Skip to content

Conversation

@MistyMoonR
Copy link
Contributor

@MistyMoonR MistyMoonR commented Feb 8, 2026

Description

访问控制: backend 或者 mixed
当后端返回菜单项 meta.menuVisibleWithForbidden 为 true 时,将其路由组件替换为 403 页,菜单仍展示该项,访问时展示 403,便于用户知悉功能并申请权限。
实现官方文档里 权限->菜单可见,但禁止访问 的功能

原先样式
75e3c533edf719461132a2d93ac63881

修改后样式
image

Type of change

  • New feature (non-breaking change which adds functionality)

Checklist

  • If you introduce new functionality, document it. You can run documentation with pnpm run docs:dev command.
  • Run the tests with pnpm test.
  • Changes in changelog are generated from PR name. Please, make sure that it explains your changes in an understandable manner. Please, prefix changeset messages with feat:, fix:, perf:, docs:, or chore:.
  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Summary by CodeRabbit

  • New Features
    • Routes now support displaying a forbidden access state. Users encountering restricted routes will see a customizable component informing them about permission requirements and enabling access requests. A new configuration option allows customization of the forbidden state display. Enhanced handling of unavailable menu data during route generation.

当后端菜单项 `meta.menuVisibleWithForbidden` 为 true 时,将其路由组件替换为 403 页,菜单仍展示该项,访问时展示 403,便于用户知悉功能并申请权限。
@changeset-bot
Copy link

changeset-bot bot commented Feb 8, 2026

⚠️ No Changeset found

Latest commit: 29118a5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 8, 2026

📝 Walkthrough

Walkthrough

Extended the backend route generation to support a forbiddenComponent option that substitutes routes marked with menuVisibleWithForbidden. Added a menuHasVisibleWithForbidden helper function to detect such routes. The implementation guards against missing menuRoutes by returning an empty array.

Changes

Cohort / File(s) Summary
Route Generation Enhancement
packages/utils/src/helpers/generate-routes-backend.ts
Added forbiddenComponent option to GenerateMenuAndRoutesOptions and integrated route traversal logic to replace components of routes with meta.menuVisibleWithForbidden. Introduced menuHasVisibleWithForbidden helper function and added guard against missing menuRoutes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • #5830: Modifies the same generateRoutesByBackend function with error handling changes that may interact with the new forbidden component logic.
  • #6294: Introduced mixed access mode that directly calls generateRoutesByBackend, which is now affected by the new forbiddenComponent parameter addition.
  • #5871: Also modifies route component substitution logic in convertRoutes within the same file, handling component replacement for invalid pages.

Suggested reviewers

  • anncwb
  • vince292007
  • mynetfan

Poem

🐰 A guardian at the gate, so wise and true,
Forbidden routes now wear a 403 shoe,
With component swaps and helpers so neat,
Your access control is now more complete! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Description check ❓ Inconclusive PR description lacks English content and critical checklist items are unchecked (documentation, tests), though type of change and key implementation details are present. Provide English description translation and verify all critical checklist items (documentation, tests, dependent changes). Confirm whether tests were actually added/run.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly and concisely describes the main change: adding support for menuVisibleWithForbidden in the generate-routes-backend functionality.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jinmao88 jinmao88 merged commit 22ed522 into vbenjs:main Feb 8, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants