From 7e5617bd80162c6ee73ecf4e55379022ff4b2dac 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, 3 Sep 2025 17:55:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor(ckbox):=20=E7=A7=BB=E9=99=A4SidebarMen?= =?UTF-8?q?u=E7=9A=84currentContract=E5=B1=9E=E6=80=A7=E5=B9=B6=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 移除不再使用的currentContract属性和相关props传递 - 将chatSessions状态管理移至MessageList组件内部 - 添加CmdFriendInfoChanged消息处理器 - 添加调试日志用于会话更新 --- .../components/SidebarMenu/MessageList/index.tsx | 12 ++++++------ .../pages/pc/ckbox/components/SidebarMenu/index.tsx | 10 ++-------- Cunkebao/src/pages/pc/ckbox/index.tsx | 2 +- Cunkebao/src/store/module/ckchat/ckchat.ts | 1 + Cunkebao/src/store/module/websocket/msgManage.ts | 5 +++++ 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Cunkebao/src/pages/pc/ckbox/components/SidebarMenu/MessageList/index.tsx b/Cunkebao/src/pages/pc/ckbox/components/SidebarMenu/MessageList/index.tsx index 3507fc6d..dc4901e1 100644 --- a/Cunkebao/src/pages/pc/ckbox/components/SidebarMenu/MessageList/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/components/SidebarMenu/MessageList/index.tsx @@ -3,22 +3,22 @@ import { List, Avatar, Badge } from "antd"; import { UserOutlined, TeamOutlined } from "@ant-design/icons"; import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; import { useWeChatStore } from "@/store/module/weChat/weChat"; +import { useCkChatStore } from "@/store/module/ckchat/ckchat"; + import styles from "./MessageList.module.scss"; import { formatWechatTime } from "@/utils/common"; -interface MessageListProps { - chatSessions: ContractData[] | weChatGroup[]; -} +interface MessageListProps {} -const MessageList: React.FC = ({ chatSessions }) => { +const MessageList: React.FC = () => { const { setCurrentContact, currentContract } = useWeChatStore(); - + const chatSessions = useCkChatStore(state => state.getChatSessions()); const onContactClick = (session: ContractData | weChatGroup) => { setCurrentContact(session); }; return (
( = ({ - loading = false, - currentContract, -}) => { - const chatSessions = useCkChatStore(state => state.getChatSessions()); +const SidebarMenu: React.FC = ({ loading = false }) => { const searchKeyword = useCkChatStore(state => state.searchKeyword); const setSearchKeyword = useCkChatStore(state => state.setSearchKeyword); const clearSearchKeyword = useCkChatStore(state => state.clearSearchKeyword); @@ -128,7 +122,7 @@ const SidebarMenu: React.FC = ({ const renderContent = () => { switch (activeTab) { case "chats": - return ; + return ; case "contracts": return ; case "groups": diff --git a/Cunkebao/src/pages/pc/ckbox/index.tsx b/Cunkebao/src/pages/pc/ckbox/index.tsx index 38c9cf84..0cbe80f4 100644 --- a/Cunkebao/src/pages/pc/ckbox/index.tsx +++ b/Cunkebao/src/pages/pc/ckbox/index.tsx @@ -64,7 +64,7 @@ const CkboxPage: React.FC = () => { {/* 左侧联系人边栏 */} - + {/* 主内容区 */} diff --git a/Cunkebao/src/store/module/ckchat/ckchat.ts b/Cunkebao/src/store/module/ckchat/ckchat.ts index 3bdf173a..b83cd436 100644 --- a/Cunkebao/src/store/module/ckchat/ckchat.ts +++ b/Cunkebao/src/store/module/ckchat/ckchat.ts @@ -389,6 +389,7 @@ export const useCkChatStore = createPersistStore( const newSession = state.chatSessions.map(item => item.id === session.id ? session : item, ); + console.log("新数组", newSession); set({ chatSessions: newSession }); }, // 删除聊天会话 diff --git a/Cunkebao/src/store/module/websocket/msgManage.ts b/Cunkebao/src/store/module/websocket/msgManage.ts index 423fab57..3146e213 100644 --- a/Cunkebao/src/store/module/websocket/msgManage.ts +++ b/Cunkebao/src/store/module/websocket/msgManage.ts @@ -46,6 +46,10 @@ const messageHandlers: Record = { // 在这里添加具体的处理逻辑 receivedMsg(message.friendMessage); }, + CmdFriendInfoChanged: message => { + // console.log("好友信息变更", message); + // 在这里添加具体的处理逻辑 + }, // 登录响应 CmdSignInResp: message => { @@ -67,6 +71,7 @@ const messageHandlers: Record = { // 在这里添加具体的处理逻辑 setVideoUrl(message.friendMessageId, message.url); }, + // 可以继续添加更多处理器... };