mirror of
https://codeup.aliyun.com/67762337eccfc218f6110e0e/vue/learning-system-portal.git
synced 2025-12-09 19:06:43 +08:00
先提交保留一下
This commit is contained in:
@@ -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 {
|
||||
//后续这里需要增加一定的控制
|
||||
|
||||
Reference in New Issue
Block a user