|
|
|
@ -19,14 +19,15 @@ router.beforeEach(async(to, from, next) => {
@@ -19,14 +19,15 @@ router.beforeEach(async(to, from, next) => {
|
|
|
|
|
document.title = getPageTitle(to.meta.title) |
|
|
|
|
next() |
|
|
|
|
// determine whether the user has logged in
|
|
|
|
|
// const hasToken = getToken()
|
|
|
|
|
const hasToken = getToken() |
|
|
|
|
|
|
|
|
|
// if (hasToken) {
|
|
|
|
|
// if (to.path === '/login') {
|
|
|
|
|
// // if is logged in, redirect to the home page
|
|
|
|
|
// next({ path: '/' })
|
|
|
|
|
// NProgress.done()
|
|
|
|
|
// } else {
|
|
|
|
|
if (hasToken) { |
|
|
|
|
if (to.path === '/login') { |
|
|
|
|
// if is logged in, redirect to the home page
|
|
|
|
|
next({ path: '/' }) |
|
|
|
|
NProgress.done() |
|
|
|
|
} |
|
|
|
|
// else {
|
|
|
|
|
// const hasGetUserInfo = store.getters.name
|
|
|
|
|
// if (hasGetUserInfo) {
|
|
|
|
|
// next()
|
|
|
|
@ -45,18 +46,18 @@ router.beforeEach(async(to, from, next) => {
@@ -45,18 +46,18 @@ router.beforeEach(async(to, from, next) => {
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// } else {
|
|
|
|
|
// /* has no token*/
|
|
|
|
|
} else { |
|
|
|
|
/* has no token*/ |
|
|
|
|
|
|
|
|
|
// if (whiteList.indexOf(to.path) !== -1) {
|
|
|
|
|
// // in the free login whitelist, go directly
|
|
|
|
|
// next()
|
|
|
|
|
// } else {
|
|
|
|
|
// // other pages that do not have permission to access are redirected to the login page.
|
|
|
|
|
// next(`/login?redirect=${to.path}`)
|
|
|
|
|
// NProgress.done()
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
if (whiteList.indexOf(to.path) !== -1) { |
|
|
|
|
// in the free login whitelist, go directly
|
|
|
|
|
next() |
|
|
|
|
} else { |
|
|
|
|
// other pages that do not have permission to access are redirected to the login page.
|
|
|
|
|
next(`/login?redirect=${to.path}`) |
|
|
|
|
NProgress.done() |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
router.afterEach(() => { |
|
|
|
|