From 1be091522edb01c55892ccb917821b43c8ffc191 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B9=98=E9=A3=8E?= Date: Sat, 6 Dec 2025 17:10:57 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EasyncMessageStatus=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BB=A5=E8=8E=B7=E5=8F=96=E6=B6=88=E6=81=AF=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=8C=E5=B9=B6=E5=9C=A8=E6=B6=88=E6=81=AF=E5=A4=84?= =?UTF-8?q?=E7=90=86=E9=80=BB=E8=BE=91=E4=B8=AD=E9=9B=86=E6=88=90=E8=AF=A5?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E4=BB=A5=E4=BC=98=E5=8C=96=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E3=80=82=E8=B0=83=E6=95=B4ProfileCard?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E7=9A=84=E7=8A=B6=E6=80=81=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E4=BB=A5=E6=94=AF=E6=8C=81=E5=BF=AB=E9=80=9F=E5=9B=9E=E5=A4=8D?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Touchkebao/src/api/ai.ts | 9 +++++ .../components/ProfileCard/index.tsx | 6 ++-- .../src/store/module/websocket/msgManage.ts | 34 +++++++++++-------- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/Touchkebao/src/api/ai.ts b/Touchkebao/src/api/ai.ts index 196a6cf4..b73cfa45 100644 --- a/Touchkebao/src/api/ai.ts +++ b/Touchkebao/src/api/ai.ts @@ -2,6 +2,15 @@ import axios from "axios"; import { useUserStore } from "@/store/module/user"; import { request } from "@/api/request"; +export function asyncMessageStatus(params: { + messageId: number; + wechatFriendId?: number; + wechatChatroomId?: number; + wechatAccountId: number; +}) { + return request("/v1/kefu/message/getMessageStatus", params, "GET"); +} + //ai对话接口 export interface AiChatParams { friendId: number; diff --git a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx index df066762..871c95f6 100644 --- a/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx +++ b/Touchkebao/src/pages/pc/ckbox/weChat/components/ChatWindow/components/ProfileCard/index.tsx @@ -16,7 +16,7 @@ interface PersonProps { } const Person: React.FC = ({ contract }) => { - const [activeKey, setActiveKey] = useState("profile"); + const [activeKey, setActiveKey] = useState("quickwords"); const isGroup = "chatroomId" in contract; // 使用state保存当前contract的副本,确保在切换tab时不会丢失修改 const [currentContract, setCurrentContract] = useState< @@ -52,8 +52,8 @@ const Person: React.FC = ({ contract }) => { }, [currentContract, isGroup]); useEffect(() => { - setActiveKey("profile"); - setRenderedKeys(["profile"]); + setActiveKey("quickwords"); + setRenderedKeys(["quickwords"]); }, [contract]); const tabHeaderItems = useMemo( diff --git a/Touchkebao/src/store/module/websocket/msgManage.ts b/Touchkebao/src/store/module/websocket/msgManage.ts index a7b11732..476efbf2 100644 --- a/Touchkebao/src/store/module/websocket/msgManage.ts +++ b/Touchkebao/src/store/module/websocket/msgManage.ts @@ -6,7 +6,7 @@ import { Messages } from "./msg.data"; import { db } from "@/utils/db"; import { Modal } from "antd"; import { useCustomerStore, updateCustomerList } from "../weChat/customer"; -import { dataProcessing } from "@/api/ai"; +import { dataProcessing, asyncMessageStatus } from "@/api/ai"; // 消息处理器类型定义 type MessageHandler = (message: WebSocketMessage) => void; @@ -54,30 +54,36 @@ const messageHandlers: Record = { // 发送消息响应 CmdSendMessageResp: (message: Messages) => { const { findMessageBySeq, updateMessage } = getWeChatStoreMethods(); - const msg = findMessageBySeq(message.seq); - if (msg) { - updateMessage(message.seq, { - sendStatus: 1, - id: message.friendMessage?.id || message.chatroomMessage?.id, - }); - } + //异步传新消息给数据库 goAsyncServiceData(message); + asyncMessageStatus({ + messageId: message.friendMessage?.id || message.chatroomMessage?.id, + wechatFriendId: message.friendMessage?.wechatFriendId, + wechatChatroomId: message.chatroomMessage?.wechatChatroomId, + wechatAccountId: + message.friendMessage?.wechatAccountId || + message.chatroomMessage?.wechatAccountId, + }).then(res => { + if (msg) { + console.log("CmdSendMessageResp 发送消息响应", res); + updateMessage(message.seq, { + sendStatus: 0, + id: message.friendMessage?.id || message.chatroomMessage?.id, + }); + } + }); }, CmdSendMessageResult: message => { - const { updateMessage } = getWeChatStoreMethods(); - updateMessage(message.friendMessageId || message.chatroomMessageId, { - sendStatus: 0, - }); - // 最终消息同步处理 + console.log("CmdSendMessageResult 发送消息结果", message); dataProcessing({ chatroomMessageId: message.chatroomMessageId, friendMessageId: message.friendMessageId, sendStatus: message.sendStatus, type: "CmdSendMessageResult", wechatAccountId: 1, - wechatTime: message.wechatTime, + wechatTime: message?.wechatTime, }); }, // 接收消息响应