feat(ai): 清空会话后保留服务端确认气泡

This commit is contained in:
lik
2026-11-01 11:45:29 +08:00
parent 747a6405d0
commit 57f0c6c8a6
+11 -2
View File
@@ -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
}