From 9d991c7468538e8e8dd3f18661c7a0f5c82580d1 Mon Sep 17 00:00:00 2001 From: Soulter <37870767+Soulter@users.noreply.github.com> Date: Fri, 19 Dec 2025 11:18:01 +0800 Subject: [PATCH] perf: enhance chat components with theme and fullscreen toggles (#4116) * perf: enhance chat components with theme and fullscreen toggles - Added theme and fullscreen toggle functionality to Chat.vue and ConversationSidebar.vue. - Introduced a new StyledMenu component for improved dropdown menus. - Updated MessageList.vue and ChatInput.vue for better mobile responsiveness and UI consistency. - Enhanced language switcher integration in ConversationSidebar.vue. - Added new settings translations in English and Chinese locales. * fix: streamline conversation selection handling in Chat.vue - Updated handleSelectConversation function to immediately set the current session ID and selected sessions, reducing the need for multiple clicks. - Adjusted padding in ConversationSidebar.vue for improved layout consistency. --- dashboard/src/components/chat/Chat.vue | 95 +++++---- dashboard/src/components/chat/ChatInput.vue | 6 +- .../components/chat/ConversationSidebar.vue | 182 ++++++++++-------- dashboard/src/components/chat/MessageList.vue | 42 +++- .../components/shared/LanguageSwitcher.vue | 82 ++------ .../src/components/shared/StyledMenu.vue | 79 ++++++++ .../src/i18n/locales/en-US/core/common.json | 1 + .../src/i18n/locales/zh-CN/core/common.json | 1 + 8 files changed, 290 insertions(+), 198 deletions(-) create mode 100644 dashboard/src/components/shared/StyledMenu.vue diff --git a/dashboard/src/components/chat/Chat.vue b/dashboard/src/components/chat/Chat.vue index 5524e787d..a73bad4d1 100644 --- a/dashboard/src/components/chat/Chat.vue +++ b/dashboard/src/components/chat/Chat.vue @@ -18,61 +18,27 @@ @editTitle="showEditTitleDialog" @deleteConversation="handleDeleteConversation" @closeMobileSidebar="closeMobileSidebar" + @toggleTheme="toggleTheme" + @toggleFullscreen="toggleFullscreen" />
-
+
- + mdi-menu - - -
- - - - - - - - - - - - - - - - -
- +
+ +
+
Hello, I'm @@ -260,6 +226,14 @@ function toggleTheme() { theme.global.name.value = newTheme; } +function toggleFullscreen() { + if (props.chatboxMode) { + router.push(currSessionId.value ? `/chat/${currSessionId.value}` : '/chat'); + } else { + router.push(currSessionId.value ? `/chatbox/${currSessionId.value}` : '/chatbox'); + } +} + function openImagePreview(imageUrl: string) { previewImageUrl.value = imageUrl; imagePreviewDialog.value = true; @@ -303,11 +277,14 @@ function clearReply() { async function handleSelectConversation(sessionIds: string[]) { if (!sessionIds[0]) return; + // 立即更新选中状态,避免需要点击两次 + currSessionId.value = sessionIds[0]; + selectedSessions.value = [sessionIds[0]]; + // 更新 URL const basePath = props.chatboxMode ? '/chatbox' : '/chat'; if (route.path !== `${basePath}/${sessionIds[0]}`) { router.push(`${basePath}/${sessionIds[0]}`); - return; } // 手机端关闭侧边栏 @@ -317,9 +294,6 @@ async function handleSelectConversation(sessionIds: string[]) { // 清除引用状态 clearReply(); - - currSessionId.value = sessionIds[0]; - selectedSessions.value = [sessionIds[0]]; await getSessionMsg(sessionIds[0], router); @@ -510,6 +484,29 @@ onBeforeUnmount(() => { overflow: hidden; } +.message-list-wrapper { + flex: 1; + position: relative; + overflow: hidden; + display: flex; + flex-direction: column; +} + +.message-list-fade { + position: absolute; + bottom: 0; + left: 0; + right: 0; + height: 40px; + background: linear-gradient(to top, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%); + pointer-events: none; + z-index: 1; +} + +.message-list-fade.fade-dark { + background: linear-gradient(to top, rgba(30, 30, 30, 1) 0%, rgba(30, 30, 30, 0) 100%); +} + .conversation-header { display: flex; justify-content: space-between; diff --git a/dashboard/src/components/chat/ChatInput.vue b/dashboard/src/components/chat/ChatInput.vue index 53e1e30c0..78050d5e3 100644 --- a/dashboard/src/components/chat/ChatInput.vue +++ b/dashboard/src/components/chat/ChatInput.vue @@ -1,7 +1,7 @@