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