From a5e468d0c179732abc5984980ab2c36fc564a9a6 Mon Sep 17 00:00:00 2001 From: Twilight Date: Mon, 16 Sep 2024 23:54:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=20=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/Chat.vue | 10 +++++++++- src/plugins/httpInterceptors.ts | 7 ------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/components/chat/Chat.vue b/src/components/chat/Chat.vue index 5fb4339..2a82185 100644 --- a/src/components/chat/Chat.vue +++ b/src/components/chat/Chat.vue @@ -413,7 +413,7 @@ async function sendMessage( }) .catch(async (err) => { // if 409 - if (err.response.status === 409) { + if (err.response?.status === 409) { const streamId = err.response.data.data?.stream_id; if (streamId) { @@ -481,6 +481,14 @@ function streamChat(streamId: String, redirect = false) { const url = getApi().conf.basePath + "/api/v1/stream/" + streamId; const evtSource = new EventSource(url); + // 如果 error + evtSource.onerror = (e) => { + dialog.error({ + title: "推理失败", + content: "目前无法完成推理,请稍后再试。", + positiveText: "好", + }); + } let messageAdded = false; diff --git a/src/plugins/httpInterceptors.ts b/src/plugins/httpInterceptors.ts index 7959fea..ed7f244 100644 --- a/src/plugins/httpInterceptors.ts +++ b/src/plugins/httpInterceptors.ts @@ -101,13 +101,6 @@ const response = { return h(error500); }, }); - } else { - if (data.length !== 0) { - dialog.error({ - title: "错误", - content: data, - }); - } } return Promise.reject(error);