|
|
|
@ -14,7 +14,7 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration |
|
|
|
|
const whiteList = ['/user/login'] |
|
|
|
|
|
|
|
|
|
// 默认的主页
|
|
|
|
|
const defaultRoutePath = '/store/index' |
|
|
|
|
const defaultRoutePath = '/goods/index' |
|
|
|
|
|
|
|
|
|
router.beforeEach((to, from, next) => { |
|
|
|
|
NProgress.start() // start progress bar
|
|
|
|
@ -31,6 +31,7 @@ router.beforeEach((to, from, next) => { |
|
|
|
|
store |
|
|
|
|
.dispatch('GetInfo') |
|
|
|
|
.then(data => { |
|
|
|
|
console.log() |
|
|
|
|
const roles = data.roles |
|
|
|
|
store.dispatch('GenerateRoutes', { roles }).then(() => { |
|
|
|
|
// 根据roles权限生成可访问的路由表
|
|
|
|
@ -53,7 +54,7 @@ router.beforeEach((to, from, next) => { |
|
|
|
|
description: '请求用户信息失败,请重试' |
|
|
|
|
}) |
|
|
|
|
store.dispatch('Logout').then(() => { |
|
|
|
|
next({ path: '/user/login', query: { redirect: to.fullPath } }) |
|
|
|
|
next({ path: '/user/login',}) |
|
|
|
|
}) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
@ -64,7 +65,7 @@ router.beforeEach((to, from, next) => { |
|
|
|
|
// 在免登录白名单,直接进入
|
|
|
|
|
next() |
|
|
|
|
} else { |
|
|
|
|
next({ path: '/user/login', query: { redirect: to.fullPath } }) |
|
|
|
|
next({ path: '/user/login',}) |
|
|
|
|
NProgress.done() // if current page is login will not trigger afterEach hook, so manually handle it
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|