From 3c716caa374c7f42037c513fda314d50d50636c1 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Sat, 29 Jun 2024 09:46:47 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E7=BE=A4=E5=90=8E=E5=90=8C=E6=97=B6?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=BC=9A=E8=AF=9D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/App.vue | 62 ++++++++++++++-------------- im-uniapp/pages/group/group-info.vue | 2 + im-uniapp/store/chatStore.js | 9 ++++ 3 files changed, 42 insertions(+), 31 deletions(-) diff --git a/im-uniapp/App.vue b/im-uniapp/App.vue index 06664b8..02f6ee4 100644 --- a/im-uniapp/App.vue +++ b/im-uniapp/App.vue @@ -5,7 +5,7 @@ import * as enums from './common/enums'; import * as wsApi from './common/wssocket'; import UNI_APP from '@/.env.js' - + export default { data() { return { @@ -58,21 +58,21 @@ }) }, pullPrivateOfflineMessage(minId) { - store.commit("loadingPrivateMsg",true) + store.commit("loadingPrivateMsg", true) http({ url: "/message/private/pullOfflineMessage?minId=" + minId, method: 'GET' - }).catch(()=>{ - store.commit("loadingPrivateMsg",false) + }).catch(() => { + store.commit("loadingPrivateMsg", false) }) }, pullGroupOfflineMessage(minId) { - store.commit("loadingGroupMsg",true) + store.commit("loadingGroupMsg", true) http({ url: "/message/group/pullOfflineMessage?minId=" + minId, method: 'GET' - }).catch(()=>{ - store.commit("loadingGroupMsg",false) + }).catch(() => { + store.commit("loadingGroupMsg", false) }) }, handlePrivateMessage(msg) { @@ -109,17 +109,17 @@ // 单人视频信令 if (msgType.isRtcPrivate(msg.type)) { // #ifdef MP-WEIXIN - // 小程序不支持音视频 - return; + // 小程序不支持音视频 + return; // #endif // 被呼叫,弹出视频页面 let delayTime = 100; - if(msg.type == enums.MESSAGE_TYPE.RTC_CALL_VOICE - || msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO){ - let mode = msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO? "video":"voice"; + if (msg.type == enums.MESSAGE_TYPE.RTC_CALL_VOICE || + msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO) { + let mode = msg.type == enums.MESSAGE_TYPE.RTC_CALL_VIDEO ? "video" : "voice"; let pages = getCurrentPages(); - let curPage = pages[pages.length-1].route; - if(curPage != "pages/chat/chat-private-video"){ + let curPage = pages[pages.length - 1].route; + if (curPage != "pages/chat/chat-private-video") { const friendInfo = encodeURIComponent(JSON.stringify(friend)); uni.navigateTo({ url: `/pages/chat/chat-private-video?mode=${mode}&friend=${friendInfo}&isHost=false` @@ -128,8 +128,8 @@ } } setTimeout(() => { - uni.$emit('WS_RTC_PRIVATE',msg); - },delayTime) + uni.$emit('WS_RTC_PRIVATE', msg); + }, delayTime) return; } let chatInfo = { @@ -149,7 +149,7 @@ handleGroupMessage(msg) { // 消息加载标志 if (msg.type == enums.MESSAGE_TYPE.LOADING) { - store.commit("loadingGroupMsg",JSON.parse(msg.content)) + store.commit("loadingGroupMsg", JSON.parse(msg.content)) return; } // 消息已读处理 @@ -186,15 +186,15 @@ // 群视频信令 if (msgType.isRtcGroup(msg.type)) { // #ifdef MP-WEIXIN - // 小程序不支持音视频 - return; + // 小程序不支持音视频 + return; // #endif // 被呼叫,弹出视频页面 let delayTime = 100; - if(msg.type == enums.MESSAGE_TYPE.RTC_GROUP_SETUP){ + if (msg.type == enums.MESSAGE_TYPE.RTC_GROUP_SETUP) { let pages = getCurrentPages(); - let curPage = pages[pages.length-1].route; - if(curPage != "pages/chat/chat-group-video"){ + let curPage = pages[pages.length - 1].route; + if (curPage != "pages/chat/chat-group-video") { const userInfos = encodeURIComponent(msg.content); const inviterId = msg.sendId; const groupId = msg.groupId @@ -207,11 +207,11 @@ } // 消息转发到chat-group-video页面进行处理 setTimeout(() => { - uni.$emit('WS_RTC_GROUP',msg); - },delayTime) + uni.$emit('WS_RTC_GROUP', msg); + }, delayTime) return; } - + let chatInfo = { type: 'GROUP', targetId: group.id, @@ -272,8 +272,8 @@ // this.audioTip.src = "/static/audio/tip.wav"; // this.audioTip.play(); }, - isExpired(loginInfo){ - if(!loginInfo || !loginInfo.expireTime){ + isExpired(loginInfo) { + if (!loginInfo || !loginInfo.expireTime) { return true; } return loginInfo.expireTime < new Date().getTime(); @@ -311,12 +311,12 @@ uni.switchTab({ url: "/pages/chat/chat" }) - } else{ + } else { // 跳转到登录页 // #ifdef H5 - uni.navigateTo({ - url: "/pages/login/login" - }) + uni.navigateTo({ + url: "/pages/login/login" + }) // #endif } } diff --git a/im-uniapp/pages/group/group-info.vue b/im-uniapp/pages/group/group-info.vue index 60cff9b..fe4b4e1 100644 --- a/im-uniapp/pages/group/group-info.vue +++ b/im-uniapp/pages/group/group-info.vue @@ -112,6 +112,7 @@ url:"/pages/group/group" }); this.$store.commit("removeGroup", this.groupId); + this.$store.commit("removeGroupChat",this.groupId); },100) } }) @@ -141,6 +142,7 @@ url:"/pages/group/group" }); this.$store.commit("removeGroup", this.groupId); + this.$store.commit("removeGroupChat",this.groupId); },100) } }) diff --git a/im-uniapp/store/chatStore.js b/im-uniapp/store/chatStore.js index f889660..7e2e1a2 100644 --- a/im-uniapp/store/chatStore.js +++ b/im-uniapp/store/chatStore.js @@ -133,6 +133,15 @@ export default { } } }, + removeGroupChat(state, groupId) { + let chats = this.getters.findChats(); + for (let idx in chats) { + if (chats[idx].type == 'GROUP' && + chats[idx].targetId == groupId) { + this.commit("removeChat", idx); + } + } + }, moveTop(state, idx) { let chats = this.getters.findChats(); let chat = chats[idx];