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(); } },