From 18f2ebf455f43f2e53ddff8e9e3f4df3116c5d40 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: Fri, 19 Sep 2025 15:40:47 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=B6=88=E6=81=AF=E8=BD=AC=E5=8F=91):=20?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=BD=AC=E5=8F=91=E9=80=BB=E8=BE=91=E5=B9=B6?= =?UTF-8?q?=E4=BC=98=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 在消息记录和转发模态框中添加了选中聊天记录的更新逻辑,确保转发功能的正确性。同时,简化了转发模态框的参数传递,移除了不必要的回调,提升了用户体验。 --- .../components/MessageEnter/index.tsx | 6 ++-- .../components/TransmitModal/index.tsx | 35 +++++++++++++------ .../components/MessageRecord/index.tsx | 32 ++++------------- Touchkebao/src/store/module/weChat/weChat.ts | 18 +++++++--- .../src/store/module/websocket/msgManage.ts | 2 +- 5 files changed, 51 insertions(+), 42 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx index 4b876726..e3073c7e 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageEnter/index.tsx @@ -32,7 +32,9 @@ const MessageEnter: React.FC = ({ contract }) => { const EnterModule = useWeChatStore(state => state.EnterModule); const updateShowCheckbox = useWeChatStore(state => state.updateShowCheckbox); const updateEnterModule = useWeChatStore(state => state.updateEnterModule); - + const updateTransmitModal = useWeChatStore( + state => state.updateTransmitModal, + ); const handleSend = async () => { if (!inputValue.trim()) return; console.log("发送消息", contract); @@ -140,7 +142,7 @@ const MessageEnter: React.FC = ({ contract }) => { updateEnterModule("common"); }; const handTurnRignt = () => { - console.log("转发"); + updateTransmitModal(true); }; return ( diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/TransmitModal/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/TransmitModal/index.tsx index d8aaf440..832ac783 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/TransmitModal/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/MessageRecord/components/TransmitModal/index.tsx @@ -20,12 +20,8 @@ import styles from "./TransmitModal.module.scss"; import { weChatGroupService, contractService } from "@/utils/db"; import { useWeChatStore } from "@/store/module/weChat/weChat"; import { ContractData, weChatGroup } from "@/pages/pc/ckbox/data"; - -export interface TransmitModalProps { - onConfirm?: (params: (ContractData | weChatGroup)[]) => void; // 可选,因为会自动更新到store -} - -const TransmitModal: React.FC = ({ onConfirm }) => { +import { useWebSocketStore } from "@/store/module/websocket/websocket"; +const TransmitModal: React.FC = () => { const [searchValue, setSearchValue] = useState(""); const [allContacts, setAllContacts] = useState< (ContractData | weChatGroup)[] @@ -36,12 +32,19 @@ const TransmitModal: React.FC = ({ onConfirm }) => { const [loading, setLoading] = useState(false); const [page, setPage] = useState(1); const pageSize = 20; - + const { sendCommand } = useWebSocketStore.getState(); // 从 Zustand store 获取更新方法 const openTransmitModal = useWeChatStore(state => state.openTransmitModal); const updateTransmitModal = useWeChatStore( state => state.updateTransmitModal, ); + const updateSelectedChatRecords = useWeChatStore( + state => state.updateSelectedChatRecords, + ); + + const selectedChatRecords = useWeChatStore( + state => state.selectedChatRecords, + ); // 加载联系人数据 const loadContacts = async () => { @@ -115,8 +118,20 @@ const TransmitModal: React.FC = ({ onConfirm }) => { // 确认转发 const handleConfirm = () => { - console.log("handleConfirm", selectedWechatFriend); - onConfirm?.(selectedWechatFriend); + for (const user of selectedWechatFriend) { + for (const record of selectedChatRecords) { + const params = { + wechatAccountId: user.wechatAccountId, + wechatChatroomId: user?.chatroomId ? user.id : 0, + wechatFriendId: user?.chatroomId ? 0 : user.id, + msgSubType: record.msgSubType, + msgType: record.msgType, + content: record.content, + }; + sendCommand("CmdSendMessage", params); + } + } + updateSelectedChatRecords([]); updateTransmitModal(false); }; @@ -130,7 +145,7 @@ const TransmitModal: React.FC = ({ onConfirm }) => { title="转发消息" open={openTransmitModal} onCancel={() => updateTransmitModal(false)} - width={800} + width={"60%"} className={styles.transmitModal} footer={[