|
|
@@ -221,22 +221,22 @@ router.beforeEach((to, from, next) => {
|
|
|
document.title = to.meta.title
|
|
|
}
|
|
|
|
|
|
+ const vuexStore = router.app.$options.store
|
|
|
// router.app.$options.store 就是 this.$store
|
|
|
- if (checkPower.updateUserRole(router.app.$options.store.state.user.userInfo)) {
|
|
|
- router.app.$options.store.state.user.userInfo.role = 'ROLE_USER'
|
|
|
- router.app.$options.store.commit('setUserInfo', router.app.$options.store.state.user.userInfo)
|
|
|
+ if (checkPower.updateUserRole(vuexStore.state.user.userInfo)) {
|
|
|
+ vuexStore.state.user.userInfo.role = 'ROLE_USER'
|
|
|
+ vuexStore.commit('SET_USER_INFO', vuexStore.state.user.userInfo)
|
|
|
}
|
|
|
|
|
|
const date = new Date().getTime()
|
|
|
- if (router.app.$options.store.state.user.userInfo != null) {
|
|
|
- // console.log(router.app.$options.store.state.userInfo.expireTime > date, router.app.$options.store.state.userInfo.expireTime, date)
|
|
|
- if (router.app.$options.store.state.user.userInfo.expireTime > date) {
|
|
|
+ if (vuexStore.state.user.userInfo != null) {
|
|
|
+ if (vuexStore.state.user.userInfo.expireTime > date) {
|
|
|
if (to.path === '/login') {
|
|
|
return next({ path: '/' })
|
|
|
}
|
|
|
return next()
|
|
|
} else {
|
|
|
- router.app.$options.store.commit('setUserInfo', null)
|
|
|
+ vuexStore.commit('user/SET_USER_INFO', null)
|
|
|
return next({
|
|
|
path: '/login',
|
|
|
query: { redirect: to.fullPath }
|