diff --git a/src/utils/sock.js b/src/utils/sock.js index b35e07a6c..66eeb5ca1 100644 --- a/src/utils/sock.js +++ b/src/utils/sock.js @@ -52,7 +52,6 @@ StompClient.prototype = { const that = this; this.clientIns.connect({ 'X-Token': getToken() }, () => { if (notFirstConnect) { - store.dispatch('app/SET_DIALOG_MESSAGE', ''); setTimeout(()=>{ Message.success('连接成功'); }); } console.info('连接成功.'); @@ -65,21 +64,17 @@ StompClient.prototype = { }); // sock断开回调 - this.clientIns.ws.onclose = () => { - // MessageBox.confirm('连接已经断开'); - store.dispatch('app/SET_DIALOG_MESSAGE', 'socket连接已断开'); + that.clientIns.ws.onclose = () => { + Message.error(`通信连接已断开!`); notFirstConnect = true; checkLoginLine().then(() => { - this.status = false; - this.count++; - this.reconnect(this.count); + that.status = false; + that.count++; + that.reconnect(that.count); }).catch((err) => { - this.logOut(err); + that.logOut(err); }); }; - this.clientIns.ws.onerror = ()=>{ - console.log(1111); - }; resolve(this); }, () => { checkLoginLine().then(() => { @@ -110,7 +105,7 @@ StompClient.prototype = { // 恢复链接 reconnect(count) { console.info(`尝试第${count || 1}次连接.`); - store.dispatch('app/SET_DIALOG_MESSAGE', `正在尝试第${count || 1}次连接.`); + Message.warning(`正在尝试第${count || 1}次通讯连接。`); const that = this; setTimeout(() => { that.connect().then(() => { }).catch(() => {