| | |
| | | const token = getToken() |
| | | if (!token && to.name !== LOGIN_PAGE_ROUTE_NAME) { |
| | | // 未登录且要跳转的页面不是登录页 |
| | | next({ |
| | | /* next({ |
| | | name: LOGIN_PAGE_ROUTE_NAME // 跳转到登录页 |
| | | }) |
| | | }) */ |
| | | next() // 跳转 |
| | | } else if (!token && to.name === LOGIN_PAGE_ROUTE_NAME) { |
| | | // 未登陆且要跳转的页面是登录页 |
| | | next() // 跳转 |
| | | } else if (token && to.name === LOGIN_PAGE_ROUTE_NAME) { |
| | | // 已登录且要跳转的页面是登录页 |
| | | next({ |
| | | name: homeRouterName // 跳转到homeName页 |
| | | }) |
| | | // next({ |
| | | // name: homeRouterName // 跳转到homeName页 |
| | | // }) |
| | | console.log(homeRouterName) |
| | | next() |
| | | } else if (!token) { |
| | | next({ |
| | | name: LOGIN_PAGE_ROUTE_NAME // 跳转到登录页 |
| | | }) |
| | | // next({ |
| | | // name: LOGIN_PAGE_ROUTE_NAME // 跳转到登录页 |
| | | // }) |
| | | console.log(LOGIN_PAGE_ROUTE_NAME) |
| | | next() |
| | | } else { |
| | | next() |
| | | } |