From 10a646f72935dfe3692116a5a2caa31336a847ce Mon Sep 17 00:00:00 2001 From: tb107 <1070046590@qq.com> Date: Fri, 12 Apr 2024 13:04:34 +0800 Subject: [PATCH] =?UTF-8?q?Fix=20bug:=20=E9=98=B2=E6=AD=A2=20=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E3=80=81=E6=96=87=E4=BB=B6=20=E5=9C=A8=E5=8F=91?= =?UTF-8?q?=E9=80=81=E6=96=B9=20=E6=98=BE=E7=A4=BA=20=E5=9C=A8=E9=A1=B6?= =?UTF-8?q?=E7=AB=AF=20=20=E5=9B=A0=E4=B8=BA=E8=BF=98=E6=B2=A1=E5=AD=98?= =?UTF-8?q?=E5=BA=93=EF=BC=8Cid=3D0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/store/chatStore.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/im-ui/src/store/chatStore.js b/im-ui/src/store/chatStore.js index 505cc70..0e626fa 100644 --- a/im-ui/src/store/chatStore.js +++ b/im-ui/src/store/chatStore.js @@ -176,13 +176,19 @@ export default { } // 根据id顺序插入,防止消息乱序 let insertPos = chat.messages.length; - for (let idx in chat.messages) { - if (chat.messages[idx].id && msgInfo.id < chat.messages[idx].id) { - insertPos = idx; - console.log(`消息出现乱序,位置:${chat.messages.length},修正至:${insertPos}`); - break; - } + + if(msgInfo.id>0){ + //防止 图片、文件 在发送方 显示 在顶端 因为还没存库,id=0 + for (let idx in chat.messages) { + if (chat.messages[idx].id && msgInfo.id < chat.messages[idx].id) { + insertPos = idx; + console.log(`消息出现乱序,位置:${chat.messages.length},修正至:${insertPos}`); + break; + } + } } + + chat.messages.splice(insertPos, 0, msgInfo); this.commit("saveToStorage"); },