Skip to content

Conversation

@SharerMax
Copy link
Contributor

@SharerMax SharerMax commented Sep 29, 2025

🤔 这个 PR 的性质是?

  • 日常 bug 修复
  • 新特性提交
  • 文档改进
  • 演示代码改进
  • 组件样式/交互改进
  • CI/CD 改进
  • 重构
  • 代码风格优化
  • 测试用例
  • 分支合并
  • 其他

🔗 相关 Issue

💡 需求背景和解决方案

  • permission-fe 用例
  • roleCode 权限处理
  • restore 已删除的路由

roleCode 判断规则

parent child result
parent 和 child 可访问
parent 可访问
parent 和 child 不可访问
parent 和 child 不可访问

📝 更新日志

  • fix!: 前端权限控制 移除路由 name 作为 roleCode

  • 本条 PR 不需要纳入 Changelog

☑️ 请求合并前的自查清单

⚠️ 请自检并全部勾选全部选项⚠️

  • 文档已补充或无须补充
  • 代码演示已提供或无须提供
  • TypeScript 定义已补充或无须补充
  • Changelog 已提供或无须提供

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2025

完成

@SharerMax
Copy link
Contributor Author

whiteListRouters 貌似不需要存在

  1. server 端控制路由时,访问控制通过接口控制,无需 whiteListRouters
  2. fe 端控制路由时, defaultRouterList 就是实际意义的 whiteListRouters

@SharerMax SharerMax marked this pull request as ready for review October 13, 2025 16:52
@SharerMax SharerMax changed the title fix: permission-fe refactor: permission-fe Oct 13, 2025
@SharerMax SharerMax marked this pull request as draft October 13, 2025 17:10
@SharerMax
Copy link
Contributor Author

name 作为可选字段,需要处理 name 不存在的情况。
restore 添加嵌套路由时,需要 parentName 来指定父节点 🤔

@SharerMax SharerMax marked this pull request as ready for review October 15, 2025 08:09
@liweijie0812 liweijie0812 requested a review from Copilot October 15, 2025 11:14
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refactors front-end permission handling to use roleCode-based access rules, dynamically registers/unregisters routes at runtime, and adjusts router initialization and 404 handling.

  • Introduces dynamic add/remove of routes using Vue Router’s remove functions to support restore on logout.
  • Adds roleCode-based filtering for front-end permissions with an optional strict mode toggle.
  • Updates router initialization to start with default routes only and adds a proper 404 catch-all component.

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/utils/route/constant.ts Adds typed 404 route with a catch-all path and component.
src/store/modules/user.ts Simplifies roles and removes persist-time route init hook (handled in guard now).
src/store/modules/permission.ts Registers routes dynamically and provides a robust restore mechanism using remove functions.
src/store/modules/permission-fe.ts Rewrites FE permission filtering based on roleCode and dynamic route registration/restoration.
src/router/modules/homepage.ts Moves root redirect into homepage module.
src/router/index.ts Initializes router with default routes only and exposes whitelist paths.
src/permission.ts Updates navigation guard to build routes once per session and use new whitelist/restore logic.
src/layouts/components/MenuContent.vue Tightens menu filter to require a title and improves default prop typing.

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

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.

1 participant