diff --git a/Touchkebao/src/store/module/weChat/weChat.data.ts b/Touchkebao/src/store/module/weChat/weChat.data.ts index 3470fb98..b0e25c76 100644 --- a/Touchkebao/src/store/module/weChat/weChat.data.ts +++ b/Touchkebao/src/store/module/weChat/weChat.data.ts @@ -1,17 +1,19 @@ import { ChatRecord, ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; import { FriendsCircleItem } from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data"; -interface likeListItem { +export interface likeListItem { createTime: number; nickName: string; wechatId: string; } -interface CommentItem { - commentId2: string; +// 评论数据类型 +export interface CommentItem { + commentArg: number; + commentId1: number; + commentId2: number; commentTime: number; - createTime: number; + content: string; nickName: string; wechatId: string; - sendWord: string; } // 微信聊天相关的类型定义 export interface WeChatState { diff --git a/Touchkebao/src/store/module/weChat/weChat.ts b/Touchkebao/src/store/module/weChat/weChat.ts index e11dbe7b..8b583bd4 100644 --- a/Touchkebao/src/store/module/weChat/weChat.ts +++ b/Touchkebao/src/store/module/weChat/weChat.ts @@ -5,7 +5,7 @@ import { getChatroomMessages, getGroupMembers, } from "@/pages/pc/ckbox/api"; -import { WeChatState } from "./weChat.data"; +import { WeChatState, likeListItem, CommentItem } from "./weChat.data"; import { clearUnreadCount, updateConfig } from "@/pages/pc/ckbox/api"; import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; import { weChatGroupService, contractService } from "@/utils/db"; @@ -292,17 +292,20 @@ export const useWeChatStore = create()( updateMomentCommon: moments => { set({ MomentCommon: moments }); }, - updateLikeMoment: (snsId, likeList) => { + + updateLikeMoment: (snsId: string, likeList: likeListItem[]) => { set(state => ({ - MomentCommon: state.MomentCommon.map(item => { - if (item.snsId === snsId) { - return { - ...item, - likeList: likeList, - }; - } - return item; - }), + MomentCommon: state.MomentCommon.map(moment => + moment.snsId === snsId ? { ...moment, likeList } : moment, + ), + })); + }, + + updateComment: (snsId: string, commentList: CommentItem[]) => { + set(state => ({ + MomentCommon: state.MomentCommon.map(moment => + moment.snsId === snsId ? { ...moment, commentList } : moment, + ), })); }, }),