@using Frontend.Models
@using Katheryne.Abstractions
@if (context.Left)
{
}
else
{
}
@code
{
private string MessageSending { get; set; } = string.Empty;
[Parameter]
public List Messages { get; set; } = null!;
[Parameter]
public IChatRobot Robot { get; set; } = null!;
private void SendMessageClicked()
{
if (string.IsNullOrWhiteSpace(MessageSending))
{
return;
}
Messages.Add(new ChatMessage
{
Left = false,
Sender = "旅行者",
Text = MessageSending
});
foreach (string answer in Robot.ChatNext(MessageSending))
{
Messages.Add(new ChatMessage
{
Left = true,
Sender = Robot.RobotName,
Text = answer
});
}
MessageSending = string.Empty;
}
}