feat: 终止请求后的调整

This commit is contained in:
zoujing
2025-08-06 13:52:32 +08:00
parent 65653525a0
commit 6f9f129883
2 changed files with 7 additions and 1 deletions

View File

@@ -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;
}
}

View File

@@ -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 {