|
@@ -4,37 +4,17 @@ import { getAccessToken } from '@/utils/auth'
|
|
|
router.beforeEach((to, from, next) => {
|
|
router.beforeEach((to, from, next) => {
|
|
|
const needAuth = to.meta.needAuth
|
|
const needAuth = to.meta.needAuth
|
|
|
const token = getAccessToken()
|
|
const token = getAccessToken()
|
|
|
- if (needAuth) {
|
|
|
|
|
- if (token == null) {
|
|
|
|
|
- next('/login')
|
|
|
|
|
|
|
+ if (token != null) {
|
|
|
|
|
+ if (to.path === '/login') {
|
|
|
|
|
+ next({ path: '/' })
|
|
|
} else {
|
|
} else {
|
|
|
- if (to.path === '/login') {
|
|
|
|
|
- next({ path: '/' })
|
|
|
|
|
- } else {
|
|
|
|
|
- next()
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ next()
|
|
|
}
|
|
}
|
|
|
} else {
|
|
} else {
|
|
|
- next()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- /*if (to.path === '/login' && token !== null) {
|
|
|
|
|
- next({ path: '/' })
|
|
|
|
|
- } else {
|
|
|
|
|
- next()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (needAuth && token === null) {
|
|
|
|
|
- next('/login')
|
|
|
|
|
- } else {
|
|
|
|
|
- next()
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if (!needAuth) {
|
|
|
|
|
- next()
|
|
|
|
|
- } else {
|
|
|
|
|
- if (token === null) {
|
|
|
|
|
|
|
+ if (needAuth) {
|
|
|
next('/login')
|
|
next('/login')
|
|
|
|
|
+ } else {
|
|
|
|
|
+ next()
|
|
|
}
|
|
}
|
|
|
- }*/
|
|
|
|
|
|
|
+ }
|
|
|
})
|
|
})
|