diff --git a/Frontend/Pages/Index.razor b/Frontend/Pages/Index.razor index a502275..2768761 100644 --- a/Frontend/Pages/Index.razor +++ b/Frontend/Pages/Index.razor @@ -5,7 +5,7 @@ - +
+ + +
+ +
+
@code { private string MessageSending { get; set; } = string.Empty; + private string _username = string.Empty; + private bool _setUsernameVisible = false; [Parameter] public List Messages { get; set; } = null!; @@ -53,6 +66,16 @@ [Parameter] public IChatRobot Robot { get; set; } = null!; + protected override void OnInitialized() + { + if (string.IsNullOrEmpty(_username)) + { + _setUsernameVisible = true; + } + + base.OnInitialized(); + } + private void SendMessageClicked() { if (string.IsNullOrWhiteSpace(MessageSending)) @@ -63,7 +86,7 @@ Messages.Add(new ChatMessage { Left = false, - Sender = "旅行者", + Sender = string.IsNullOrEmpty(_username) ? "default" : _username, Text = MessageSending }); @@ -79,4 +102,14 @@ MessageSending = string.Empty; } + + private void SetUsernameOkClicked() + { + _setUsernameVisible = false; + } + + private void SetUsernameCancelClicked() + { + _setUsernameVisible = false; + } } \ No newline at end of file diff --git a/Frontend/Shared/MessageBubble.razor b/Frontend/Shared/MessageBubble.razor index e05e9f4..24a9e52 100644 --- a/Frontend/Shared/MessageBubble.razor +++ b/Frontend/Shared/MessageBubble.razor @@ -5,7 +5,9 @@ { - + + @Message.Sender.First() + @@ -37,7 +39,9 @@ - + + @Message.Sender.First() + }