From 5a088555c867b67c0d961cc8c3f0c7945c77a467 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A6=85=E9=A5=BC?= <2815246336@qq.com> Date: Tue, 19 Aug 2025 11:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=81=8A=E5=A4=A9=E5=8A=A0?= =?UTF-8?q?=E8=BD=BD=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layout/components/Aichat/ChatPopup.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/layout/components/Aichat/ChatPopup.vue b/src/layout/components/Aichat/ChatPopup.vue index e1a9d4a..1857fb2 100644 --- a/src/layout/components/Aichat/ChatPopup.vue +++ b/src/layout/components/Aichat/ChatPopup.vue @@ -718,6 +718,10 @@ export default { this.inputMessage = '' this.sending = true + // 定义超时变量 + let streamTimeout = null + let noDataTimeout = null + // 添加到请求队列 const requestId = Date.now() this.requestQueue.push(requestId) @@ -730,6 +734,9 @@ export default { messageId: 'user-' + Date.now() } this.messages.push(userMsg) + + // 添加用户消息后立即滚动到底部 + this.scrollToBottom(false, true) // 立即滚动,强制执行 // 添加AI消息占位符 const aiMsg = { @@ -743,7 +750,7 @@ export default { } this.messages.push(aiMsg) - this.scrollToBottom(true) // 添加消息后使用平滑滚动 + this.scrollToBottom(true, true) // 添加消息后使用平滑滚动,强制执行 try { // 创建流式聊天 @@ -766,7 +773,7 @@ export default { }) // 添加额外的超时保护 - const streamTimeout = setTimeout(() => { + streamTimeout = setTimeout(() => { if (cancel) { cancel('流式响应超时') } @@ -781,7 +788,6 @@ export default { const { reader, decoder } = response let buffer = '' let lastUpdateTime = Date.now() - let noDataTimeout = null while (true) { // 设置无数据超时检测 @@ -907,7 +913,7 @@ export default { // 从监控系统中移除请求 this.activeRequests.delete(requestId) - this.scrollToBottom(true) // 发送完成后使用平滑滚动 + this.scrollToBottom(true, true) // 发送完成后使用平滑滚动,强制执行 } },