-
Notifications
You must be signed in to change notification settings - Fork 7.7k
fix: 解决AccessModeType:backend登录过期,重新登录不会重新生成路由的问题 #5830
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
1、长时间未登录登录过期,再次打开页面构开始生成动态路由 2、fetchMenuListAsync后台返回401登录过期:doReAuthenticate函数跳转到登录页面 3、异常被拦截,return [] 4、gurad.ts accessStore.setIsAccessChecked(true); 被错误的标识为已生成路由 5、重新登录后,accessStore.isAccessChecked=true未能正确的重新生成路由
|
WalkthroughThe change updates the error handling in the Changes
Sequence Diagram(s)sequenceDiagram
participant C as Caller
participant G as generateRoutesByBackend
C->>G: Call generateRoutesByBackend(options)
alt Error occurs
G-->>C: Log error, then throw error
else Success
G-->>C: Return RouteRecordRaw[]
end
Suggested labels
Suggested reviewers
Poem
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (1)
packages/utils/src/helpers/generate-routes-backend.ts (1)
34-36
: Improved error handling to fix route regeneration issue.This change makes the function propagate errors instead of silently returning an empty array. This fixes the issue where the access checker would incorrectly mark routes as generated when errors occur during authentication, preventing proper route regeneration after re-login.
Consider adding a comment explaining the rationale for throwing the error instead of returning an empty array:
} catch (error) { console.error(error); + // Propagate error to prevent setting isAccessChecked to true when authentication fails throw error; }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/utils/src/helpers/generate-routes-backend.ts
(1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: post-update (windows-latest)
- GitHub Check: post-update (ubuntu-latest)
1、长时间未登录登录过期,再次打开页面构开始生成动态路由 2、fetchMenuListAsync后台返回401登录过期:doReAuthenticate函数跳转到登录页面 3、异常被拦截,return [] 4、gurad.ts accessStore.setIsAccessChecked(true); 被错误的标识为已生成路由 5、重新登录后,accessStore.isAccessChecked=true未能正确的重新生成路由
重现步骤分析:
1、长时间未登录登录过期,再次打开页面构开始生成动态路由
2、fetchMenuListAsync后台返回401登录过期:doReAuthenticate函数跳转到登录页面
3、异常被拦截,return []
4、gurad.ts accessStore.setIsAccessChecked(true); 被错误的标识为已生成路由
5、重新登录后,accessStore.isAccessChecked=true未能正确的重新生成路由
Description
Type of change
Please delete options that are not relevant.
pnpm-lock.yaml
unless you introduce a new test example.Checklist
pnpm run docs:dev
command.pnpm test
.feat:
,fix:
,perf:
,docs:
, orchore:
.Summary by CodeRabbit