| | |
| | | router.beforeEach((to, from, next) => { |
| | | NProgress.start(); |
| | | const meta = to.meta || {}; |
| | | const whiteList = ['/login', '/404', '/401', '/lock','/pack'] |
| | | if (store.getters.access_token) { |
| | | if (store.getters.isLock && to.path !== '/lock') { |
| | | next({ path: '/lock' }); |
| | |
| | | // 页面多开:载入localStorage的auth参数 By Luxn |
| | | let auth = JSON.parse(localStorage.getItem("authorization") || "{}"); |
| | | if ( meta.isAuth === false) { |
| | | next(); |
| | | //没有token的情况 |
| | | if (whiteList.indexOf(to.path) !== -1) { |
| | | // 如果在白名单内则直接跳转 |
| | | next() |
| | | } else { |
| | | // 其余页面重定向到登录页 |
| | | next('/login') |
| | | } |
| | | // next(); |
| | | }else{ |
| | | if (auth.date_time) { |
| | | let key = ["access_token", "refresh_token", "expires_in", "user_info", "language"]; |
| | |
| | | }else{ |
| | | next('/login'); |
| | | } |
| | | |
| | | } |
| | | } |
| | | }) |