wlzboy
2 天以前 8cb5d3440208a3be3e772e65f1bd0ec63031ba62
ruoyi-ui/src/permission.js
@@ -9,7 +9,7 @@
NProgress.configure({ showSpinner: false })
const whiteList = ['/login', '/register','/anonymous/*', '/h5/*']
const whiteList = ['/login', '/register','/anonymous/*', '/h5/*','/evaluation']
const isWhiteList = (path) => {
  return whiteList.some(pattern => isPathMatch(pattern, path))
@@ -24,6 +24,7 @@
  console.log('完整路径:', to.fullPath)
  console.log('Token状态:', !!getToken())
  console.log('白名单检查:', isWhiteList(to.path))
  console.log('路由meta.anonymous:', to.meta.anonymous)
  
  if (getToken()) {
    to.meta.title && store.dispatch('settings/setTitle', to.meta.title)
@@ -58,11 +59,16 @@
  } else {
    
    // 没有token
    console.log('❌ 无Token,检查白名单和匿名标记')
    console.log('白名单检查结果:', isWhiteList(to.path))
    console.log('匿名标记:', to.meta.anonymous)
    if (isWhiteList(to.path) || to.meta.anonymous) {
      // 在免登录白名单,直接进入
      console.log('✅ 允许匿名访问,直接通过')
      next()
    } else {
      console.log('🚫 需要登录,重定向到登录页')
      next(`/login?redirect=${encodeURIComponent(to.fullPath)}`) // 否则全部重定向到登录页
      NProgress.done()
    }