Skip to content
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

feat(routes): 优化父级路由的显示隐藏逻辑,自动隐藏无可见子项的父级菜单 #982

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

drizzlesconsin
Copy link
Contributor

🚀 功能描述

优化了父级路由的显示/隐藏逻辑,当父级路由下所有可见的子节点都被隐藏时(hideInMenu: true),自动隐藏父级菜单项,避免出现空的父级菜单。

💡 实现方案

  1. traverseModifyRoutes 函数中增加对子节点可见性的判断:

    // 父节点显示/隐藏逻辑:
    // 1. 遍历所有子节点,找出未设置 hideInMenu 的节点(即可见节点)
    // 2. 如果没有任何可见子节点,则隐藏父节点
    const hasVisibleChildren = 
      Array.isArray(finallyChildList) && 
      finallyChildList.some((route) => !route.hideInMenu);
    
    if (!hasVisibleChildren) {
      currentRoute.hideInMenu = true;
    }
  2. 添加测试用例验证新逻辑的正确性

🧪 测试用例

it('should hide parent route when all visible children are hidden', () => {
  // ... test case code ...
});

📝 变更影响

  • 当父级路由的所有子节点都设置了 hideInMenu: true 时,父级路由会自动隐藏
  • 不影响现有的权限控制逻辑
  • 不影响已有的路由配置

✅ Checklist

  • 代码实现
  • 添加测试
  • 本地测试通过

- 当所有可见子节点都被隐藏时(hideInMenu: true),自动隐藏父节点
- 避免出现空的父级菜单项
- 添加相关测试用例验证新逻辑
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