Browse Source

fix: 用户挤下线的bug

master
xsx 6 months ago
parent
commit
b3105f9bd5
  1. 6
      im-uniapp/App.vue
  2. 7
      im-uniapp/common/wssocket.js
  3. 10
      im-web/src/view/Home.vue

6
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() {

7
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);

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

Loading…
Cancel
Save