From 4d562fc3f13bf1f73dbd1ce4a06ac780aef42e73 Mon Sep 17 00:00:00 2001 From: huxuejian Date: Thu, 15 Oct 2026 16:32:43 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=97=AE=E9=A2=98=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/message/components/chat-input.vue | 9 ++++++--- pages/message/index.vue | 25 ++++++++++++++++++++++++- pages/work/profile.vue | 2 +- utils/chat-utils.js | 4 +++- 4 files changed, 34 insertions(+), 6 deletions(-) diff --git a/pages/message/components/chat-input.vue b/pages/message/components/chat-input.vue index 86454ba..0c7db56 100644 --- a/pages/message/components/chat-input.vue +++ b/pages/message/components/chat-input.vue @@ -295,18 +295,21 @@ const sendVoiceMessage = async (voiceFile, duration) => { // 发送消息的通用方法(文本、图片、语音) const sendMessage = async (messageType, data) => { - await sendMessageUtil( + const result = await sendMessageUtil( messageType, data, props.timChatManager, () => validateBeforeSend(false, false, props.timChatManager), () => { showMorePanel.value = false; - // 发送成功后滚动到底部 - emit("messageSent"); }, cloudCustomData.value ); + + if (result?.success) { + // 让页面直接将本地消息加入列表,避免依赖全局 IM 回调的注册时机。 + emit("messageSent", result.message); + } }; // 发送自定义消息的通用方法 diff --git a/pages/message/index.vue b/pages/message/index.vue index 2d839be..0afb829 100644 --- a/pages/message/index.vue +++ b/pages/message/index.vue @@ -101,7 +101,7 @@ " :userId="openid" :teamId="teamId" :patientId="patientId" :corpId="corpId" :patientInfo="patientInfo" :orderStatus="orderStatus" :isGenerating="isGenerating" :canBenefitEntry="isBenefitEntryEnabled" - @scrollToBottom="() => scrollToBottom(true)" @messageSent="() => scrollToBottom(true)" + @scrollToBottom="() => scrollToBottom(true)" @messageSent="handleMessageSent" @endConsult="handleEndConsult" @openConsult="handleOpenConsult">