From 2616b53858822a0152662eb07c1ab81db8dff10f Mon Sep 17 00:00:00 2001 From: Lexcubia Date: Fri, 25 Apr 2025 14:32:24 +0800 Subject: [PATCH] =?UTF-8?q?refactor(chat):=20=E9=87=8D=E6=9E=84=E8=81=8A?= =?UTF-8?q?=E5=A4=A9=E8=BE=93=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/chat/ChatInterface.vue | 36 ++---- src/views/chat/ChatModeSelector.vue | 4 +- .../chat/{ => components}/ChatHeader.vue | 0 .../chat/components/ChatHistoryList.vue} | 0 src/views/chat/components/ChatInput.vue | 113 ++++++++++++++++++ 5 files changed, 124 insertions(+), 29 deletions(-) rename src/views/chat/{ => components}/ChatHeader.vue (100%) rename src/{components/chat/HistoryList.vue => views/chat/components/ChatHistoryList.vue} (100%) create mode 100644 src/views/chat/components/ChatInput.vue diff --git a/src/views/chat/ChatInterface.vue b/src/views/chat/ChatInterface.vue index 82259ab..f1bd866 100644 --- a/src/views/chat/ChatInterface.vue +++ b/src/views/chat/ChatInterface.vue @@ -72,27 +72,10 @@ 会话已结束 -
- - - 发送 - -
+
@@ -112,7 +95,8 @@ import { ref, onMounted, onUnmounted, nextTick, watch, computed, defineOptions } import { marked } from 'marked' import * as echarts from 'echarts' import { useChatStore } from '@/store/chat' -import ChatHeader from '@/views/chat/ChatHeader.vue' +import ChatHeader from '@/views/chat/components/ChatHeader.vue' +import ChatInput from '@/views/chat/components/ChatInput.vue' import { ElTag, ElButton, ElInput, ElAvatar } from 'element-plus' import { Plus, CaretBottom, CaretRight } from '@element-plus/icons-vue' import userAvatarUrl from '@/assets/user.png'; @@ -241,11 +225,9 @@ watch(() => currentMessages.value?.map(msg => msg.respondingType), (newTypes, ol }, { deep: true }) // 发送消息时滚动到底部 -const sendMessage = () => { - if (!messageInput.value.trim() && !sendButtonsDisabled.value) return - chatStore.sendMessage(messageInput.value) - messageInput.value = '' - messageInputRef.value.style.height = 'auto' +const sendMessage = (message) => { + if (!message.trim() && !sendButtonsDisabled.value) return + chatStore.sendMessage(message) shouldAutoScroll.value = true // 发送消息时恢复自动滚动 scrollToBottom(true) } diff --git a/src/views/chat/ChatModeSelector.vue b/src/views/chat/ChatModeSelector.vue index 99bbef9..72771db 100644 --- a/src/views/chat/ChatModeSelector.vue +++ b/src/views/chat/ChatModeSelector.vue @@ -35,7 +35,7 @@ - + +
+ + + 发送 + +
+ + + + + \ No newline at end of file