From 4c6d35421a27e03578a1c3ddb000b7ead7fdcea3 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Mon, 16 Oct 2023 14:00:03 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E7=BE=8E=E5=8C=96=E5=A4=B4=E5=83=8F?= =?UTF-8?q?=E5=92=8C=E8=AE=BE=E7=BD=AE=E7=94=A8=E6=88=B7=E5=90=8D=E7=A7=B0?= =?UTF-8?q?=E8=BF=87=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Frontend/Pages/Index.razor | 2 +- Frontend/Pages/Index.razor.css | 1 + Frontend/Shared/ChatZone.razor | 35 ++++++++++++++++++++++++++++- Frontend/Shared/MessageBubble.razor | 8 +++++-- 4 files changed, 42 insertions(+), 4 deletions(-) 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() + }