Browse Source

!4 修复会话抖动的bug

Merge pull request !4 from blue/v_1.1.0
master
blue 3 years ago
committed by Gitee
parent
commit
c95efd72c1
No known key found for this signature in database GPG Key ID: 173E9B9CA92EEF8F
  1. 2
      im-ui/src/components/chat/ChatGroup.vue
  2. 13
      im-ui/src/store/chatStore.js

2
im-ui/src/components/chat/ChatGroup.vue

@ -19,7 +19,7 @@
</el-main> </el-main>
<el-footer height="25%" class="im-chat-footer"> <el-footer height="25%" class="im-chat-footer">
<div class="chat-tool-bar"> <div class="chat-tool-bar">
<div title="表情" class="el-icon-service" ref="emotion" @click="switchEmotionBox()"> <div title="表情" class="el-icon-eleme" ref="emotion" @click="switchEmotionBox()">
<emotion v-show="showEmotion" :pos="emoBoxPos" @emotion="handleEmotion"></Emotion> <emotion v-show="showEmotion" :pos="emoBoxPos" @emotion="handleEmotion"></Emotion>
</div> </div>
<div title="发送图片"> <div title="发送图片">

13
im-ui/src/store/chatStore.js

@ -11,6 +11,7 @@ export default {
}, },
openChat(state, chatInfo) { openChat(state, chatInfo) {
let chat = null; let chat = null;
let activeChat = state.activeIndex>=0?state.chats[state.activeIndex]:null;
for (let i in state.chats) { for (let i in state.chats) {
if (state.chats[i].type == chatInfo.type && if (state.chats[i].type == chatInfo.type &&
state.chats[i].targetId === chatInfo.targetId) { state.chats[i].targetId === chatInfo.targetId) {
@ -35,7 +36,15 @@ export default {
}; };
state.chats.unshift(chat); 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) { activeChat(state, idx) {
state.activeIndex = idx; state.activeIndex = idx;
@ -119,4 +128,4 @@ export default {
} }
}, },
} }

Loading…
Cancel
Save