|
@@ -155,30 +155,12 @@ public class MenuServiceImpl extends ServiceImpl<MenuMapper, Menu> implements Me
|
|
|
// 递归构建子节点
|
|
// 递归构建子节点
|
|
|
List<Map<String, Object>> childNodes = buildMenuTree(menu.getId(), allMenus);
|
|
List<Map<String, Object>> childNodes = buildMenuTree(menu.getId(), allMenus);
|
|
|
if (!childNodes.isEmpty()) {
|
|
if (!childNodes.isEmpty()) {
|
|
|
- // showParent为false且只有一个子节点时,提升子节点为一级菜单
|
|
|
|
|
- boolean showParent = menu.getShowParent() == null || menu.getShowParent();
|
|
|
|
|
- if (!showParent && childNodes.size() == 1) {
|
|
|
|
|
- Map<String, Object> childNode = childNodes.get(0);
|
|
|
|
|
- Map<String, Object> childMeta = (Map<String, Object>) childNode.get("meta");
|
|
|
|
|
- // 合并父级 icon(子级优先)
|
|
|
|
|
- if ((childMeta.get("icon") == null || childMeta.get("icon").toString().isEmpty())
|
|
|
|
|
- && menu.getIcon() != null && !menu.getIcon().isEmpty()) {
|
|
|
|
|
- childMeta.put("icon", menu.getIcon());
|
|
|
|
|
- }
|
|
|
|
|
- // 使用父级 title 覆盖子级(更概括)
|
|
|
|
|
- childMeta.put("title", menu.getTitle());
|
|
|
|
|
- // 继承父级 rank(子级优先)
|
|
|
|
|
- if (childMeta.get("rank") == null && menu.getRank() != null) {
|
|
|
|
|
- childMeta.put("rank", menu.getRank());
|
|
|
|
|
- }
|
|
|
|
|
- tree.add(childNode);
|
|
|
|
|
- } else {
|
|
|
|
|
- node.put("children", childNodes);
|
|
|
|
|
- if (menu.getRedirect() != null && !menu.getRedirect().isEmpty()) {
|
|
|
|
|
- node.put("redirect", menu.getRedirect());
|
|
|
|
|
- }
|
|
|
|
|
- tree.add(node);
|
|
|
|
|
|
|
+ // 保留完整的树结构,单子节点提升交给前端 SidebarItem 组件处理
|
|
|
|
|
+ node.put("children", childNodes);
|
|
|
|
|
+ if (menu.getRedirect() != null && !menu.getRedirect().isEmpty()) {
|
|
|
|
|
+ node.put("redirect", menu.getRedirect());
|
|
|
}
|
|
}
|
|
|
|
|
+ tree.add(node);
|
|
|
} else {
|
|
} else {
|
|
|
// 叶子节点需要 component
|
|
// 叶子节点需要 component
|
|
|
if (menu.getComponent() != null && !menu.getComponent().isEmpty()) {
|
|
if (menu.getComponent() != null && !menu.getComponent().isEmpty()) {
|