先提交保留一下

This commit is contained in:
daihh
2022-06-03 10:36:26 +08:00
parent 5b9ce7fa75
commit cce3e21837
14 changed files with 88 additions and 32 deletions

View File

@@ -6,6 +6,7 @@ import 'nprogress/nprogress.css'
import { getToken } from '@/utils/token'
import { routers } from "@/data/pages"
import watermark from './utils/warterMark.js'
import constants from '@/utils/constants'
NProgress.configure({ showSpinner: false })
@@ -13,14 +14,24 @@ const whiteList = ['/login','/logout','/loading','/pc/loading','/500','/auth-red
router.beforeEach((to, from, next) => {
watermark.set("");
//动态计算文件的路径
let configPath=process.env.VUE_APP_FILE_RELATIVE_PATH;
if(configPath.startsWith('http')){
constants.fileBaseUrl=configPath;
}else{
constants.fileBaseUrl = window.location.protocol+'//'+window.location.host+configPath;
}
NProgress.start();
if (whiteList.indexOf(to.path) !== -1) {
// 在免登录白名单,直接进入
next()
}else{
if(getToken()){
if(to.path === '/login'){
next({ path: '/pc/index' })
next({ path: process.env.VUE_APP_PUBLIC_PATH+'/index' })
NProgress.done();
} else {
//后续这里需要增加一定的控制