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">