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