From 83b4be06c87a27cf436ca07e18d916abcf24c49f Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 29 Nov 2022 16:04:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=8D=95=E8=AF=8D=E6=8B=BC=E5=86=99?= =?UTF-8?q?=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- frontend/src/websocket/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/frontend/src/websocket/index.js b/frontend/src/websocket/index.js index b623bb0e6a..91d9592457 100644 --- a/frontend/src/websocket/index.js +++ b/frontend/src/websocket/index.js @@ -20,8 +20,8 @@ class DeWebsocket { initialize() { this.connection() const _this = this - this.timer = this.isLoginStatu() && setInterval(() => { - this.isLoginStatu() || this.destroy() + this.timer = this.isLoginStatus() && setInterval(() => { + this.isLoginStatus() || this.destroy() try { _this.client && _this.client.send('heart detection') } catch (error) { @@ -41,12 +41,12 @@ class DeWebsocket { this.initialize() } - isLoginStatu() { + isLoginStatus() { return store.state && store.state.user && store.state.user.user && store.state.user.user.userId } connection() { - if (!this.isLoginStatu()) { + if (!this.isLoginStatus()) { return } const socket = new SockJS(this.ws_url + '?userId=' + store.state.user.user.userId) @@ -70,6 +70,7 @@ class DeWebsocket { } ).bind(this) } + subscribe() { this.channels.forEach(channel => { this.client.subscribe('/user/' + store.state.user.user.userId + channel.topic, res => { @@ -77,6 +78,7 @@ class DeWebsocket { }) }) } + disconnect() { this.client && this.client.disconnect() }