feat(ai): 清空会话后保留服务端确认气泡
This commit is contained in:
+11
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user