From 15a17b5e1d4777a676e7f13f1ce6bb8579922ca1 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, 17 Sep 2025 17:02:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(weChat):=20=E4=BC=98=E5=8C=96=E6=9C=8B?= =?UTF-8?q?=E5=8F=8B=E5=9C=88=E6=95=B0=E6=8D=AE=E7=B1=BB=E5=9E=8B=E5=92=8C?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 导出 likeListItem 和 CommentItem 接口供其他模块使用 - 重构 CommentItem 接口字段,增加注释说明 - 简化 updateLikeMoment 方法实现 - 新增 updateComment 方法用于更新评论列表 --- .../src/store/module/weChat/weChat.data.ts | 12 +++++---- Touchkebao/src/store/module/weChat/weChat.ts | 25 +++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) 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, + ), })); }, }),