From dbaee8baf1f59aa3fd923a416740876af5a7ee80 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Fri, 8 Aug 2025 14:44:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=9F=A5=E8=AF=A2=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/store/chatStore.js | 33 ++++++++++--------- .../src/components/chat/ChatMessageItem.vue | 2 +- im-web/src/store/chatStore.js | 31 ++++++++--------- im-web/src/view/Home.vue | 1 - 4 files changed, 34 insertions(+), 33 deletions(-) diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index b7ead33..8ffd431 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -165,7 +165,7 @@ export default defineStore('chatStore', { let chat = this.findChat(chatInfo); let message = this.findMessage(chat, msgInfo); if (message) { - console.log("message:",message) + console.log("message:", message) Object.assign(message, msgInfo); chat.stored = false; this.saveToStorage(); @@ -498,24 +498,25 @@ export default defineStore('chatStore', { return null; } for (let idx = chat.messages.length - 1; idx >= 0; idx--) { - if (!chat.messages[idx].id && !chat.messages[idx].tmpId) { - continue; - } // 通过id判断 - if (msgInfo.id && chat.messages[idx].id == msgInfo.id) { - return chat.messages[idx]; + if (msgInfo.id && chat.messages[idx].id) { + if (msgInfo.id == chat.messages[idx].id) { + return chat.messages[idx]; + } + // 如果id比要查询的消息小,说明没有这条消息 + if (msgInfo.id > chat.messages[idx].id) { + break; + } } // 正在发送中的消息可能没有id,只有tmpId - if (msgInfo.tmpId && chat.messages[idx].tmpId && - chat.messages[idx].tmpId == msgInfo.tmpId) { - return chat.messages[idx]; - } - // 如果id比要查询的消息小,说明没有这条消息 - if (msgInfo.id && msgInfo.id > chat.messages[idx].id) { - break; - } - if (msgInfo.tmpId && msgInfo.tmpId > chat.messages[idx].tmpId) { - break; + if (msgInfo.tmpId && chat.messages[idx].tmpId) { + if (msgInfo.tmpId == chat.messages[idx].tmpId) { + return chat.messages[idx]; + } + // 如果id比要查询的消息小,说明没有这条消息 + if (msgInfo.tmpId > chat.messages[idx].tmpId) { + break; + } } } return null; diff --git a/im-web/src/components/chat/ChatMessageItem.vue b/im-web/src/components/chat/ChatMessageItem.vue index 19be0aa..51b4d74 100644 --- a/im-web/src/components/chat/ChatMessageItem.vue +++ b/im-web/src/components/chat/ChatMessageItem.vue @@ -320,7 +320,7 @@ export default { .message-image { border-radius: 8px; - border: 3px solid var(--im-color-primary-light-8); + border: 2px solid var(--im-color-primary-light-9); overflow: hidden; cursor: pointer; } diff --git a/im-web/src/store/chatStore.js b/im-web/src/store/chatStore.js index d5952dc..96e1dbf 100644 --- a/im-web/src/store/chatStore.js +++ b/im-web/src/store/chatStore.js @@ -523,24 +523,25 @@ export default defineStore('chatStore', { return null; } for (let idx = chat.messages.length - 1; idx >= 0; idx--) { - if (!chat.messages[idx].id && !chat.messages[idx].tmpId) { - continue; - } // 通过id判断 - if (msgInfo.id && chat.messages[idx].id == msgInfo.id) { - return chat.messages[idx]; + if (msgInfo.id && chat.messages[idx].id) { + if (msgInfo.id == chat.messages[idx].id) { + return chat.messages[idx]; + } + // 如果id比要查询的消息小,说明没有这条消息 + if (msgInfo.id > chat.messages[idx].id) { + break; + } } // 正在发送中的消息可能没有id,只有tmpId - if (msgInfo.tmpId && chat.messages[idx].tmpId && - chat.messages[idx].tmpId == msgInfo.tmpId) { - return chat.messages[idx]; - } - // 如果id比要查询的消息小,说明没有这条消息 - if (msgInfo.id && msgInfo.id > chat.messages[idx].id) { - break; - } - if (msgInfo.tmpId && msgInfo.tmpId > chat.messages[idx].tmpId) { - break; + if (msgInfo.tmpId && chat.messages[idx].tmpId) { + if (msgInfo.tmpId == chat.messages[idx].tmpId) { + return chat.messages[idx]; + } + // 如果id比要查询的消息小,说明没有这条消息 + if (msgInfo.tmpId > chat.messages[idx].tmpId) { + break; + } } } } diff --git a/im-web/src/view/Home.vue b/im-web/src/view/Home.vue index 2ae0839..233bbf3 100644 --- a/im-web/src/view/Home.vue +++ b/im-web/src/view/Home.vue @@ -125,7 +125,6 @@ export default { location.href = "/"; } }); - } else if (cmd == 3) { if (!this.configStore.appInit || this.chatStore.loading) { // 如果正在拉取离线消息,先放进缓存区,等待消息拉取完成再处理,防止消息乱序