From 3634be2f5508a22998854736fa7c1114145abf3e Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Tue, 21 Jan 2025 01:12:49 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=A8=E6=88=B7=E5=B0=81=E7=A6=81=E5=92=8C?= =?UTF-8?q?=E7=BE=A4=E5=B0=81=E7=A6=81=E5=A2=9E=E5=8A=A0=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E8=AF=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/bx/implatform/vo/GroupVO.java | 6 ++ .../java/com/bx/implatform/vo/UserVO.java | 5 ++ im-uniapp/App.vue | 10 ++- .../chat-group-readed/chat-group-readed.vue | 12 ++- im-uniapp/pages/chat/chat-box.vue | 71 ++++++++++++++---- im-uniapp/store/chatStore.js | 35 +++------ im-web/src/components/chat/ChatBox.vue | 75 ++++++++++++++++--- im-web/src/components/chat/ChatInput.vue | 2 +- im-web/src/store/chatStore.js | 35 ++++----- im-web/src/view/Home.vue | 5 +- 10 files changed, 175 insertions(+), 81 deletions(-) diff --git a/im-platform/src/main/java/com/bx/implatform/vo/GroupVO.java b/im-platform/src/main/java/com/bx/implatform/vo/GroupVO.java index 61abfa3..75abfa8 100644 --- a/im-platform/src/main/java/com/bx/implatform/vo/GroupVO.java +++ b/im-platform/src/main/java/com/bx/implatform/vo/GroupVO.java @@ -50,5 +50,11 @@ public class GroupVO { @Schema(description = "是否已退出") private Boolean quit; + @Schema(description = "账号是否被封禁") + private Boolean isBanned; + + @Schema(description = "被封禁原因") + private String reason; + } diff --git a/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java b/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java index f54b17d..64ccae5 100644 --- a/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java +++ b/im-platform/src/main/java/com/bx/implatform/vo/UserVO.java @@ -43,4 +43,9 @@ public class UserVO { @Schema(description = "是否在线") private Boolean online; + @Schema(description = "账号是否被封禁") + private Boolean isBanned; + + @Schema(description = "被封禁原因") + private String reason; } diff --git a/im-uniapp/App.vue b/im-uniapp/App.vue index 9b290f3..475ab99 100644 --- a/im-uniapp/App.vue +++ b/im-uniapp/App.vue @@ -169,7 +169,7 @@ export default { // 打开会话 this.chatStore.openChat(chatInfo); // 插入消息 - this.chatStore.insertMessage(msg); + this.chatStore.insertMessage(msg, chatInfo); // 播放提示音 this.playAudioTip(); @@ -192,6 +192,10 @@ export default { } // 消息回执处理 if (msg.type == enums.MESSAGE_TYPE.RECEIPT) { + let chatInfo = { + type: 'GROUP', + targetId: msg.groupId + } // 更新消息已读人数 let msgInfo = { id: msg.id, @@ -199,7 +203,7 @@ export default { readedCount: msg.readedCount, receiptOk: msg.receiptOk }; - this.chatStore.updateMessage(msgInfo) + this.chatStore.updateMessage(msgInfo,chatInfo) return; } // 标记这条消息是不是自己发的 @@ -259,7 +263,7 @@ export default { // 打开会话 this.chatStore.openChat(chatInfo); // 插入消息 - this.chatStore.insertMessage(msg); + this.chatStore.insertMessage(msg, chatInfo); // 播放提示音 this.playAudioTip(); }, diff --git a/im-uniapp/components/chat-group-readed/chat-group-readed.vue b/im-uniapp/components/chat-group-readed/chat-group-readed.vue index c47a309..4ae285e 100644 --- a/im-uniapp/components/chat-group-readed/chat-group-readed.vue +++ b/im-uniapp/components/chat-group-readed/chat-group-readed.vue @@ -79,12 +79,18 @@ export default { }) this.items[0] = `已读(${this.readedMembers.length})`; this.items[1] = `未读(${this.unreadMembers.length})`; - // 更新已读人数 - this.chatStore.updateMessage({ + + let chatInfo = { + type: 'GROUP', + targetId: this.msgInfo.groupId + } + let msgInfo = { id: this.msgInfo.id, groupId: this.msgInfo.groupId, readedCount: this.readedMembers.length - }) + } + // 更新已读人数 + this.chatStore.updateMessage(msgInfo, chatInfo) }) }, onClickItem(e) { diff --git a/im-uniapp/pages/chat/chat-box.vue b/im-uniapp/pages/chat/chat-box.vue index e425e81..309f5d8 100644 --- a/im-uniapp/pages/chat/chat-box.vue +++ b/im-uniapp/pages/chat/chat-box.vue @@ -155,6 +155,11 @@ export default { this.switchChatTabBox('none'); }, onSendRecord(data) { + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } let msgInfo = { content: JSON.stringify(data), type: this.$enums.MESSAGE_TYPE.AUDIO, @@ -164,7 +169,7 @@ export default { this.fillTargetId(msgInfo, this.chat.targetId); this.sendMessageRequest(msgInfo).then((m) => { m.selfSend = true; - this.chatStore.insertMessage(m); + this.chatStore.insertMessage(m, this.chat); // 会话置顶 this.moveChatToTop(); // 滚动到底部 @@ -260,6 +265,17 @@ export default { sendTextMessage() { this.editorCtx.getContents({ success: (e) => { + + // 清空编辑框数据 + this.editorCtx.clear(); + this.atUserIds = []; + this.isReceipt = false; + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } + let sendText = this.isReceipt ? "【回执消息】" : ""; e.delta.ops.forEach((op) => { if (op.insert.image) { @@ -286,6 +302,7 @@ export default { } // 填充对方id this.fillTargetId(msgInfo, this.chat.targetId); + this.sendMessageRequest(msgInfo).then((m) => { m.selfSend = true; this.chatStore.insertMessage(m, this.chat); @@ -294,10 +311,6 @@ export default { }).finally(() => { // 滚动到底部 this.scrollToBottom(); - // 清空编辑框数据 - this.atUserIds = []; - this.isReceipt = false; - this.editorCtx.clear(); }); } }) @@ -379,6 +392,11 @@ export default { }) }, onUploadImageBefore(file) { + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } let data = { originUrl: file.path, thumbUrl: file.path @@ -399,7 +417,7 @@ export default { // 填充对方id this.fillTargetId(msgInfo, this.chat.targetId); // 插入消息 - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); // 会话置顶 this.moveChatToTop(); // 借助file对象保存 @@ -416,15 +434,20 @@ export default { msgInfo.loadStatus = 'ok'; msgInfo.id = m.id; this.isReceipt = false; - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); }) }, onUploadImageFail(file, err) { let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); msgInfo.loadStatus = 'fail'; - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); }, onUploadFileBefore(file) { + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } let data = { name: file.name, size: file.size, @@ -445,7 +468,7 @@ export default { // 填充对方id this.fillTargetId(msgInfo, this.chat.targetId); // 插入消息 - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); // 会话置顶 this.moveChatToTop(); // 借助file对象保存 @@ -467,13 +490,13 @@ export default { msgInfo.loadStatus = 'ok'; msgInfo.id = m.id; this.isReceipt = false; - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); }) }, onUploadFileFail(file, res) { let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); msgInfo.loadStatus = 'fail'; - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); }, onDeleteMessage(msgInfo) { uni.showModal({ @@ -481,7 +504,7 @@ export default { content: '确认删除消息?', success: (res) => { if (!res.cancel) { - this.chatStore.deleteMessage(msgInfo); + this.chatStore.deleteMessage(msgInfo, this.chat); uni.showToast({ title: "删除成功", icon: "none" @@ -505,7 +528,7 @@ export default { msgInfo.type = this.$enums.MESSAGE_TYPE.RECALL; msgInfo.content = '你撤回了一条消息'; msgInfo.status = this.$enums.MESSAGE_STATUS.RECALL; - this.chatStore.insertMessage(msgInfo); + this.chatStore.insertMessage(msgInfo, this.chat); }) } } @@ -697,6 +720,22 @@ export default { }); // #endif }, + showBannedTip() { + let msgInfo = { + tmpId: this.generateId(), + sendId: this.mine.id, + sendTime: new Date().getTime(), + type: this.$enums.MESSAGE_TYPE.TIP_TEXT + } + if (this.chat.type == "PRIVATE") { + msgInfo.recvId = this.mine.id + msgInfo.content = "该用户已被管理员封禁,原因:" + this.friend.reason + } else { + msgInfo.groupId = this.group.id; + msgInfo.content = "本群聊已被管理员封禁,原因:" + this.group.reason + } + this.chatStore.insertMessage(msgInfo, this.chat); + }, reCalChatMainHeight() { const sysInfo = uni.getSystemInfoSync(); let h = sysInfo.windowHeight; @@ -753,6 +792,10 @@ export default { } return this.chat.unreadCount; }, + isBanned() { + return (this.chat.type == "PRIVATE" && this.friend.isBanned) || + (this.chat.type == "GROUP" && this.group.isBanned) + }, atUserItems() { let atUsers = []; this.atUserIds.forEach((id) => { @@ -815,7 +858,7 @@ export default { // 监听键盘高度 this.listenKeyBoard(); // 计算聊天窗口高度 - this.$nextTick(()=>this.reCalChatMainHeight()) + this.$nextTick(() => this.reCalChatMainHeight()) }, onShow() { if (this.needScrollToBottom) { diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index da631dc..505c7c1 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -141,9 +141,9 @@ export default defineStore('chatStore', { this.saveToStorage(); } }, - insertMessage(msgInfo) { + insertMessage(msgInfo, chatInfo) { // 获取对方id或群id - let type = msgInfo.groupId ? 'GROUP' : 'PRIVATE'; + let type = chatInfo.type; // 记录消息的最大id if (msgInfo.id && type == "PRIVATE" && msgInfo.id > this.privateMsgMaxId) { this.privateMsgMaxId = msgInfo.id; @@ -152,7 +152,7 @@ export default defineStore('chatStore', { this.groupMsgMaxId = msgInfo.id; } // 如果是已存在消息,则覆盖旧的消息数据 - let chat = this.findChat(msgInfo); + let chat = this.findChat(chatInfo); let message = this.findMessage(chat, msgInfo); if (message) { Object.assign(message, msgInfo); @@ -228,9 +228,9 @@ export default defineStore('chatStore', { chat.stored = false; this.saveToStorage(); }, - updateMessage(msgInfo) { + updateMessage(msgInfo, chatInfo) { // 获取对方id或群id - let chat = this.findChat(msgInfo); + let chat = this.findChat(chatInfo); let message = this.findMessage(chat, msgInfo); if (message) { // 属性拷贝 @@ -239,9 +239,9 @@ export default defineStore('chatStore', { this.saveToStorage(); } }, - deleteMessage(msgInfo) { + deleteMessage(msgInfo, chatInfo) { // 获取对方id或群id - let chat = this.findChat(msgInfo); + let chat = this.findChat(chatInfo); for (let idx in chat.messages) { // 已经发送成功的,根据id删除 if (chat.messages[idx].id && chat.messages[idx].id == msgInfo.id) { @@ -261,7 +261,7 @@ export default defineStore('chatStore', { updateChatFromFriend(friend) { let chat = this.findChatByFriend(friend.id) if (chat && (chat.headImage != friend.headImageThumb || - chat.showName != friend.nickName)) { + chat.showName != friend.nickName)) { // 更新会话中的群名和头像 chat.headImage = friend.headImageThumb; chat.showName = friend.nickName; @@ -272,7 +272,7 @@ export default defineStore('chatStore', { updateChatFromGroup(group) { let chat = this.findChatByGroup(group.id); if (chat && (chat.headImage != group.headImageThumb || - chat.showName != group.showGroupName)) { + chat.showName != group.showGroupName)) { // 更新会话中的群名称和头像 chat.headImage = group.headImageThumb; chat.showName = group.showGroupName; @@ -390,21 +390,10 @@ export default defineStore('chatStore', { } } }, - findChat: (state) => (msgInfo) => { + findChat: (state) => (chat) => { let chats = state.curChats; - // 获取对方id或群id - let type = msgInfo.groupId ? 'GROUP' : 'PRIVATE'; - let targetId = msgInfo.groupId ? msgInfo.groupId : msgInfo.selfSend ? msgInfo.recvId : msgInfo - .sendId; - let chat = null; - for (let idx in chats) { - if (chats[idx].type == type && - chats[idx].targetId === targetId) { - chat = chats[idx]; - break; - } - } - return chat; + let idx = state.findChatIdx(chat); + return chats[idx]; }, findChatByFriend: (state) => (fid) => { return state.curChats.find(chat => chat.type == 'PRIVATE' && diff --git a/im-web/src/components/chat/ChatBox.vue b/im-web/src/components/chat/ChatBox.vue index 1f8c019..62ddcc8 100644 --- a/im-web/src/components/chat/ChatBox.vue +++ b/im-web/src/components/chat/ChatBox.vue @@ -161,15 +161,20 @@ export default { msgInfo.loadStatus = 'ok'; msgInfo.id = m.id; this.isReceipt = false; - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); }) }, onImageFail(e, file) { let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); msgInfo.loadStatus = 'fail'; - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); }, onImageBefore(file) { + // 被封禁提示 + if (this.isBanned) { + this.showBannedTip(); + return; + } let url = URL.createObjectURL(file); let data = { originUrl: url, @@ -191,7 +196,7 @@ export default { // 填充对方id this.fillTargetId(msgInfo, this.chat.targetId); // 插入消息 - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); // 会话置顶 this.moveChatToTop(); // 滚动到底部 @@ -213,15 +218,20 @@ export default { msgInfo.id = m.id; this.isReceipt = false; this.refreshPlaceHolder(); - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); }) }, onFileFail(e, file) { let msgInfo = JSON.parse(JSON.stringify(file.msgInfo)); msgInfo.loadStatus = 'fail'; - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); }, onFileBefore(file) { + // 被封禁提示 + if (this.isBanned) { + this.showBannedTip(); + return; + } let url = URL.createObjectURL(file); let data = { name: file.name, @@ -243,7 +253,7 @@ export default { // 填充对方id this.fillTargetId(msgInfo, this.chat.targetId); // 插入消息 - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); // 会话置顶 this.moveChatToTop(); // 滚动到底部 @@ -285,6 +295,12 @@ export default { this.showRecord = false; }, showPrivateVideo(mode) { + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } + let rtcInfo = { mode: mode, isHost: true, @@ -294,6 +310,11 @@ export default { this.$eventBus.$emit("openPrivateVideo", rtcInfo); }, onGroupVideo() { + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } // 邀请成员发起通话 let ids = [this.mine.id]; let maxChannel = this.$store.state.configStore.webrtc.maxChannel; @@ -329,6 +350,11 @@ export default { this.showHistory = false; }, onSendRecord(data) { + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } let msgInfo = { content: JSON.stringify(data), type: 3, @@ -338,7 +364,7 @@ export default { this.fillTargetId(msgInfo, this.chat.targetId); this.sendMessageRequest(msgInfo).then((m) => { m.selfSend = true; - this.$store.commit("insertMessage", m); + this.$store.commit("insertMessage", [m, this.chat]); // 会话置顶 this.moveChatToTop(); // 保持输入框焦点 @@ -364,6 +390,11 @@ export default { async sendMessage(fullList) { this.resetEditor(); this.readedMessage(); + // 检查是否被封禁 + if (this.isBanned) { + this.showBannedTip(); + return; + } let sendText = this.isReceipt ? "【回执消息】" : ""; let promiseList = []; for (let i = 0; i < fullList.length; i++) { @@ -421,7 +452,7 @@ export default { this.lockMessage = true; this.sendMessageRequest(msgInfo).then((m) => { m.selfSend = true; - this.$store.commit("insertMessage", m); + this.$store.commit("insertMessage", [m, this.chat]); // 会话置顶 this.moveChatToTop(); }).finally(() => { @@ -465,7 +496,7 @@ export default { msgInfo.type = 10; msgInfo.content = '你撤回了一条消息'; msgInfo.status = this.$enums.MESSAGE_STATUS.RECALL; - this.$store.commit("insertMessage", msgInfo); + this.$store.commit("insertMessage", [msgInfo, this.chat]); }) }); }, @@ -482,7 +513,7 @@ export default { this.$http({ url: url, method: 'put' - }).then(() => { }) + }).then(() => {}) }, loadReaded(fId) { this.$http({ @@ -588,6 +619,22 @@ export default { }) } }, + showBannedTip() { + let msgInfo = { + tmpId: this.generateId(), + sendId: this.mine.id, + sendTime: new Date().getTime(), + type: this.$enums.MESSAGE_TYPE.TIP_TEXT + } + if (this.chat.type == "PRIVATE") { + msgInfo.recvId = this.mine.id + msgInfo.content = "该用户已被管理员封禁,原因:" + this.friend.reason + } else { + msgInfo.groupId = this.group.id; + msgInfo.content = "本群聊已被管理员封禁,原因:" + this.group.reason + } + this.$store.commit("insertMessage", [msgInfo, this.chat]); + }, generateId() { // 生成临时id return String(new Date().getTime()) + String(Math.floor(Math.random() * 1000)); @@ -616,13 +663,17 @@ export default { return 0; } return this.chat.messages.length; + }, + isBanned() { + return (this.chat.type == "PRIVATE" && this.friend.isBanned) || + (this.chat.type == "GROUP" && this.group.isBanned) } }, watch: { chat: { handler(newChat, oldChat) { if (newChat.targetId > 0 && (!oldChat || newChat.type != oldChat.type || - newChat.targetId != oldChat.targetId)) { + newChat.targetId != oldChat.targetId)) { if (this.chat.type == "GROUP") { this.loadGroup(this.chat.targetId); } else { @@ -831,4 +882,4 @@ export default { } } - + \ No newline at end of file diff --git a/im-web/src/components/chat/ChatInput.vue b/im-web/src/components/chat/ChatInput.vue index 2a032d1..a5a9ee5 100644 --- a/im-web/src/components/chat/ChatInput.vue +++ b/im-web/src/components/chat/ChatInput.vue @@ -443,7 +443,7 @@ export default { if (node.dataset.id) { tempText += node.innerHTML; atUserIds.push(node.dataset.id) - } else { + } else if(node.outerHtml) { tempText += node.outerHtml; } } diff --git a/im-web/src/store/chatStore.js b/im-web/src/store/chatStore.js index ea1759e..aa1db6d 100644 --- a/im-web/src/store/chatStore.js +++ b/im-web/src/store/chatStore.js @@ -137,8 +137,8 @@ export default { this.commit("saveToStorage"); } }, - insertMessage(state, msgInfo) { - let type = msgInfo.groupId ? 'GROUP' : 'PRIVATE'; + insertMessage(state, [msgInfo, chatInfo]) { + let type = chatInfo.type; // 记录消息的最大id if (msgInfo.id && type == "PRIVATE" && msgInfo.id > state.privateMsgMaxId) { state.privateMsgMaxId = msgInfo.id; @@ -147,7 +147,7 @@ export default { state.groupMsgMaxId = msgInfo.id; } // 如果是已存在消息,则覆盖旧的消息数据 - let chat = this.getters.findChat(msgInfo); + let chat = this.getters.findChat(chatInfo); let message = this.getters.findMessage(chat, msgInfo); if (message) { Object.assign(message, msgInfo); @@ -178,7 +178,8 @@ export default { chat.lastSendTime = msgInfo.sendTime; chat.sendNickName = msgInfo.sendNickName; // 未读加1 - if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED && msgInfo.type != MESSAGE_TYPE.TIP_TEXT) { + if (!msgInfo.selfSend && msgInfo.status != MESSAGE_STATUS.READED && + msgInfo.type != MESSAGE_TYPE.TIP_TEXT) { chat.unreadCount++; } // 是否有人@我 @@ -216,9 +217,9 @@ export default { chat.stored = false; this.commit("saveToStorage"); }, - updateMessage(state, msgInfo) { + updateMessage(state, [msgInfo, chatInfo]) { // 获取对方id或群id - let chat = this.getters.findChat(msgInfo); + let chat = this.getters.findChat(chatInfo); let message = this.getters.findMessage(chat, msgInfo); if (message) { // 属性拷贝 @@ -227,8 +228,8 @@ export default { this.commit("saveToStorage"); } }, - deleteMessage(state, msgInfo) { - let chat = this.getters.findChat(msgInfo); + deleteMessage(state, [msgInfo, chatInfo]) { + let chat = this.getters.findChat(chatInfo); for (let idx in chat.messages) { // 已经发送成功的,根据id删除 if (chat.messages[idx].id && chat.messages[idx].id == msgInfo.id) { @@ -289,7 +290,7 @@ export default { }); // 将消息一次性装载回来 state.chats = cacheChats; - // 清空缓存,不再使用 + // 清空缓存 cacheChats = null; this.commit("saveToStorage"); }, @@ -384,20 +385,10 @@ export default { } } }, - findChat: (state, getters) => (msgInfo) => { + findChat: (state, getters) => (chat) => { let chats = getters.findChats(); - // 获取对方id或群id - let type = msgInfo.groupId ? 'GROUP' : 'PRIVATE'; - let targetId = msgInfo.groupId ? msgInfo.groupId : msgInfo.selfSend ? msgInfo.recvId : msgInfo.sendId; - let chat = null; - for (let idx in chats) { - if (chats[idx].type == type && - chats[idx].targetId === targetId) { - chat = chats[idx]; - break; - } - } - return chat; + let idx = getters.findChatIdx(chat); + return chats[idx]; }, findChatByFriend: (state, getters) => (fid) => { let chats = getters.findChats(); diff --git a/im-web/src/view/Home.vue b/im-web/src/view/Home.vue index a31e2fa..676783d 100644 --- a/im-web/src/view/Home.vue +++ b/im-web/src/view/Home.vue @@ -201,7 +201,7 @@ export default { // 打开会话 this.$store.commit("openChat", chatInfo); // 插入消息 - this.$store.commit("insertMessage", msg); + this.$store.commit("insertMessage", [msg, chatInfo]); // 播放提示音 if (!msg.selfSend && this.$msgType.isNormal(msg.type) && msg.status != this.$enums.MESSAGE_STATUS.READED) { @@ -251,7 +251,6 @@ export default { }) }, insertGroupMessage(group, msg) { - let chatInfo = { type: 'GROUP', targetId: group.id, @@ -261,7 +260,7 @@ export default { // 打开会话 this.$store.commit("openChat", chatInfo); // 插入消息 - this.$store.commit("insertMessage", msg); + this.$store.commit("insertMessage", [msg, chatInfo]); // 播放提示音 if (!msg.selfSend && msg.type <= this.$enums.MESSAGE_TYPE.VIDEO && msg.status != this.$enums.MESSAGE_STATUS.READED) {