From b5d16a2bfab4c54800acf92546abc237e591c873 Mon Sep 17 00:00:00 2001 From: lik Date: Sun, 1 Nov 2026 11:45:35 +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 --- src/pages/ai/aichat.tsx | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/pages/ai/aichat.tsx b/src/pages/ai/aichat.tsx index b107c37..1777226 100644 --- a/src/pages/ai/aichat.tsx +++ b/src/pages/ai/aichat.tsx @@ -208,12 +208,21 @@ export default function AiChat() { function finishAIResponse() { const isClearRequest = activeRequestTypeRef.current === 'clear' + // 清空请求的确认语由服务端下发:只保留这条确认,其余历史随清空一起丢弃 + const clearReplyId = isClearRequest ? activeRequestIdRef.current : '' resetActiveRequest() if (isClearRequest) { - updateMessages([]) + const list = clearReplyId + ? messagesRef.current.filter(item => item.type === 'ai' && item._serverId === clearReplyId) + : [] + updateMessages(list) setIsTyping(false) - Taro.removeStorageSync('ai_chat_history') + if (list.length) { + saveChatHistory(list) + } else { + Taro.removeStorageSync('ai_chat_history') + } Taro.removeStorageSync('ai_session_id') return }