From 92b00a3477fce382ecd2f548a34d90d771bf1240 Mon Sep 17 00:00:00 2001 From: jackfiled Date: Mon, 9 Oct 2023 19:32:56 +0800 Subject: [PATCH] dev: robot interface --- Frontend/Pages/Index.razor | 94 ++-------------------------- Frontend/Pages/Index.razor.css | 42 ------------- Frontend/Shared/Chat.razor | 88 ++++++++++++++++++++++++++ Frontend/Shared/Chat.razor.css | 58 +++++++++++++++++ Katheryne.sln | 6 ++ Katheryne.sln.DotSettings | 2 + Katheryne/Abstractions/IChatRobot.cs | 15 +++++ Katheryne/Katheryne.csproj | 9 +++ 8 files changed, 184 insertions(+), 130 deletions(-) create mode 100644 Frontend/Shared/Chat.razor create mode 100644 Frontend/Shared/Chat.razor.css create mode 100644 Katheryne.sln.DotSettings create mode 100644 Katheryne/Abstractions/IChatRobot.cs create mode 100644 Katheryne/Katheryne.csproj diff --git a/Frontend/Pages/Index.razor b/Frontend/Pages/Index.razor index 10b8726..ea216ab 100644 --- a/Frontend/Pages/Index.razor +++ b/Frontend/Pages/Index.razor @@ -1,98 +1,16 @@ @page "/" -@using Frontend.Models -@inject ILogger Logger + - + - + -
-
- - - @if (context.Left) - { -
- -
- } - else - { -
- -
- } -
-
-
- -
-
- -
-
-
- - - - - - - - -
-
-
-
+
-@code -{ - private string MessageSending { get; set; } = string.Empty; - - private readonly List _messages = new() - { - new ChatMessage - { - Sender = "凯瑟琳", - Text = "向着星辰和深渊!", - Left = true - }, - new ChatMessage - { - Sender = "凯瑟琳", - Text = "欢迎来到冒险家协会。", - Left = true - } - }; - - private void SendMessageClicked() - { - if (string.IsNullOrWhiteSpace(MessageSending)) - { - return; - } - - _messages.Add(new ChatMessage - { - Left = false, - Sender = "旅行者", - Text = MessageSending - }); - - MessageSending = string.Empty; - - _messages.Add(new ChatMessage - { - Left = true, - Sender = "凯瑟琳", - Text = "对不起,做不到。" - }); - } +@code { + } \ No newline at end of file diff --git a/Frontend/Pages/Index.razor.css b/Frontend/Pages/Index.razor.css index 320dfb9..e69de29 100644 --- a/Frontend/Pages/Index.razor.css +++ b/Frontend/Pages/Index.razor.css @@ -1,42 +0,0 @@ -.chat-column { - margin-left: auto; -} - -.content-zone { - align-items: center; - display: flex; - flex-direction: column; - width: 100%; - min-height: calc(100vh - 64px); - max-height: calc(100vh - 64px); - padding: 10px; - position: relative; - background: linear-gradient(180deg, - #f5f4f6, - #b5bddf); - overflow: hidden; -} - -.chat-zone { - min-width: 100%; - display: flex; - flex-direction: column; - position: relative; - height: 100%; - overflow-y: auto; -} - -.control-zone { - min-width: 100%; - bottom: 0; - position: absolute; - background-color: #b5bddf; - display: block; - box-shadow: 3px 0 0 #b5bddf; -} - -.input-zone { - padding: 10px; - border-radius: 15px; - background-color: white; -} \ No newline at end of file diff --git a/Frontend/Shared/Chat.razor b/Frontend/Shared/Chat.razor new file mode 100644 index 0000000..bbb62bf --- /dev/null +++ b/Frontend/Shared/Chat.razor @@ -0,0 +1,88 @@ +@using Frontend.Models + +
+
+ + + @if (context.Left) + { +
+ +
+ } + else + { +
+ +
+ } +
+
+
+ +
+
+ +
+
+
+ + + + + + + + +
+
+
+
+ +@code +{ + private string MessageSending { get; set; } = string.Empty; + + private readonly List _messages = new() + { + new ChatMessage + { + Sender = "凯瑟琳", + Text = "向着星辰和深渊!", + Left = true + }, + new ChatMessage + { + Sender = "凯瑟琳", + Text = "欢迎来到冒险家协会。", + Left = true + } + }; + + private void SendMessageClicked() + { + if (string.IsNullOrWhiteSpace(MessageSending)) + { + return; + } + + _messages.Add(new ChatMessage + { + Left = false, + Sender = "旅行者", + Text = MessageSending + }); + + MessageSending = string.Empty; + + _messages.Add(new ChatMessage + { + Left = true, + Sender = "凯瑟琳", + Text = "对不起,做不到。" + }); + } +} \ No newline at end of file diff --git a/Frontend/Shared/Chat.razor.css b/Frontend/Shared/Chat.razor.css new file mode 100644 index 0000000..69d3a72 --- /dev/null +++ b/Frontend/Shared/Chat.razor.css @@ -0,0 +1,58 @@ +.chat-column { + margin-left: auto; +} + +.content-zone { + align-items: center; + display: flex; + flex-direction: column; + width: 100%; + min-height: calc(100vh - 64px); + max-height: calc(100vh - 64px); + padding: 10px; + position: relative; + background: linear-gradient(180deg, + #f5f4f6, + #b5bddf); + overflow: hidden; +} + +.chat-zone { + min-width: 100%; + display: flex; + flex-direction: column; + position: relative; + height: 100%; + overflow-y: auto; +} + +.chat-zone::-webkit-scrollbar { + width: 10px; + height: 1px; +} + +.chat-zone::-webkit-scrollbar-thumb { + border-radius: 10px; + -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2); + background: #bdbdbd; +} + +.chat-zone::-webkit-scrollbar-track { + border-radius: 10px; + background: #fff; +} + +.control-zone { + min-width: 100%; + bottom: 0; + position: absolute; + background-color: #b5bddf; + display: block; + box-shadow: 3px 0 0 #b5bddf; +} + +.input-zone { + padding: 10px; + border-radius: 15px; + background-color: white; +} \ No newline at end of file diff --git a/Katheryne.sln b/Katheryne.sln index df710db..89b4f08 100644 --- a/Katheryne.sln +++ b/Katheryne.sln @@ -2,6 +2,8 @@ Microsoft Visual Studio Solution File, Format Version 12.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Frontend", "Frontend\Frontend.csproj", "{6DD57D75-C2C2-48DA-A7FB-8FA9BEBBBA99}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Katheryne", "Katheryne\Katheryne.csproj", "{74F745FB-2F2B-4B56-A387-3B490EFE9615}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -12,5 +14,9 @@ Global {6DD57D75-C2C2-48DA-A7FB-8FA9BEBBBA99}.Debug|Any CPU.Build.0 = Debug|Any CPU {6DD57D75-C2C2-48DA-A7FB-8FA9BEBBBA99}.Release|Any CPU.ActiveCfg = Release|Any CPU {6DD57D75-C2C2-48DA-A7FB-8FA9BEBBBA99}.Release|Any CPU.Build.0 = Release|Any CPU + {74F745FB-2F2B-4B56-A387-3B490EFE9615}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {74F745FB-2F2B-4B56-A387-3B490EFE9615}.Debug|Any CPU.Build.0 = Debug|Any CPU + {74F745FB-2F2B-4B56-A387-3B490EFE9615}.Release|Any CPU.ActiveCfg = Release|Any CPU + {74F745FB-2F2B-4B56-A387-3B490EFE9615}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/Katheryne.sln.DotSettings b/Katheryne.sln.DotSettings new file mode 100644 index 0000000..e83eeaa --- /dev/null +++ b/Katheryne.sln.DotSettings @@ -0,0 +1,2 @@ + + True \ No newline at end of file diff --git a/Katheryne/Abstractions/IChatRobot.cs b/Katheryne/Abstractions/IChatRobot.cs new file mode 100644 index 0000000..ea64e2d --- /dev/null +++ b/Katheryne/Abstractions/IChatRobot.cs @@ -0,0 +1,15 @@ +namespace Katheryne.Abstractions; + +/// +/// 对话机器人接口 +/// +public interface IChatRobot +{ + public string RobotName { get; } + + public IEnumerable OnChatStart(); + + public IEnumerable OnChatStop(); + + +} \ No newline at end of file diff --git a/Katheryne/Katheryne.csproj b/Katheryne/Katheryne.csproj new file mode 100644 index 0000000..6836c68 --- /dev/null +++ b/Katheryne/Katheryne.csproj @@ -0,0 +1,9 @@ + + + + net7.0 + enable + enable + + +