@page "/"
@using Frontend.Models
@if (@context.Selected)
{
}
else
{
}
@code {
private readonly Dictionary _chatDictionary = new();
private Guid _currentGuid;
protected override void OnInitialized()
{
var chat = new Chat
{
Title = $"对话:{_chatDictionary.Count + 1}"
};
chat.Messages.Add(new ChatMessage
{
Sender = "凯瑟琳",
Left = true,
Text = "向着星辰和深渊!欢迎来到冒险家协会。"
});
chat.Selected = true;
_chatDictionary.Add(chat.Guid, chat);
_currentGuid = chat.Guid;
}
private void CreateChatClicked()
{
var chat = new Chat
{
Title = $"对话:{_chatDictionary.Count + 1}"
};
chat.Messages.Add(new ChatMessage
{
Sender = "凯瑟琳",
Left = true,
Text = "向着星辰和深渊!欢迎来到冒险家协会。"
});
_chatDictionary.Add(chat.Guid, chat);
// 切换到新建的对话
_chatDictionary[_currentGuid].Selected = false;
_currentGuid = chat.Guid;
_chatDictionary[_currentGuid].Selected = true;
}
private void ChangeChatClicked(Guid guid)
{
_chatDictionary[_currentGuid].Selected = false;
_currentGuid = guid;
_chatDictionary[_currentGuid].Selected = true;
}
}