From 7239313f0fa32e469016456282d4dfeda4e2aa3d Mon Sep 17 00:00:00 2001 From: zoujing Date: Thu, 8 Jan 2026 14:46:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E7=9A=84=E4=B8=AD=E6=96=AD=E9=87=8D=E8=BF=9E?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/chat/ChatMainList/index.vue | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/pages/index/components/chat/ChatMainList/index.vue b/src/pages/index/components/chat/ChatMainList/index.vue index 653c8fd..bc51ac3 100644 --- a/src/pages/index/components/chat/ChatMainList/index.vue +++ b/src/pages/index/components/chat/ChatMainList/index.vue @@ -581,18 +581,19 @@ const sendChat = (message, isInstruct = false) => { initWebSocket(); // 短暂延迟后再次检查连接状态 setTimeout(() => { - if (webSocketManager && webSocketManager.isConnected()) { + const connected = webSocketManager && webSocketManager.isConnected(); + isSessionActive.value = connected; + // 更新AI消息状态 + const aiMsgIndex = chatMsgList.value.length - 1; + if (aiMsgIndex >= 0 && chatMsgList.value[aiMsgIndex].msgType === MessageRole.AI) { + chatMsgList.value[aiMsgIndex].msg = connected ? "" : "发送消息失败,请重试"; + chatMsgList.value[aiMsgIndex].isLoading = connected; + } + if (connected) { // 连接成功后重新发送消息 sendChat(message, isInstruct); } else { console.error("WebSocket重新初始化失败"); - isSessionActive.value = false; - // 更新AI消息状态为失败 - const aiMsgIndex = chatMsgList.value.length - 1; - if (aiMsgIndex >= 0 && chatMsgList.value[aiMsgIndex].msgType === MessageRole.AI) { - chatMsgList.value[aiMsgIndex].msg = "发送消息失败,请重试"; - chatMsgList.value[aiMsgIndex].isLoading = false; - } } }, 1000); return;