feat: 初始访问时跳转开站引导页面

This commit is contained in:
TsMask
2024-04-24 15:27:23 +08:00
parent e351960229
commit 1085fa16aa
3 changed files with 14 additions and 15 deletions

View File

@@ -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) {

View File

@@ -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;

View File

@@ -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<string, any>;
};
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();