From 46eadf7f8d14e6875ea00533c4d6e58875a129ff Mon Sep 17 00:00:00 2001 From: Lyn Lee <15036012006@126.com> Date: Thu, 12 Jun 2025 18:38:19 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=99=BB=E5=BD=95=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 默认先websoket鉴权判断是否需要登录 --- src/App.vue | 3 --- src/store/server/actions.ts | 21 ++++++++++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/App.vue b/src/App.vue index adc6750a..c65adf61 100644 --- a/src/App.vue +++ b/src/App.vue @@ -403,9 +403,6 @@ export default class App extends Mixins(BaseMixin, ThemeMixin) { this.appHeight() window.addEventListener('resize', this.appHeight) window.addEventListener('orientationchange', this.appHeight) - if (!localStorage.getItem('token')) { - this.$refs.loginRef.showDialog=true - } } } diff --git a/src/store/server/actions.ts b/src/store/server/actions.ts index b8416e7c..7ab37b19 100644 --- a/src/store/server/actions.ts +++ b/src/store/server/actions.ts @@ -21,19 +21,26 @@ export const actions: ActionTree = { // identify client try { - let token = null - if (localStorage.getItem('token')) { - token = localStorage.getItem('token') - } else { - token = null + let token = localStorage.getItem('token') + + let data = { + client_name: 'mainsail', + version: rootState.packageVersion, + type: 'web', + url: 'https://github.com/mainsail-crew/mainsail', } - const connection = await Vue.$socket.emitAndWait('server.connection.identify', { + + let dataWithToken = { client_name: 'mainsail', version: rootState.packageVersion, type: 'web', url: 'https://github.com/mainsail-crew/mainsail', access_token: token - }) + } + + let wsData = token ? dataWithToken : data; + + const connection = await Vue.$socket.emitAndWait('server.connection.identify', wsData) commit('setConnectionId', connection.connection_id) } catch (e: any) { if (e.message === 'Unauthorized') {