| | |
| | | |
| | | NProgress.configure({ showSpinner: false }) |
| | | |
| | | const whiteList = ['/login', '/register','/anonymous/*'] |
| | | const whiteList = ['/login', '/register','/anonymous/*', '/h5/*'] |
| | | |
| | | const isWhiteList = (path) => { |
| | | return whiteList.some(pattern => isPathMatch(pattern, path)) |
| | |
| | | |
| | | router.beforeEach((to, from, next) => { |
| | | NProgress.start() |
| | | |
| | | // 调试日志 |
| | | console.log('=== 路由守卫调试 ===') |
| | | console.log('目标路径:', to.path) |
| | | console.log('完整路径:', to.fullPath) |
| | | console.log('Token状态:', !!getToken()) |
| | | console.log('白名单检查:', isWhiteList(to.path)) |
| | | |
| | | if (getToken()) { |
| | | to.meta.title && store.dispatch('settings/setTitle', to.meta.title) |
| | | /* has token*/ |
| | |
| | | next({ path: '/' }) |
| | | NProgress.done() |
| | | } else if (isWhiteList(to.path)) { |
| | | console.log('✅ 有Token且在白名单,直接通过') |
| | | next() |
| | | } else { |
| | | if (store.getters.roles.length === 0) { |