From acaf8c3086cd91fc81be87c753bbc2b2312ca893 Mon Sep 17 00:00:00 2001 From: WangJing Date: Tue, 29 Jul 2025 17:57:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E6=B6=88=E6=81=AF=E4=BD=93?= =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=8A=96=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/chatweb/components/ChatBox.vue | 21 ++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/chat-client/src/views/chatweb/components/ChatBox.vue b/chat-client/src/views/chatweb/components/ChatBox.vue index 28c6dcb..dc8dfcc 100644 --- a/chat-client/src/views/chatweb/components/ChatBox.vue +++ b/chat-client/src/views/chatweb/components/ChatBox.vue @@ -385,6 +385,7 @@ import VabChart from '@/plugins/VabChart/index.vue' import { sendChatMessage, type ChatMessageResponse, type ChatMessageSendRequest, stopMessagesStream, getFilePathList, type TraceFile, type TraceData } from '@/api/chat' import { useI18n } from 'vue-i18n' +import { throttle } from 'lodash' const { t, locale } = useI18n() // Props 定义 @@ -800,8 +801,10 @@ const sendMessage = async () => { currentTaskId.value = data.taskId } - messages.value = [...messages.value] - await scrollToBottom() + // messages.value = [...messages.value] + // botMessage.text += data.answer + // await scrollToBottom() + throttledScrollToBottom() } } catch (e) { console.error('解析错误:', e) @@ -821,7 +824,7 @@ const sendMessage = async () => { const formatted = await formatAnswer(parseThink(botMessage.text).answer) botMessage.formattedText = formatted.html botMessage.echarts = formatted.echarts - messages.value = [...messages.value] + // messages.value = [...messages.value] if (data.conversationId) { newConversationId = data.conversationId @@ -849,7 +852,7 @@ const sendMessage = async () => { botMessage.sources = data botMessage.conversationId = newConversationId botMessage.messageId = newMessageId - messages.value = [...messages.value] + // messages.value = [...messages.value] } } catch (error) { console.log('获取文件来源失败:', error) @@ -893,6 +896,10 @@ const scrollToBottom = async () => { } } +const throttledScrollToBottom = throttle(() => { + scrollToBottom() +}, 150) + // 解析方法 const parseThink = (text: string) => { const thinkRegex = /(.*?)<\/think>/s @@ -1280,7 +1287,7 @@ const regenerateResponse = async (userQuery: string) => { currentTaskId.value = data.taskId } - messages.value = [...messages.value] + // messages.value = [...messages.value] await scrollToBottom() } } catch (e) { @@ -1301,7 +1308,7 @@ const regenerateResponse = async (userQuery: string) => { const formatted = await formatAnswer(parseThink(botMessage.text).answer) botMessage.formattedText = formatted.html botMessage.echarts = formatted.echarts - messages.value = [...messages.value] + // messages.value = [...messages.value] if (data.conversationId) { newConversationId = data.conversationId @@ -1329,7 +1336,7 @@ const regenerateResponse = async (userQuery: string) => { botMessage.sources = data botMessage.conversationId = newConversationId botMessage.messageId = newMessageId - messages.value = [...messages.value] + // messages.value = [...messages.value] } } catch (error) { console.log('获取文件来源失败:', error)