From 6f9f1298832a8356e7d5aebdd419cc0575cf5f8a Mon Sep 17 00:00:00 2001 From: zoujing Date: Wed, 6 Aug 2025 13:52:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E7=BB=88=E6=AD=A2=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E5=90=8E=E7=9A=84=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chat/ChatMainList.vue | 5 +++++ request/api/AgentChatStream.js | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pages/chat/ChatMainList.vue b/pages/chat/ChatMainList.vue index 979c833..df480b2 100644 --- a/pages/chat/ChatMainList.vue +++ b/pages/chat/ChatMainList.vue @@ -490,6 +490,9 @@ // 停止请求函数 const stopRequest = () => { if (requestTaskRef.value && requestTaskRef.value.abort) { + // 标记请求已中止,用于过滤后续可能到达的数据 + requestTaskRef.value.isAborted = true; + // 中止请求 requestTaskRef.value.abort(); // 重置状态 isSessionActive.value = false; @@ -507,6 +510,8 @@ typeWriterTimer = null; } setTimeoutScrollToBottom() + // 清空请求引用 + requestTaskRef.value = null; } } diff --git a/request/api/AgentChatStream.js b/request/api/AgentChatStream.js index 0cba5cf..d972d8b 100644 --- a/request/api/AgentChatStream.js +++ b/request/api/AgentChatStream.js @@ -59,7 +59,8 @@ function agentChatStream(params, onChunk) { }); requestTask.onChunkReceived(res => { - if (hasError) return; + // 检查请求是否已被中止 + if (hasError || requestTask.isAborted) return; const base64 = uni.arrayBufferToBase64(res.data); let data = ''; try {