From 7bd7bd3564685e2a9f7f5ee509cfb6f368f3beac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B6=85=E7=BA=A7=E8=80=81=E7=99=BD=E5=85=94?= Date: Wed, 3 Sep 2025 18:20:24 +0800 Subject: [PATCH] =?UTF-8?q?fix(weChat/ckchat):=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E8=81=94=E7=B3=BB=E4=BA=BA=E6=97=B6=E6=9C=AA?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E6=9C=AA=E8=AF=BB=E8=AE=A1=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 在切换联系人时,确保会话的未读计数被正确重置为0。将重置逻辑统一移至addChatSession方法中处理,避免遗漏。 --- Cunkebao/src/store/module/ckchat/ckchat.ts | 2 +- Cunkebao/src/store/module/weChat/weChat.ts | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cunkebao/src/store/module/ckchat/ckchat.ts b/Cunkebao/src/store/module/ckchat/ckchat.ts index 686ee2f9b..d0a16103b 100644 --- a/Cunkebao/src/store/module/ckchat/ckchat.ts +++ b/Cunkebao/src/store/module/ckchat/ckchat.ts @@ -9,7 +9,6 @@ import { } from "@/pages/pc/ckbox/data"; import { kfUserService, weChatGroupService, contractService } from "@/utils/db"; import { createContractList } from "@/store/module/ckchat/api"; -import { deepCopy } from "@/utils/common"; export const useCkChatStore = createPersistStore( set => ({ @@ -363,6 +362,7 @@ export const useCkChatStore = createPersistStore( })(), // 添加聊天会话 addChatSession: (session: ContractData | weChatGroup) => { + session.unreadCount = 0; set(state => { // 检查是否已存在相同id的会话 const exists = state.chatSessions.some(item => item.id === session.id); diff --git a/Cunkebao/src/store/module/weChat/weChat.ts b/Cunkebao/src/store/module/weChat/weChat.ts index 182fa937c..30d65ead1 100644 --- a/Cunkebao/src/store/module/weChat/weChat.ts +++ b/Cunkebao/src/store/module/weChat/weChat.ts @@ -24,7 +24,6 @@ export const useWeChatStore = create()( // 切换联系人时清空当前消息,等待重新加载 set({ currentMessages: [] }); clearUnreadCount([contract.id]).then(() => { - contract.unreadCount = 0; addChatSession(contract); set({ currentContract: contract }); updateConfig({