diff --git a/src/utils/msb-im.js b/src/utils/msb-im.js index ab6b843..ca341fe 100644 --- a/src/utils/msb-im.js +++ b/src/utils/msb-im.js @@ -2,7 +2,7 @@ * @Author: ch * @Date: 2022-05-18 14:54:47 * @LastEditors: ch - * @LastEditTime: 2022-06-13 18:54:30 + * @LastEditTime: 2022-06-13 21:32:46 * @Description: file content */ import '@/utils/poto-req'; @@ -34,6 +34,7 @@ const fromatPotoReq = (traceId, traceType, content) => { message: res.getMessage(), }; }; + class MsbIm { defaultOption = { ioKey: 'traceId', @@ -281,13 +282,12 @@ class MsbIm { if (hisIndex >= 0) { historyData[hisIndex].lastMessage = item.lastMessage; historyData[hisIndex].unreadCount++; - newData.push(historyData); + newData.push(historyData[hisIndex]); } else { item.messageList = []; newData = [...newData, item]; } }); - this.setSessionData(newData); return Promise.resolve(result); } @@ -459,5 +459,11 @@ class MsbIm { } return Promise.resolve(result); } + close() { + this.socket.close(); + this.socket = null; + this.isOpen = false; + this.setSessionData([]); + } } export default MsbIm; diff --git a/src/views/chat/index.vue b/src/views/chat/index.vue index cc3d89b..c37a5af 100644 --- a/src/views/chat/index.vue +++ b/src/views/chat/index.vue @@ -300,6 +300,7 @@ reason: res.value, }) .then((res) => { + currentSessionId.value = null; Im.setCurSessionId(null); Im.getSessionList(); });