From 09a8b6b630f9785a7d9e902fd285cc61a782cccf Mon Sep 17 00:00:00 2001 From: fan <18706759286@163.com> Date: Thu, 16 Jan 2020 13:28:29 +0800 Subject: [PATCH] =?UTF-8?q?FAS=E5=AD=90=E7=B3=BB=E7=BB=9F=E6=B5=8B?= =?UTF-8?q?=E8=AF=95PSD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/sock.js | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) 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(() => {