| | |
| | | if (anonymous != null) { |
| | | Set<String> patterns = entry.getKey().getPatternValues(); |
| | | urls.addAll(patterns); |
| | | System.out.println("✅ 检测到匿名接口: " + patterns + " - " + handlerMethod.getMethod().getName()); |
| | | } |
| | | } |
| | | System.out.println("📜 所有匿名接口列表: " + urls); |
| | | return urls; |
| | | } |
| | | |
| | |
| | | |
| | | 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)) |
| | |
| | | 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) |
| | |
| | | } 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() |
| | | } |
| | |
| | | } |
| | | |
| | | export default new Router({ |
| | | mode: 'hash', // 使用hash模式,兼容性更好 |
| | | mode: 'history', // 使用history模式,URL更美观 |
| | | scrollBehavior: () => ({ y: 0 }), |
| | | routes: constantRoutes |
| | | }) |
| | |
| | | host: '0.0.0.0', |
| | | port: port, |
| | | open: true, |
| | | historyApiFallback: true, // history模式支持 |
| | | proxy: { |
| | | // detail: https://cli.vuejs.org/config/#devserver-proxy |
| | | [process.env.VUE_APP_BASE_API]: { |