更新联系人上下文菜单和朋友圈组件:修复移动分组成功消息的重复调用,优化样式以增强用户体验,重构相关组件以使用currentCustomer替代currentKf,确保数据一致性和可读性。

This commit is contained in:
乘风
2025-12-18 10:44:38 +08:00
parent 72cf3fd81c
commit 7724d60a05
4 changed files with 46 additions and 49 deletions

View File

@@ -133,7 +133,7 @@ export const ContactContextMenu: React.FC<ContactContextMenuProps> = ({
if (onMoveGroup) {
await onMoveGroup(contact, values.targetGroupId);
message.success("移动分组成功");
message.success("移动分组成功");
} else {
message.warning("移动分组功能未实现");
}
@@ -176,23 +176,24 @@ export const ContactContextMenu: React.FC<ContactContextMenuProps> = ({
return (
<>
{visible && (
<>
<div
className={styles.contextMenuOverlay}
onClick={onClose}
onContextMenu={e => e.preventDefault()}
/>
<Menu
className={styles.contextMenu}
style={{
position: "fixed",
left: x,
top: y,
zIndex: 1000,
}}
items={menuItems}
onClick={onClose}
/>
<>
<div
className={styles.contextMenuOverlay}
onClick={onClose}
onContextMenu={e => e.preventDefault()}
/>
<Menu
className={styles.contextMenu}
style={{
position: "fixed",
left: x,
top: y,
zIndex: 1000,
boxShadow: "0 12px 32px rgba(15, 23, 42, 0.32)",
}}
items={menuItems}
onClick={onClose}
/>
</>
)}
@@ -215,11 +216,7 @@ export const ContactContextMenu: React.FC<ContactContextMenuProps> = ({
label="备注名称"
rules={[{ max: 20, message: "备注名称不能超过20个字符" }]}
>
<Input
placeholder="请输入备注名称"
maxLength={20}
showCount
/>
<Input placeholder="请输入备注名称" maxLength={20} showCount />
</Form.Item>
</Form>
</Modal>

View File

@@ -28,7 +28,7 @@ import { useWeChatStore } from "@/store/module/weChat/weChat";
export const FriendCard: React.FC<FriendCardProps> = ({
monent,
isNotMy = false,
currentKf,
currentCustomer,
wechatFriendId,
formatTime,
}) => {
@@ -44,15 +44,15 @@ export const FriendCard: React.FC<FriendCardProps> = ({
const [commentText, setCommentText] = useState("");
const handleLike = (moment: FriendsCircleItem) => {
console.log(currentKf);
console.log(currentCustomer);
//判断是否已经点赞了
const isLiked = moment?.likeList?.some(
(item: likeListItem) => item.wechatId === currentKf?.wechatId,
(item: likeListItem) => item.wechatId === currentCustomer?.wechatId,
);
if (isLiked) {
cancelLikeMoment({
wechatAccountId: currentKf?.id || 0,
wechatAccountId: currentCustomer?.id || 0,
wechatFriendId: wechatFriendId || 0,
snsId: moment.snsId,
seq: Date.now(),
@@ -60,11 +60,11 @@ export const FriendCard: React.FC<FriendCardProps> = ({
// 更新点赞
updateLikeMoment(
moment.snsId,
moment.likeList.filter(v => v.wechatId !== currentKf?.wechatId),
moment.likeList.filter(v => v.wechatId !== currentCustomer?.wechatId),
);
} else {
likeMoment({
wechatAccountId: currentKf?.id || 0,
wechatAccountId: currentCustomer?.id || 0,
wechatFriendId: wechatFriendId || 0,
snsId: moment.snsId,
seq: Date.now(),
@@ -74,8 +74,8 @@ export const FriendCard: React.FC<FriendCardProps> = ({
...moment.likeList,
{
createTime: Date.now(),
nickName: currentKf?.nickname || "",
wechatId: currentKf?.wechatId || "",
nickName: currentCustomer?.nickname || "",
wechatId: currentCustomer?.wechatId || "",
},
]);
}
@@ -89,7 +89,7 @@ export const FriendCard: React.FC<FriendCardProps> = ({
// TODO: 调用发送评论的API
commentMoment({
wechatAccountId: currentKf?.id || 0,
wechatAccountId: currentCustomer?.id || 0,
wechatFriendId: wechatFriendId || 0,
snsId: monent.snsId,
sendWord: commentText,
@@ -104,8 +104,8 @@ export const FriendCard: React.FC<FriendCardProps> = ({
commentId2: Date.now(),
commentTime: Date.now(),
content: commentText,
nickName: currentKf?.nickname || "",
wechatId: currentKf?.wechatId || "",
nickName: currentCustomer?.nickname || "",
wechatId: currentCustomer?.wechatId || "",
},
]);
// 清空输入框并隐藏
@@ -118,7 +118,7 @@ export const FriendCard: React.FC<FriendCardProps> = ({
// TODO: 调用删除评论的API
comfirm("确定删除评论吗?").then(() => {
cancelCommentMoment({
wechatAccountId: currentKf?.id || 0,
wechatAccountId: currentCustomer?.id || 0,
wechatFriendId: wechatFriendId || 0,
snsId: snsId,
seq: Date.now(),
@@ -129,7 +129,7 @@ export const FriendCard: React.FC<FriendCardProps> = ({
const commentList = monent.commentList.filter(v => {
return !(
v.commentId2 == comment.commentId2 &&
v.wechatId == currentKf?.wechatId
v.wechatId == currentCustomer?.wechatId
);
});
updateComment(snsId, commentList);
@@ -271,7 +271,7 @@ export const MomentList: React.FC<MomentListProps> = ({
MomentCommon,
MomentCommonLoading,
formatTime,
currentKf,
currentCustomer,
loadMomentData,
}) => {
return (
@@ -287,7 +287,7 @@ export const MomentList: React.FC<MomentListProps> = ({
monent={v}
isNotMy={false}
formatTime={formatTime}
currentKf={currentKf}
currentCustomer={currentCustomer}
/>
</div>
))}

View File

@@ -48,10 +48,12 @@ export interface ApiResponse {
hasMore: boolean;
}
import { Customer } from "@/store/module/weChat/customer.data";
export interface FriendCardProps {
monent: FriendsCircleItem;
isNotMy?: boolean;
currentKf?: any;
currentCustomer?: Customer | null;
wechatFriendId?: number;
formatTime: (time: number) => string;
}
@@ -59,7 +61,7 @@ export interface FriendCardProps {
export interface MomentListProps {
MomentCommon: FriendsCircleItem[];
MomentCommonLoading: boolean;
currentKf?: any;
currentCustomer?: Customer | null;
wechatFriendId?: number;
formatTime: (time: number) => string;
loadMomentData: (loadMore: boolean) => void;

View File

@@ -6,7 +6,7 @@ import { MomentList } from "./components/friendCard";
import dayjs from "dayjs";
import styles from "./index.module.scss";
import { fetchFriendsCircleData } from "./api";
import { useCkChatStore } from "@/store/module/ckchat/ckchat";
import { useCustomerStore } from "@/store/module/weChat/customer";
import { useWeChatStore } from "@/store/module/weChat/weChat";
interface FriendsCircleProps {
@@ -14,9 +14,7 @@ interface FriendsCircleProps {
}
const FriendsCircle: React.FC<FriendsCircleProps> = ({ wechatFriendId }) => {
const currentKf = useCkChatStore(state =>
state.kfUserList.find(kf => kf.id === state.kfSelected),
);
const currentCustomer = useCustomerStore(state => state.currentCustomer);
const { clearMomentCommon, updateMomentCommonLoading } = useWeChatStore();
const MomentCommon = useWeChatStore(state => state.MomentCommon);
const MomentCommonLoading = useWeChatStore(
@@ -37,7 +35,7 @@ const FriendsCircle: React.FC<FriendsCircleProps> = ({ wechatFriendId }) => {
// 加载数据;
const requestData = {
cmdType: "CmdFetchMoment",
wechatAccountId: currentKf?.id || 0,
wechatAccountId: currentCustomer?.id || 0,
wechatFriendId: wechatFriendId || 0,
createTimeSec: Math.floor(dayjs().subtract(2, "month").valueOf() / 1000),
prevSnsId: loadMore
@@ -82,7 +80,7 @@ const FriendsCircle: React.FC<FriendsCircleProps> = ({ wechatFriendId }) => {
<div className={styles.collapseHeader}>
<img
className={styles.avatar}
src={currentKf?.avatar || defaultAvatar}
src={currentCustomer?.avatar || defaultAvatar}
alt="客服头像"
onError={e => {
// 如果图片加载失败,使用默认头像
@@ -97,7 +95,7 @@ const FriendsCircle: React.FC<FriendsCircleProps> = ({ wechatFriendId }) => {
),
children: (
<MomentList
currentKf={currentKf}
currentCustomer={currentCustomer}
MomentCommon={MomentCommon}
MomentCommonLoading={MomentCommonLoading}
loadMomentData={loadMomentData}
@@ -115,7 +113,7 @@ const FriendsCircle: React.FC<FriendsCircleProps> = ({ wechatFriendId }) => {
),
children: (
<MomentList
currentKf={currentKf}
currentCustomer={currentCustomer}
MomentCommon={MomentCommon}
MomentCommonLoading={MomentCommonLoading}
loadMomentData={loadMomentData}
@@ -135,7 +133,7 @@ const FriendsCircle: React.FC<FriendsCircleProps> = ({ wechatFriendId }) => {
),
children: (
<MomentList
currentKf={currentKf}
currentCustomer={currentCustomer}
MomentCommon={MomentCommon}
MomentCommonLoading={MomentCommonLoading}
loadMomentData={loadMomentData}