From 609a31b71f75019239a4c460749299a8f2157760 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Thu, 12 Dec 2024 17:02:11 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E6=A1=8C=E9=9D=A2?= =?UTF-8?q?=E7=89=88=E5=AF=BC=E5=87=BA=E6=88=90=E5=8A=9F=E5=90=8E=E6=B2=A1?= =?UTF-8?q?=E5=93=9F=E6=AC=A7=E6=8F=90=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/core-frontend/src/websocket/index.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/core/core-frontend/src/websocket/index.ts b/core/core-frontend/src/websocket/index.ts index 874f21ef3b..df05ab5419 100644 --- a/core/core-frontend/src/websocket/index.ts +++ b/core/core-frontend/src/websocket/index.ts @@ -22,6 +22,9 @@ export default { } ] function isLoginStatus() { + if (wsCache.get('app.desktop')) { + return true + } return wsCache.get('user.token') && wsCache.get('user.uid') } @@ -45,17 +48,17 @@ export default { if (!prefix.endsWith('/')) { prefix += '/' } - console.log('newSockJS') - const socket = new SockJS(prefix + 'websocket?userId=' + wsCache.get('user.uid')) + const userId = wsCache.get('app.desktop') ? 1 : wsCache.get('user.uid') + const socket = new SockJS(prefix + 'websocket?userId=' + userId) stompClient = Stomp.over(socket) const heads = { - userId: wsCache.get('user.uid') + userId: userId } stompClient.connect( heads, () => { channels.forEach(channel => { - stompClient.subscribe('/user/' + wsCache.get('user.uid') + channel.topic, res => { + stompClient.subscribe('/user/' + userId + channel.topic, res => { res && res.body && useEmitt().emitter.emit(channel.event, res.body) }) })