feat:【antd】【ai】chat “返回异常时空消息删除”的迁移

This commit is contained in:
YunaiV
2025-11-15 19:06:37 +08:00
parent 6dd9e9e699
commit 71e638188e
2 changed files with 20 additions and 1 deletions

View File

@@ -359,6 +359,10 @@ async function doSendMessageStream(userMessage: AiChatMessageApi.ChatMessage) {
const { code, data, msg } = JSON.parse(res.data);
if (code !== 0) {
await alert(`对话异常! ${msg}`);
// 如果未接收到消息,则进行删除
if (receiveMessageFullText.value === '') {
activeMessageList.value.pop();
}
return;
}
@@ -382,7 +386,8 @@ async function doSendMessageStream(userMessage: AiChatMessageApi.ChatMessage) {
await scrollToBottom();
},
(error: any) => {
alert(`对话异常! ${error}`);
// 异常提示,并停止流
alert(`对话异常!`);
stopStream();
// 需要抛出异常,禁止重试
throw error;