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