|
|
@ -2,20 +2,20 @@ import router from './router' |
|
|
|
import store from './store' |
|
|
|
import NProgress from 'nprogress' // Progress 进度条
|
|
|
|
import 'nprogress/nprogress.css'// Progress 进度条样式
|
|
|
|
import { getToken, getRememberMeToken } from '@/utils/auth' // 验权
|
|
|
|
import { getToken } from '@/utils/auth' // 验权
|
|
|
|
const whiteList = ['/login', '/remote', '/404', '/viewhzd', '/upload', '/xingshi', '/wenjian', '/fangwei', '/qiye'] // 不重定向白名单
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
NProgress.start() |
|
|
|
if (getToken() || getRememberMeToken()) { |
|
|
|
if (getToken()) { |
|
|
|
if (to.path === '/login') { |
|
|
|
next({ path: '/' }) |
|
|
|
NProgress.done() // 结束Progress
|
|
|
|
} else if (!store.getters.roles.length) { |
|
|
|
} else if (store.getters.roles.length) { |
|
|
|
next() |
|
|
|
} else { |
|
|
|
store.dispatch('GetInfo').then(() => { |
|
|
|
next({ ...to }) |
|
|
|
next({ ...to, replace: true }) |
|
|
|
}) |
|
|
|
} else { |
|
|
|
next() |
|
|
|
} |
|
|
|
} else { |
|
|
|
const ppath = to.path |
|
|
|