feat(微信): 添加wechatChatroomId字段并优化消息处理逻辑

- 在weChatGroup接口中添加wechatChatroomId字段
- 移除调试用的console.log语句
- 重构消息处理逻辑,简化条件判断并新增会话初始化处理
This commit is contained in:
超级老白兔
2025-09-05 11:47:40 +08:00
parent 2e7f890218
commit 66241f32af
3 changed files with 10 additions and 12 deletions

View File

@@ -91,18 +91,10 @@ export const useWeChatStore = create<WeChatState>()(
const currentContract = useWeChatStore.getState().currentContract;
//判断群还是好友
const getMessageId =
currentContract?.chatroomId || message.wechatFriendId;
const isGroup = currentContract?.chatroomId;
message?.wechatChatroomId || message.wechatFriendId;
if (
currentContract &&
currentContract.wechatAccountId == message.wechatAccountId &&
currentContract.id == getMessageId
) {
console.log("进入");
if (isGroup) {
message.unreadCount = 1;
}
//当前选中聊天的群或好友
if (currentContract && currentContract.id == getMessageId) {
set(state => ({
currentMessages: [...state.currentMessages, message],
}));
@@ -113,6 +105,12 @@ export const useWeChatStore = create<WeChatState>()(
if (session) {
session.unreadCount = Number(session.unreadCount) + 1;
updateChatSession(session);
} else {
// 新增会话
addChatSession({
...session,
unreadCount: 1,
});
}
}
},