From b31e1a47f0b47f51d93832566c21461a1ae949bf 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: Mon, 13 Oct 2025 17:28:51 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BF=AB=E6=8D=B7=E5=9B=9E?= =?UTF-8?q?=E5=A4=8D=E5=8A=9F=E8=83=BD=EF=BC=9A=E5=BC=95=E5=85=A5WebSocket?= =?UTF-8?q?=E6=94=AF=E6=8C=81=EF=BC=8C=E4=BC=98=E5=8C=96=E5=BF=AB=E6=8D=B7?= =?UTF-8?q?=E8=AF=AD=E5=8F=91=E9=80=81=E9=80=BB=E8=BE=91=EF=BC=8C=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8F=91=E9=80=81=E7=A1=AE=E8=AE=A4=E9=A2=84=E8=A7=88?= =?UTF-8?q?=EF=BC=8C=E6=8F=90=E5=8D=87=E7=94=A8=E6=88=B7=E4=BD=93=E9=AA=8C?= =?UTF-8?q?=E5=92=8C=E4=BB=A3=E7=A0=81=E5=8F=AF=E8=AF=BB=E6=80=A7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/QuickWords/index.tsx | 75 ++++++++++++++++++- 1 file changed, 72 insertions(+), 3 deletions(-) diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/components/QuickWords/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/components/QuickWords/index.tsx index fd10071f..b6088c9f 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/components/QuickWords/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/components/QuickWords/index.tsx @@ -38,6 +38,7 @@ import Layout from "@/components/Layout/LayoutFiexd"; import QuickReplyModal from "./components/QuickReplyModal"; import GroupModal from "./components/GroupModal"; import { useWeChatStore } from "@/store/module/weChat/weChat"; +import { useWebSocketStore } from "@/store/module/websocket/websocket"; // 消息类型枚举 export enum MessageType { @@ -80,6 +81,74 @@ const QuickWords: React.FC = ({ onInsert }) => { const updateQuoteMessageContent = useWeChatStore( state => state.updateQuoteMessageContent, ); + const currentContract = useWeChatStore(state => state.currentContract); + const { sendCommand } = useWebSocketStore.getState(); + + const sendQuickReplyNow = (reply: QuickWordsReply) => { + if (!currentContract) return; + const params = { + wechatAccountId: currentContract.wechatAccountId, + wechatChatroomId: currentContract?.chatroomId ? currentContract.id : 0, + wechatFriendId: currentContract?.chatroomId ? 0 : currentContract.id, + msgSubType: 0, + msgType: reply.msgType, + content: reply.content, + } as any; + sendCommand("CmdSendMessage", params); + }; + + const previewAndConfirmSend = (reply: QuickWordsReply) => { + let previewNode: React.ReactNode = null; + if (reply.msgType === MessageType.IMAGE) { + previewNode = ( +
+ 预览 +
+ ); + } else if (reply.msgType === MessageType.VIDEO) { + try { + const json = JSON.parse(reply.content || "{}"); + const cover = json.previewImage || json.thumbPath || ""; + previewNode = ( +
+ {cover ? ( + 视频预览 + ) : ( +
视频消息
+ )} +
+ ); + } catch { + previewNode =
视频消息
; + } + } else if (reply.msgType === MessageType.LINK) { + previewNode = ( +
+
{reply.title}
+
{reply.content}
+
+ ); + } + + Modal.confirm({ + title: "确认发送该快捷语?", + content: previewNode, + okText: "发送", + cancelText: "取消", + onOk: () => { + sendQuickReplyNow(reply); + message.success("已发送"); + }, + }); + }; // 获取快捷语数据 const fetchQuickWords = useCallback(async () => { @@ -172,10 +241,10 @@ const QuickWords: React.FC = ({ onInsert }) => { if ([MessageType.TEXT].includes(reply.msgType)) { updateQuoteMessageContent(reply.content || ""); } else if ([MessageType.LINK].includes(reply.msgType)) { - updateQuoteMessageContent(reply.content || ""); + previewAndConfirmSend(reply); } else { - // 非文本类型,插入标题作为占位,方便用户手动调整 - updateQuoteMessageContent(reply.title || ""); + // 图片/视频等类型:弹出预览确认后直接发送 + previewAndConfirmSend(reply); } } catch (_) {} }}