From 57f0c6c8a692a2d88d84d1eb151c4d70f07dd497 Mon Sep 17 00:00:00 2001 From: lik Date: Sun, 1 Nov 2026 11:45:29 +0800 Subject: [PATCH] =?UTF-8?q?feat(ai):=20=E6=B8=85=E7=A9=BA=E4=BC=9A?= =?UTF-8?q?=E8=AF=9D=E5=90=8E=E4=BF=9D=E7=95=99=E6=9C=8D=E5=8A=A1=E7=AB=AF?= =?UTF-8?q?=E7=A1=AE=E8=AE=A4=E6=B0=94=E6=B3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/ai/aichat.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/pages/ai/aichat.js b/pages/ai/aichat.js index 0360fac..7822d29 100644 --- a/pages/ai/aichat.js +++ b/pages/ai/aichat.js @@ -282,11 +282,20 @@ Page({ finishAIResponse() { const isClearRequest = this.activeRequestType === 'clear' + // 清空请求的确认语由服务端下发:只保留这条确认,其余历史随清空一起丢弃 + const clearReplyId = isClearRequest ? this.activeServerId : '' this.resetActiveRequest() if (isClearRequest) { - this.setData({ messages: [], isTyping: false }) - wx.removeStorageSync('ai_chat_history') + const messages = clearReplyId + ? this.data.messages.filter(item => item.type === 'ai' && item._serverId === clearReplyId) + : [] + this.setData({ messages, isTyping: false }) + if (messages.length) { + this.saveChatHistory(messages) + } else { + wx.removeStorageSync('ai_chat_history') + } wx.removeStorageSync('ai_session_id') return }