From 87a302b799e49f899874afb3fb4ce9955a104ac0 Mon Sep 17 00:00:00 2001 From: zoujing Date: Tue, 29 Jul 2025 20:21:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=20=E6=9D=A5=E5=AF=B9=E8=AF=9D=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/chat/ChatMainList.vue | 30 ++++++++++++++++++++++++------ pages/chat/ChatQuickAccess.vue | 10 +++++++--- pages/chat/ChatTopWelcome.vue | 6 +++--- request/api/AgentChatStream.js | 12 +++++++++++- 4 files changed, 45 insertions(+), 13 deletions(-) diff --git a/pages/chat/ChatMainList.vue b/pages/chat/ChatMainList.vue index 028d055..0ba2415 100644 --- a/pages/chat/ChatMainList.vue +++ b/pages/chat/ChatMainList.vue @@ -116,6 +116,8 @@ // 会话进行中标志 let isSessionActive = false; + /// 指令 + let commonType = '' // 打开抽屉 @@ -167,8 +169,13 @@ }; /// 是发送指令 - const handleReplyInstruct = (text) => { - sendMessage(text, true) + const handleReplyInstruct = (item) => { + if(item.type === 'MyOrder') { + /// 订单 + return + } + commonType = item.type + sendMessage(item.title, true) setTimeoutScrollToBottom() } @@ -271,7 +278,7 @@ conversationId: conversationId.value, agentId: agentId.value, messageType: isInstruct ? 1 : 0, - messageContent: message + messageContent: isInstruct ? commonType : message } // 插入AI消息 @@ -305,9 +312,10 @@ // 流式接收内容 agentChatStream(args, (chunk) => { console.log('分段内容:', chunk) - if (chunk.error) { + if (chunk && chunk.error) { chatMsgList.value[aiMsgIndex].msg = '请求错误,请重试'; - clearInterval(finishInterval); + clearInterval(loadingTimer); + loadingTimer = null; isTyping = false; typeWriterTimer = null; isSessionActive = false; // 出错也允许再次发送 @@ -334,10 +342,20 @@ if (chunk && chunk.finish) { // 结尾处理:确保剩余内容全部输出 const finishInterval = setInterval(() => { + console.log('aiMsgBuffer.length:', aiMsgBuffer.length) if (aiMsgBuffer.length === 0) { clearInterval(finishInterval); + clearInterval(loadingTimer); + loadingTimer = null; isTyping = false; - isSessionActive = false; // 会话结束,允许再次发送 + typeWriterTimer = null; + // 补全:如果消息内容还停留在'加载中.'或为空,则给出友好提示 + const msg = chatMsgList.value[aiMsgIndex].msg; + console.log('msg:', msg) + if (!msg || msg === '加载中.' || msg.startsWith('加载中')) { + chatMsgList.value[aiMsgIndex].msg = '未获取到内容,请重试'; + } + isSessionActive = false; scrollToBottom(); } }, 50); diff --git a/pages/chat/ChatQuickAccess.vue b/pages/chat/ChatQuickAccess.vue index dda0f3f..76e09d3 100644 --- a/pages/chat/ChatQuickAccess.vue +++ b/pages/chat/ChatQuickAccess.vue @@ -1,7 +1,7 @@