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)