refactor(weChat): 重构朋友圈相关类型定义和组件导入路径
将朋友圈相关的类型定义从分散的文件集中到index.data.ts中 更新组件中类型导入路径以保持一致性 添加评论更新逻辑到朋友圈组件
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
import { FriendsCircleItem } from "../index.data";
|
||||
export interface FriendCardProps {
|
||||
monent: FriendsCircleItem;
|
||||
isNotMy?: boolean;
|
||||
currentKf?: any;
|
||||
wechatFriendId?: number;
|
||||
formatTime: (time: number) => string;
|
||||
}
|
||||
|
||||
export interface MomentListProps {
|
||||
MomentCommon: FriendsCircleItem[];
|
||||
MomentCommonLoading: boolean;
|
||||
currentKf?: any;
|
||||
wechatFriendId?: number;
|
||||
formatTime: (time: number) => string;
|
||||
loadMomentData: (loadMore: boolean) => void;
|
||||
}
|
||||
export interface likeListItem {
|
||||
createTime: number;
|
||||
nickName: string;
|
||||
wechatId: string;
|
||||
}
|
||||
@@ -7,7 +7,13 @@ import {
|
||||
SendOutlined,
|
||||
DeleteOutlined,
|
||||
} from "@ant-design/icons";
|
||||
import { CommentItem, FriendsCircleItem } from "../index.data";
|
||||
import {
|
||||
CommentItem,
|
||||
likeListItem,
|
||||
FriendCardProps,
|
||||
MomentListProps,
|
||||
FriendsCircleItem,
|
||||
} from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data";
|
||||
import styles from "../index.module.scss";
|
||||
import {
|
||||
likeMoment,
|
||||
@@ -16,7 +22,7 @@ import {
|
||||
cancelCommentMoment,
|
||||
} from "./api";
|
||||
import { comfirm } from "@/utils/common";
|
||||
import { likeListItem, FriendCardProps, MomentListProps } from "./data";
|
||||
|
||||
import { useWeChatStore } from "@/store/module/weChat/weChat";
|
||||
// 单个朋友圈项目组件
|
||||
export const FriendCard: React.FC<FriendCardProps> = ({
|
||||
@@ -31,7 +37,7 @@ export const FriendCard: React.FC<FriendCardProps> = ({
|
||||
const time = formatTime(monent.createTime);
|
||||
const likesCount = monent?.likeList?.length || 0;
|
||||
const commentsCount = monent?.commentList?.length || 0;
|
||||
const { updateLikeMoment } = useWeChatStore();
|
||||
const { updateLikeMoment, updateComment } = useWeChatStore();
|
||||
|
||||
// 评论相关状态
|
||||
const [showCommentInput, setShowCommentInput] = useState(false);
|
||||
@@ -89,6 +95,19 @@ export const FriendCard: React.FC<FriendCardProps> = ({
|
||||
sendWord: commentText,
|
||||
seq: Date.now(),
|
||||
});
|
||||
// 更新评论
|
||||
updateComment(monent.snsId, [
|
||||
...monent.commentList,
|
||||
{
|
||||
commentArg: 0,
|
||||
commentId1: Date.now(),
|
||||
commentId2: Date.now(),
|
||||
commentTime: Date.now(),
|
||||
content: commentText,
|
||||
nickName: currentKf?.nickname || "",
|
||||
wechatId: currentKf?.wechatId || "",
|
||||
},
|
||||
]);
|
||||
// 清空输入框并隐藏
|
||||
setCommentText("");
|
||||
setShowCommentInput(false);
|
||||
@@ -106,6 +125,11 @@ export const FriendCard: React.FC<FriendCardProps> = ({
|
||||
commentId2: comment.commentId2,
|
||||
commentTime: comment.commentTime,
|
||||
});
|
||||
// 更新评论
|
||||
const commentList = monent.commentList.filter(v => {
|
||||
return v.commentId2 !== comment.commentId2;
|
||||
});
|
||||
updateComment(snsId, commentList);
|
||||
message.success("评论删除成功");
|
||||
});
|
||||
};
|
||||
|
||||
@@ -47,3 +47,25 @@ export interface ApiResponse {
|
||||
total: number;
|
||||
hasMore: boolean;
|
||||
}
|
||||
|
||||
export interface FriendCardProps {
|
||||
monent: FriendsCircleItem;
|
||||
isNotMy?: boolean;
|
||||
currentKf?: any;
|
||||
wechatFriendId?: number;
|
||||
formatTime: (time: number) => string;
|
||||
}
|
||||
|
||||
export interface MomentListProps {
|
||||
MomentCommon: FriendsCircleItem[];
|
||||
MomentCommonLoading: boolean;
|
||||
currentKf?: any;
|
||||
wechatFriendId?: number;
|
||||
formatTime: (time: number) => string;
|
||||
loadMomentData: (loadMore: boolean) => void;
|
||||
}
|
||||
export interface likeListItem {
|
||||
createTime: number;
|
||||
nickName: string;
|
||||
wechatId: string;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,9 @@
|
||||
import { ChatRecord, ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
|
||||
import { FriendsCircleItem } from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data";
|
||||
export interface likeListItem {
|
||||
createTime: number;
|
||||
nickName: string;
|
||||
wechatId: string;
|
||||
}
|
||||
// 评论数据类型
|
||||
export interface CommentItem {
|
||||
commentArg: number;
|
||||
commentId1: number;
|
||||
commentId2: number;
|
||||
commentTime: number;
|
||||
content: string;
|
||||
nickName: string;
|
||||
wechatId: string;
|
||||
}
|
||||
import {
|
||||
CommentItem,
|
||||
likeListItem,
|
||||
FriendsCircleItem,
|
||||
} from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data";
|
||||
// 微信聊天相关的类型定义
|
||||
export interface WeChatState {
|
||||
// 当前选中的联系人/群组
|
||||
|
||||
@@ -5,7 +5,11 @@ import {
|
||||
getChatroomMessages,
|
||||
getGroupMembers,
|
||||
} from "@/pages/pc/ckbox/api";
|
||||
import { WeChatState, likeListItem, CommentItem } from "./weChat.data";
|
||||
import { WeChatState } from "./weChat.data";
|
||||
import {
|
||||
likeListItem,
|
||||
CommentItem,
|
||||
} from "@/pages/pc/ckbox/weChat/components/SidebarMenu/FriendsCicle/index.data";
|
||||
import { clearUnreadCount, updateConfig } from "@/pages/pc/ckbox/api";
|
||||
import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data";
|
||||
import { weChatGroupService, contractService } from "@/utils/db";
|
||||
|
||||
Reference in New Issue
Block a user