diff --git a/src/router/index.ts b/src/router/index.ts index f5b566f0..8b327fc7 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -153,16 +153,19 @@ const WHITE_LIST: string[] = [ /**全局路由-前置守卫 */ router.beforeEach(async (to, from, next) => { NProgress.start(); - const token = getToken(); + // 获取系统配置信息 const appStore = useAppStore(); if (!appStore.loginBackground) { await appStore.fnSysConf(); - console.log(to.path); - if (appStore.sysGuide && to.path !== '/quick-build') { - next({ name: 'QuickBuild' }); - } } + console.log(to.path); + // 需要系统引导跳转 + if (appStore.sysGuide && to.path !== '/quick-build') { + next({ name: 'QuickBuild' }); + } + + const token = getToken(); // 没有token if (!token) { diff --git a/src/store/modules/app.ts b/src/store/modules/app.ts index b28838f3..66c52987 100644 --- a/src/store/modules/app.ts +++ b/src/store/modules/app.ts @@ -1,6 +1,7 @@ import { getSysConf } from '@/api'; import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants'; import { RESULT_CODE_SUCCESS } from '@/constants/result-constants'; +import { removeToken } from '@/plugins/auth-token'; import { parseUrlPath } from '@/plugins/file-static-url'; import { localGet, localSet } from '@/utils/cache-local-utils'; import { defineStore } from 'pinia'; @@ -73,10 +74,6 @@ const useAppStore = defineStore('app', { document.title = this.appName; } }, - /**设置版权声明 */ - setCopyright(text: string) { - this.copyright = text; - }, // 获取系统配置信息 async fnSysConf() { const res = await getSysConf(); @@ -84,6 +81,10 @@ const useAppStore = defineStore('app', { this.version = res.data.version; this.buildTime = res.data.buildTime; this.sysGuide = res.data.sysGuide === 'true'; + // 引导时 + if (this.sysGuide) { + removeToken(); + } this.serialNum = res.data.serialNum; this.appName = res.data.title; this.copyright = res.data.copyright; diff --git a/src/store/modules/user.ts b/src/store/modules/user.ts index 96daf0ad..1d4d4629 100644 --- a/src/store/modules/user.ts +++ b/src/store/modules/user.ts @@ -9,8 +9,6 @@ import { parseUrlPath } from '@/plugins/file-static-url'; /**用户信息类型 */ type UserInfo = { - /**授权凭证 */ - token: string; /**登录账号 */ userName: string; /**用户角色 字符串数组 */ @@ -27,13 +25,12 @@ type UserInfo = { email: string; /**用户性别 */ sex: string | undefined; - /**个人化设置 */ + /**其他信息 */ profile: Record; }; const useUserStore = defineStore('user', { state: (): UserInfo => ({ - token: getToken(), userName: '', roles: [], permissions: [], @@ -104,7 +101,6 @@ const useUserStore = defineStore('user', { if (res.code === RESULT_CODE_SUCCESS && res.data) { const token = res.data[TOKEN_RESPONSE_FIELD]; setToken(token); - this.token = token; } return res; }, @@ -154,7 +150,6 @@ const useUserStore = defineStore('user', { } catch (error) { throw error; } finally { - this.token = ''; this.roles = []; this.permissions = []; removeToken();