From 45c56482669f0a027f9e9012469ec937f6447ddb Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Sat, 27 Sep 2025 18:50:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=B6=88=E6=81=AF=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=B8=80=E7=9B=B4=E5=8F=91=E9=80=81=E4=B8=AD=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/store/chatStore.js | 17 ++++++----------- im-web/src/store/chatStore.js | 11 +++++------ 2 files changed, 11 insertions(+), 17 deletions(-) diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index 91dc0a1..089b337 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -519,20 +519,15 @@ export default defineStore('chatStore', { } } } - // 正在发送中的消息可能没有id,只有tmpId - if (msgInfo.tmpId) { + // 正在发送中的临时消息可能没有id,只有tmpId + if (msgInfo.selfSend && msgInfo.tmpId) { for (let idx = chat.messages.length - 1; idx >= 0; idx--) { let m = chat.messages[idx]; - // 这里只查询临时消息,跳过正常消息 - if (m.id) { - continue; - } - // 这里只查询临时消息,跳过有id的正常消息 - if (m.id) { - contine; + if (!m.selfSend || !m.tmpId) { + continue; } - if (m.tmpId && msgInfo.tmpId == m.tmpId) { - return m; + if (msgInfo.tmpId == m.tmpId) { + return idx; } // 如果id比要查询的消息小,说明没有这条消息 if (m.tmpId && m.tmpId < msgInfo.tmpId) { diff --git a/im-web/src/store/chatStore.js b/im-web/src/store/chatStore.js index f4b6bc7..7b040d3 100644 --- a/im-web/src/store/chatStore.js +++ b/im-web/src/store/chatStore.js @@ -547,16 +547,15 @@ export default defineStore('chatStore', { } } } - // 正在发送中的消息可能没有id,只有tmpId - if (msgInfo.tmpId) { + // 正在发送中的临时消息可能没有id,只有tmpId + if (msgInfo.selfSend && msgInfo.tmpId) { for (let idx = chat.messages.length - 1; idx >= 0; idx--) { let m = chat.messages[idx]; - // 这里只查询临时消息,跳过正常消息 - if (m.id) { + if (!m.selfSend || !m.tmpId) { continue; } - if (m.tmpId && msgInfo.tmpId == m.tmpId) { - return m; + if (msgInfo.tmpId == m.tmpId) { + return idx; } // 如果id比要查询的消息小,说明没有这条消息 if (m.tmpId && m.tmpId < msgInfo.tmpId) {