feat(朋友圈): 实现朋友圈点赞功能并优化组件结构
重构朋友圈组件结构,将核心逻辑拆分为独立组件。主要变更包括: 1. 新增点赞功能及相关API接口 2. 修改snsId类型从number到string以兼容接口 3. 在store中新增updateLikeMoment方法处理点赞状态 4. 提取FriendCard和MomentList为独立组件 5. 优化代码结构提升可维护性
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
import { ChatRecord, ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
|
||||
import { FriendsCircleItem } from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data";
|
||||
interface likeListItem {
|
||||
createTime: number;
|
||||
nickName: string;
|
||||
wechatId: string;
|
||||
}
|
||||
// 微信聊天相关的类型定义
|
||||
export interface WeChatState {
|
||||
// 当前选中的联系人/群组
|
||||
@@ -26,6 +31,7 @@ export interface WeChatState {
|
||||
MomentCommonLoading: boolean;
|
||||
// MomentCommon 相关方法
|
||||
updateMomentCommonLoading: (loading: boolean) => void;
|
||||
updateLikeMoment: (snsId: string, likeList: likeListItem[]) => void;
|
||||
|
||||
loadChatMessages: (Init: boolean, To?: number) => Promise<void>;
|
||||
SearchMessage: (params: {
|
||||
|
||||
@@ -292,6 +292,19 @@ export const useWeChatStore = create<WeChatState>()(
|
||||
updateMomentCommon: moments => {
|
||||
set({ MomentCommon: moments });
|
||||
},
|
||||
updateLikeMoment: (snsId, likeList) => {
|
||||
set(state => ({
|
||||
MomentCommon: state.MomentCommon.map(item => {
|
||||
if (item.snsId === snsId) {
|
||||
return {
|
||||
...item,
|
||||
likeList: likeList,
|
||||
};
|
||||
}
|
||||
return item;
|
||||
}),
|
||||
}));
|
||||
},
|
||||
}),
|
||||
{
|
||||
name: "wechat-storage",
|
||||
|
||||
Reference in New Issue
Block a user