| | |
| | | |
| | | NProgress.configure({ showSpinner: false }) |
| | | |
| | | const whiteList = ['/login', '/auth-redirect', '/bind', '/register'] |
| | | const whiteList = ['/login', '/register'] |
| | | |
| | | router.beforeEach((to, from, next) => { |
| | | NProgress.start() |
| | |
| | | if (to.path === '/login') { |
| | | next({ path: '/' }) |
| | | NProgress.done() |
| | | } else if (whiteList.indexOf(to.path) !== -1) { |
| | | next() |
| | | } else { |
| | | if (store.getters.roles.length === 0) { |
| | | isRelogin.show = true |
| | |
| | | // 在免登录白名单,直接进入 |
| | | next() |
| | | } else { |
| | | next(`/login?redirect=${to.fullPath}`) // 否则全部重定向到登录页 |
| | | next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页 |
| | | NProgress.done() |
| | | } |
| | | } |