|
|
@ -19,44 +19,45 @@ router.beforeEach(async(to, from, next) => { |
|
|
|
document.title = getPageTitle(to.meta.title) |
|
|
|
document.title = getPageTitle(to.meta.title) |
|
|
|
next() |
|
|
|
next() |
|
|
|
// determine whether the user has logged in
|
|
|
|
// determine whether the user has logged in
|
|
|
|
// const hasToken = getToken()
|
|
|
|
const hasToken = getToken() |
|
|
|
|
|
|
|
|
|
|
|
// if (hasToken) {
|
|
|
|
if (hasToken) { |
|
|
|
// if (to.path === '/login') {
|
|
|
|
if (to.path === '/login') { |
|
|
|
// // if is logged in, redirect to the home page
|
|
|
|
// if is logged in, redirect to the home page
|
|
|
|
// next({ path: '/' })
|
|
|
|
next({ path: '/' }) |
|
|
|
// NProgress.done()
|
|
|
|
NProgress.done() |
|
|
|
// } else {
|
|
|
|
} |
|
|
|
// const hasGetUserInfo = store.getters.name
|
|
|
|
// else {
|
|
|
|
// if (hasGetUserInfo) {
|
|
|
|
// const hasGetUserInfo = store.getters.name
|
|
|
|
// next()
|
|
|
|
// if (hasGetUserInfo) {
|
|
|
|
// } else {
|
|
|
|
// next()
|
|
|
|
// try {
|
|
|
|
// } else {
|
|
|
|
// // get user info
|
|
|
|
// try {
|
|
|
|
// await store.dispatch('user/getInfo')
|
|
|
|
// // get user info
|
|
|
|
|
|
|
|
// await store.dispatch('user/getInfo')
|
|
|
|
|
|
|
|
|
|
|
|
// next()
|
|
|
|
// next()
|
|
|
|
// } catch (error) {
|
|
|
|
// } catch (error) {
|
|
|
|
// // remove token and go to login page to re-login
|
|
|
|
// // remove token and go to login page to re-login
|
|
|
|
// await store.dispatch('user/resetToken')
|
|
|
|
// await store.dispatch('user/resetToken')
|
|
|
|
// Message.error(error || 'Has Error')
|
|
|
|
// Message.error(error || 'Has Error')
|
|
|
|
// next(`/login?redirect=${to.path}`)
|
|
|
|
// next(`/login?redirect=${to.path}`)
|
|
|
|
// NProgress.done()
|
|
|
|
// NProgress.done()
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// } else {
|
|
|
|
} else { |
|
|
|
// /* has no token*/
|
|
|
|
/* has no token*/ |
|
|
|
|
|
|
|
|
|
|
|
// if (whiteList.indexOf(to.path) !== -1) {
|
|
|
|
if (whiteList.indexOf(to.path) !== -1) { |
|
|
|
// // in the free login whitelist, go directly
|
|
|
|
// in the free login whitelist, go directly
|
|
|
|
// next()
|
|
|
|
next() |
|
|
|
// } else {
|
|
|
|
} else { |
|
|
|
// // other pages that do not have permission to access are redirected to the login page.
|
|
|
|
// other pages that do not have permission to access are redirected to the login page.
|
|
|
|
// next(`/login?redirect=${to.path}`)
|
|
|
|
next(`/login?redirect=${to.path}`) |
|
|
|
// NProgress.done()
|
|
|
|
NProgress.done() |
|
|
|
// }
|
|
|
|
} |
|
|
|
// }
|
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
router.afterEach(() => { |
|
|
|
router.afterEach(() => { |
|
|
|