feat: 初始访问时跳转开站引导页面
This commit is contained in:
@@ -153,16 +153,19 @@ const WHITE_LIST: string[] = [
|
|||||||
/**全局路由-前置守卫 */
|
/**全局路由-前置守卫 */
|
||||||
router.beforeEach(async (to, from, next) => {
|
router.beforeEach(async (to, from, next) => {
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
const token = getToken();
|
|
||||||
// 获取系统配置信息
|
// 获取系统配置信息
|
||||||
const appStore = useAppStore();
|
const appStore = useAppStore();
|
||||||
if (!appStore.loginBackground) {
|
if (!appStore.loginBackground) {
|
||||||
await appStore.fnSysConf();
|
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
|
// 没有token
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { getSysConf } from '@/api';
|
import { getSysConf } from '@/api';
|
||||||
import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants';
|
import { CACHE_LOCAL_I18N } from '@/constants/cache-keys-constants';
|
||||||
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
import { RESULT_CODE_SUCCESS } from '@/constants/result-constants';
|
||||||
|
import { removeToken } from '@/plugins/auth-token';
|
||||||
import { parseUrlPath } from '@/plugins/file-static-url';
|
import { parseUrlPath } from '@/plugins/file-static-url';
|
||||||
import { localGet, localSet } from '@/utils/cache-local-utils';
|
import { localGet, localSet } from '@/utils/cache-local-utils';
|
||||||
import { defineStore } from 'pinia';
|
import { defineStore } from 'pinia';
|
||||||
@@ -73,10 +74,6 @@ const useAppStore = defineStore('app', {
|
|||||||
document.title = this.appName;
|
document.title = this.appName;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**设置版权声明 */
|
|
||||||
setCopyright(text: string) {
|
|
||||||
this.copyright = text;
|
|
||||||
},
|
|
||||||
// 获取系统配置信息
|
// 获取系统配置信息
|
||||||
async fnSysConf() {
|
async fnSysConf() {
|
||||||
const res = await getSysConf();
|
const res = await getSysConf();
|
||||||
@@ -84,6 +81,10 @@ const useAppStore = defineStore('app', {
|
|||||||
this.version = res.data.version;
|
this.version = res.data.version;
|
||||||
this.buildTime = res.data.buildTime;
|
this.buildTime = res.data.buildTime;
|
||||||
this.sysGuide = res.data.sysGuide === 'true';
|
this.sysGuide = res.data.sysGuide === 'true';
|
||||||
|
// 引导时
|
||||||
|
if (this.sysGuide) {
|
||||||
|
removeToken();
|
||||||
|
}
|
||||||
this.serialNum = res.data.serialNum;
|
this.serialNum = res.data.serialNum;
|
||||||
this.appName = res.data.title;
|
this.appName = res.data.title;
|
||||||
this.copyright = res.data.copyright;
|
this.copyright = res.data.copyright;
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import { parseUrlPath } from '@/plugins/file-static-url';
|
|||||||
|
|
||||||
/**用户信息类型 */
|
/**用户信息类型 */
|
||||||
type UserInfo = {
|
type UserInfo = {
|
||||||
/**授权凭证 */
|
|
||||||
token: string;
|
|
||||||
/**登录账号 */
|
/**登录账号 */
|
||||||
userName: string;
|
userName: string;
|
||||||
/**用户角色 字符串数组 */
|
/**用户角色 字符串数组 */
|
||||||
@@ -27,13 +25,12 @@ type UserInfo = {
|
|||||||
email: string;
|
email: string;
|
||||||
/**用户性别 */
|
/**用户性别 */
|
||||||
sex: string | undefined;
|
sex: string | undefined;
|
||||||
/**个人化设置 */
|
/**其他信息 */
|
||||||
profile: Record<string, any>;
|
profile: Record<string, any>;
|
||||||
};
|
};
|
||||||
|
|
||||||
const useUserStore = defineStore('user', {
|
const useUserStore = defineStore('user', {
|
||||||
state: (): UserInfo => ({
|
state: (): UserInfo => ({
|
||||||
token: getToken(),
|
|
||||||
userName: '',
|
userName: '',
|
||||||
roles: [],
|
roles: [],
|
||||||
permissions: [],
|
permissions: [],
|
||||||
@@ -104,7 +101,6 @@ const useUserStore = defineStore('user', {
|
|||||||
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
if (res.code === RESULT_CODE_SUCCESS && res.data) {
|
||||||
const token = res.data[TOKEN_RESPONSE_FIELD];
|
const token = res.data[TOKEN_RESPONSE_FIELD];
|
||||||
setToken(token);
|
setToken(token);
|
||||||
this.token = token;
|
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
},
|
},
|
||||||
@@ -154,7 +150,6 @@ const useUserStore = defineStore('user', {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw error;
|
throw error;
|
||||||
} finally {
|
} finally {
|
||||||
this.token = '';
|
|
||||||
this.roles = [];
|
this.roles = [];
|
||||||
this.permissions = [];
|
this.permissions = [];
|
||||||
removeToken();
|
removeToken();
|
||||||
|
|||||||
Reference in New Issue
Block a user