From 79e29b41edb306d39bef94d3339df9f6cae33061 Mon Sep 17 00:00:00 2001 From: "xie.bx" Date: Mon, 7 Nov 2022 22:07:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BC=9A=E8=AF=9D=E6=8A=96?= =?UTF-8?q?=E5=8A=A8=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-ui/src/store/chatStore.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/im-ui/src/store/chatStore.js b/im-ui/src/store/chatStore.js index d8218e2..38ff629 100644 --- a/im-ui/src/store/chatStore.js +++ b/im-ui/src/store/chatStore.js @@ -11,6 +11,7 @@ export default { }, openChat(state, chatInfo) { let chat = null; + let activeChat = state.activeIndex>=0?state.chats[state.activeIndex]:null; for (let i in state.chats) { if (state.chats[i].type == chatInfo.type && state.chats[i].targetId === chatInfo.targetId) { @@ -35,7 +36,15 @@ export default { }; state.chats.unshift(chat); } - + // 选中会话保持不变 + if(activeChat){ + state.chats.forEach((chat,idx)=>{ + if(activeChat.type == chat.type + && activeChat.targetId == chat.targetId){ + state.activeIndex = idx; + } + }) + } }, activeChat(state, idx) { state.activeIndex = idx; @@ -119,4 +128,4 @@ export default { } }, -} +}