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) => { wsApi.onClose((res) => {
console.log("ws断开", res); console.log("ws断开", res);
// //
this.reconnectWs(); if (!this.reconnecting) {
this.configStore.setAppInit(false); this.reconnectWs();
this.configStore.setAppInit(false);
}
}) })
}, },
loadStore() { loadStore() {

7
im-uniapp/common/wssocket.js

@ -66,9 +66,7 @@ let connect = (wsurl, token) => {
socketTask.onError((e) => { socketTask.onError((e) => {
console.log("ws错误:",e) console.log("ws错误:",e)
close(); close(1006);
isConnect = false;
closeCallBack && closeCallBack({ code: 1006 });
}) })
} }
@ -97,6 +95,9 @@ let close = (code) => {
complete: (res) => { complete: (res) => {
console.log("关闭websocket连接"); console.log("关闭websocket连接");
isConnect = false; isConnect = false;
if (code != 3099) {
closeCallBack && closeCallBack(res);s
}
}, },
fail: (e) => { fail: (e) => {
console.log("关闭websocket连接失败", e); console.log("关闭websocket连接失败", e);

10
im-web/src/view/Home.vue

@ -148,8 +148,10 @@ export default {
this.$wsApi.onClose((e) => { this.$wsApi.onClose((e) => {
if (e.code != 3000) { if (e.code != 3000) {
// 线 // 线
this.reconnectWs(); if (!this.reconnecting) {
this.configStore.setAppInit(false) this.reconnectWs();
this.configStore.setAppInit(false)
}
} }
}); });
}).catch((e) => { }).catch((e) => {
@ -385,8 +387,8 @@ export default {
this.chatStore.insertMessage(msg, chatInfo); this.chatStore.insertMessage(msg, chatInfo);
// //
if (!group.isDnd && !this.chatStore.loading && if (!group.isDnd && !this.chatStore.loading &&
!msg.selfSend && this.$msgType.isNormal(msg.type) !msg.selfSend && this.$msgType.isNormal(msg.type) &&
&& msg.status != this.$enums.MESSAGE_STATUS.READED) { msg.status != this.$enums.MESSAGE_STATUS.READED) {
this.playAudioTip(); this.playAudioTip();
} }
}, },

Loading…
Cancel
Save