From 03095969516cc3d3916180d191bca9863cbb2888 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Fri, 6 Jun 2025 17:09:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=9E=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/store/chatStore.js | 15 +++++---------- im-web/src/store/chatStore.js | 12 ++++-------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index 9a88579..27e91c8 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -374,7 +374,6 @@ export default defineStore('chatStore', { this.chats.forEach((chat) => { let chatKey = `${key}-${chat.type}-${chat.targetId}` if (!chat.stored) { - chat.stored = true; if (chat.delete) { uni.removeStorageSync(chatKey); } else { @@ -386,15 +385,11 @@ export default defineStore('chatStore', { } // 存储热消息 let hotKey = chatKey + '-hot'; - if (chat.messages.length > chat.hotMinIdx) { - let hotChat = Object.assign({}, chat); - hotChat.messages = chat.messages.slice(chat.hotMinIdx) - uni.setStorageSync(hotKey, hotChat); - console.log("热数据:",hotChat.messages.length) - } else { - uni.removeStorageSync(hotKey); - } + let hotChat = Object.assign({}, chat); + hotChat.messages = chat.messages.slice(chat.hotMinIdx) + uni.setStorageSync(hotKey, hotChat); } + chat.stored = true; } if (!chat.delete) { chatKeys.push(chatKey); @@ -429,7 +424,7 @@ export default defineStore('chatStore', { chatsData.chatKeys.forEach(key => { let coldChat = uni.getStorageSync(key); let hotChat = uni.getStorageSync(key + '-hot'); - if (!coldChat && hotChat) { + if (!coldChat && !hotChat) { return; } // 冷热消息合并 diff --git a/im-web/src/store/chatStore.js b/im-web/src/store/chatStore.js index ae8f55c..712a162 100644 --- a/im-web/src/store/chatStore.js +++ b/im-web/src/store/chatStore.js @@ -370,7 +370,6 @@ export default defineStore('chatStore', { // 只存储有改动的会话 let chatKey = `${key}-${chat.type}-${chat.targetId}` if (!chat.stored) { - chat.stored = true; if (chat.delete) { localForage.removeItem(chatKey); } else { @@ -382,14 +381,11 @@ export default defineStore('chatStore', { } // 存储热消息 let hotKey = chatKey + '-hot'; - if (chat.messages.length > chat.hotMinIdx) { - let hotChat = Object.assign({}, chat); - hotChat.messages = chat.messages.slice(chat.hotMinIdx) - localForage.setItem(hotKey, hotChat) - } else { - localForage.removeItem(hotKey); - } + let hotChat = Object.assign({}, chat); + hotChat.messages = chat.messages.slice(chat.hotMinIdx) + localForage.setItem(hotKey, hotChat) } + chat.stored = true; } if (!chat.delete) { chatKeys.push(chatKey);