|
|
@ -1,6 +1,7 @@
|
|
|
|
import { Router } from 'vue-router';
|
|
|
|
import { Router } from 'vue-router';
|
|
|
|
import { PageEnum, PreviewEnum } from '@/enums/pageEnum'
|
|
|
|
import { PageEnum, PreviewEnum } from '@/enums/pageEnum'
|
|
|
|
import { loginCheck } from '@/utils'
|
|
|
|
import { loginCheck, setLocalStorage, getLocalStorage,clearLocalStorage } from '@/utils'
|
|
|
|
|
|
|
|
import { StorageEnum } from '@/enums/storageEnum'
|
|
|
|
|
|
|
|
|
|
|
|
// 路由白名单
|
|
|
|
// 路由白名单
|
|
|
|
const routerAllowList = [
|
|
|
|
const routerAllowList = [
|
|
|
@ -13,14 +14,31 @@ const routerAllowList = [
|
|
|
|
export function createRouterGuards(router: Router) {
|
|
|
|
export function createRouterGuards(router: Router) {
|
|
|
|
// 前置
|
|
|
|
// 前置
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
router.beforeEach(async (to, from, next) => {
|
|
|
|
console.log(to);
|
|
|
|
//clearLocalStorage(StorageEnum.GO_SYSTEM_STORE);
|
|
|
|
|
|
|
|
if (to.query.token) {
|
|
|
|
|
|
|
|
console.log(to.query.token);
|
|
|
|
|
|
|
|
let info = {
|
|
|
|
|
|
|
|
tenantInfo: {
|
|
|
|
|
|
|
|
tenantId: 1
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
userInfo: {
|
|
|
|
|
|
|
|
nickName: "芋道源码",
|
|
|
|
|
|
|
|
tokenName: "Authorization",
|
|
|
|
|
|
|
|
userId: 1,
|
|
|
|
|
|
|
|
userName: "芋道源码",
|
|
|
|
|
|
|
|
userToken: to.query.token
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
setLocalStorage(StorageEnum.GO_SYSTEM_STORE, info);
|
|
|
|
|
|
|
|
const infoMsg = getLocalStorage(StorageEnum.GO_SYSTEM_STORE)
|
|
|
|
|
|
|
|
console.log(infoMsg);
|
|
|
|
|
|
|
|
}
|
|
|
|
const Loading = window['$loading'];
|
|
|
|
const Loading = window['$loading'];
|
|
|
|
Loading && Loading.start();
|
|
|
|
Loading && Loading.start();
|
|
|
|
const isErrorPage = router.getRoutes().findIndex((item) => item.name === to.name);
|
|
|
|
const isErrorPage = router.getRoutes().findIndex((item) => item.name === to.name);
|
|
|
|
if (isErrorPage === -1) {
|
|
|
|
if (isErrorPage === -1) {
|
|
|
|
next({ name: PageEnum.ERROR_PAGE_NAME_404 })
|
|
|
|
next({ name: PageEnum.ERROR_PAGE_NAME_404 })
|
|
|
|
}
|
|
|
|
}
|
|
|
|
console.log('hhhhhhhi')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
|
|
// @ts-ignore
|
|
|
|
if (!routerAllowList.includes(to.name) && !loginCheck()) {
|
|
|
|
if (!routerAllowList.includes(to.name) && !loginCheck()) {
|
|
|
|