移除菜单中不应该显示的按钮
This commit is contained in:
parent
a28016b14f
commit
b79c3ad903
@ -58,10 +58,27 @@ public class SysMenuService : IDynamicApiController, ITransient
|
||||
(u.Type != MenuTypeEnum.Btn || menuIdList.Contains(u.Id)))
|
||||
.OrderBy(u => new { u.OrderNo, u.Id })
|
||||
.Distinct().ToTreeAsync(u => u.Children, u => u.Pid, 0, menuIdList.Select(d => (object)d).ToArray());
|
||||
DeleteBtnFromMenuTree(menuTree);
|
||||
return menuTree.Adapt<List<MenuOutput>>();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除登录菜单树里面的按钮
|
||||
/// </summary>
|
||||
private static void DeleteBtnFromMenuTree(List<SysMenu> menuList)
|
||||
{
|
||||
if (menuList == null) return;
|
||||
for (var i = menuList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
var menu = menuList[i];
|
||||
if (menu.Type == MenuTypeEnum.Btn)
|
||||
menuList.Remove(menu);
|
||||
else if (menu.Children.Count > 0)
|
||||
DeleteBtnFromMenuTree(menu.Children);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单列表 🔖
|
||||
/// </summary>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user