From b3105f9bd5db8667ef7609cef75633a345ec2018 Mon Sep 17 00:00:00 2001 From: xsx <825657193@qq.com> Date: Mon, 29 Sep 2025 17:29:29 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=94=A8=E6=88=B7=E6=8C=A4=E4=B8=8B?= =?UTF-8?q?=E7=BA=BF=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- im-uniapp/App.vue | 6 ++++-- im-uniapp/common/wssocket.js | 7 ++++--- im-web/src/view/Home.vue | 10 ++++++---- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/im-uniapp/App.vue b/im-uniapp/App.vue index 3cf18f4..df3332c 100644 --- a/im-uniapp/App.vue +++ b/im-uniapp/App.vue @@ -74,8 +74,10 @@ export default { wsApi.onClose((res) => { console.log("ws断开", res); // 重新连接 - this.reconnectWs(); - this.configStore.setAppInit(false); + if (!this.reconnecting) { + this.reconnectWs(); + this.configStore.setAppInit(false); + } }) }, loadStore() { diff --git a/im-uniapp/common/wssocket.js b/im-uniapp/common/wssocket.js index 3f03c9f..4476b69 100644 --- a/im-uniapp/common/wssocket.js +++ b/im-uniapp/common/wssocket.js @@ -66,9 +66,7 @@ let connect = (wsurl, token) => { socketTask.onError((e) => { console.log("ws错误:",e) - close(); - isConnect = false; - closeCallBack && closeCallBack({ code: 1006 }); + close(1006); }) } @@ -97,6 +95,9 @@ let close = (code) => { complete: (res) => { console.log("关闭websocket连接"); isConnect = false; + if (code != 3099) { + closeCallBack && closeCallBack(res);s + } }, fail: (e) => { console.log("关闭websocket连接失败", e); diff --git a/im-web/src/view/Home.vue b/im-web/src/view/Home.vue index 49a252f..e0b9514 100644 --- a/im-web/src/view/Home.vue +++ b/im-web/src/view/Home.vue @@ -148,8 +148,10 @@ export default { this.$wsApi.onClose((e) => { if (e.code != 3000) { // 断线重连 - this.reconnectWs(); - this.configStore.setAppInit(false) + if (!this.reconnecting) { + this.reconnectWs(); + this.configStore.setAppInit(false) + } } }); }).catch((e) => { @@ -385,8 +387,8 @@ export default { this.chatStore.insertMessage(msg, chatInfo); // 播放提示音 if (!group.isDnd && !this.chatStore.loading && - !msg.selfSend && this.$msgType.isNormal(msg.type) - && msg.status != this.$enums.MESSAGE_STATUS.READED) { + !msg.selfSend && this.$msgType.isNormal(msg.type) && + msg.status != this.$enums.MESSAGE_STATUS.READED) { this.playAudioTip(); } },