From 386a2c422f214333b81511ed957174705e4ccc57 Mon Sep 17 00:00:00 2001 From: Wenjie Zhang Date: Sat, 9 Aug 2025 23:18:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E7=95=8C=E9=9D=A2=E6=A0=B7=E5=BC=8F=E5=92=8C=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E4=BD=93=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将默认对话标题从"新对话"改为"新的对话" - 调整聊天侧边栏的背景色和悬停效果 - 在空聊天状态添加输入框 - 重构智能体选择器为弹窗模式 - 改进消息输入组件支持单行/多行模式 - 优化加载动画和生成状态指示器 --- server/routers/chat_router.py | 2 +- web/src/apis/auth_api.js | 2 +- web/src/components/AgentChatComponent.vue | 73 +++- web/src/components/ChatSidebarComponent.vue | 10 +- web/src/components/MessageInputComponent.vue | 398 ++++++++++++++----- web/src/views/AgentView.vue | 221 +++++++++- 6 files changed, 554 insertions(+), 152 deletions(-) diff --git a/server/routers/chat_router.py b/server/routers/chat_router.py index f0e81a71..9b1946da 100644 --- a/server/routers/chat_router.py +++ b/server/routers/chat_router.py @@ -285,7 +285,7 @@ async def create_thread( id=thread_id, user_id=str(current_user.id), agent_id=thread.agent_id, - title=thread.title or "新对话", + title=thread.title or "新的对话", description=thread.description, ) diff --git a/web/src/apis/auth_api.js b/web/src/apis/auth_api.js index 69e93641..9310bfe9 100644 --- a/web/src/apis/auth_api.js +++ b/web/src/apis/auth_api.js @@ -120,7 +120,7 @@ export const threadApi = { */ createThread: (agentId, title, metadata) => apiPost('/api/chat/thread', { agent_id: agentId, - title: title || '新对话', + title: title || '新的对话', metadata: metadata || {} }, {}, true), diff --git a/web/src/components/AgentChatComponent.vue b/web/src/components/AgentChatComponent.vue index 646bca26..23348dfa 100644 --- a/web/src/components/AgentChatComponent.vue +++ b/web/src/components/AgentChatComponent.vue @@ -27,7 +27,7 @@
@@ -56,8 +56,21 @@

{{ currentAgent ? currentAgent.name : '请选择一个智能体开始对话' }}

{{ currentAgent ? currentAgent.description : '不同的智能体有不同的专长和能力' }}

+
+ +
+ +
-
+
{ try { // 调用API创建新对话 state.creatingNewChat = true; - const response = await threadApi.createThread(props.agentId, '新对话'); + const response = await threadApi.createThread(props.agentId, '新的对话'); if (!response || !response.id) { throw new Error('创建对话失败'); } @@ -1436,13 +1449,20 @@ const mergeMessageChunk = (chunks) => { h1 { margin-bottom: 20px; - font-size: 1.2rem; - color: var(--gray-900); + font-size: 1.3rem; + color: var(--gray-1000); } p { + font-size: 1.1rem; color: var(--gray-700); } + + .inputer-init { + margin: 40px auto; + width: 80%; + max-width: 800px; + } } .chat-loading { @@ -1550,16 +1570,16 @@ const mergeMessageChunk = (chunks) => { display: inline-flex; align-items: center; justify-content: center; + gap: 3px; } .loading-dots div { - width: 8px; - height: 8px; - margin: 0 4px; - background-color: var(--gray-700); + width: 6px; + height: 6px; + background: linear-gradient(135deg, var(--main-color), var(--main-700)); border-radius: 50%; - opacity: 0.3; - animation: pulse 0.5s infinite ease-in-out both; + animation: dotPulse 1.4s infinite ease-in-out both; + box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3); } .loading-dots div:nth-child(1) { @@ -1570,25 +1590,29 @@ const mergeMessageChunk = (chunks) => { animation-delay: -0.16s; } +.loading-dots div:nth-child(3) { + animation-delay: 0s; +} + .generating-status { display: flex; justify-content: flex-start; - padding: 0.8rem 0; - animation: fadeInUp 0.3s ease-out; + padding: 1rem 0; + animation: fadeInUp 0.4s ease-out; + transition: all 0.2s; } .generating-indicator { display: flex; align-items: center; - padding: 0.5rem 1rem 0.5rem 0.5rem; - background: var(--gray-100); - border-radius: 12px; - border: 1px solid var(--gray-200); + padding: 0.75rem 0rem; .generating-text { margin-left: 12px; color: var(--gray-700); font-size: 14px; + font-weight: 500; + letter-spacing: 0.025em; } } @@ -1625,17 +1649,26 @@ const mergeMessageChunk = (chunks) => { } } -@keyframes pulse { +@keyframes dotPulse { 0%, 80%, 100% { transform: scale(0.8); - opacity: 0.3; + opacity: 0.5; } 40% { - transform: scale(1); + transform: scale(1.1); opacity: 1; } } +@keyframes shimmer { + 0% { + left: -100%; + } + 100% { + left: 100%; + } +} + @keyframes swing-in-top-fwd { 0% { transform: rotateX(-100deg); diff --git a/web/src/components/ChatSidebarComponent.vue b/web/src/components/ChatSidebarComponent.vue index 5f452736..e4c69295 100644 --- a/web/src/components/ChatSidebarComponent.vue +++ b/web/src/components/ChatSidebarComponent.vue @@ -25,7 +25,7 @@ :class="{ 'active': currentChatId === chat.id }" @click="selectChat(chat)" > -
{{ chat.title || '新对话' }}
+
{{ chat.title || '新的对话' }}
@@ -244,7 +244,7 @@ const toggleCollapse = () => { width: 100%; padding: 8px 12px; border-radius: 6px; - background-color: var(--main-50); + background-color: var(--gray-50); color: var(--main-color); border: none; transition: all 0.2s ease; @@ -332,7 +332,7 @@ const toggleCollapse = () => { } &:hover { - background-color: var(--gray-100); + background-color: var(--gray-50); .actions-mask { background: linear-gradient(to right, transparent, var(--gray-100) 20px); @@ -344,14 +344,14 @@ const toggleCollapse = () => { } &.active { - background-color: var(--main-50); + background-color: var(--gray-100); .conversation-title { color: var(--main-600); font-weight: 500; } .actions-mask { - background: linear-gradient(to right, transparent, var(--main-50) 20px); + background: linear-gradient(to right, transparent, var(--gray-100) 20px); } } } diff --git a/web/src/components/MessageInputComponent.vue b/web/src/components/MessageInputComponent.vue index e439f80e..117272f8 100644 --- a/web/src/components/MessageInputComponent.vue +++ b/web/src/components/MessageInputComponent.vue @@ -1,48 +1,76 @@