wlzboy
2025-09-24 62a079a15b46925283581f6caaf631b5a4558927
ruoyi-ui/src/permission.js
@@ -9,7 +9,7 @@
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))
@@ -17,6 +17,14 @@
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*/
@@ -24,6 +32,7 @@
      next({ path: '/' })
      NProgress.done()
    } else if (isWhiteList(to.path)) {
      console.log('✅ 有Token且在白名单,直接通过')
      next()
    } else {
      if (store.getters.roles.length === 0) {
@@ -47,7 +56,7 @@
      }
    }
  } else {
    debugger;
    // 没有token
    if (isWhiteList(to.path) || to.meta.anonymous) {
      // 在免登录白名单,直接进入