仰望星辰工作室

fix(plugin): 插件菜单回归「插件」一级 → 分组二级 → 子页三级结构

Y yang1145 提交于 2026-07-19 01:35 · 803aff7 ·父提交 4e2d65d
fix(plugin): 插件菜单回归「插件」一级 → 分组二级 → 子页三级结构

MPHX/plugin.php
  - mnbt_plugin_render_menu_side_html() 始终输出「插件」顶级组
  - 有 children 的项作为二级 nav-item-has-subnav(图标仍可点击展开)
  - 叶子项作为二级直接链接
  - children 内项为三级
  - 移除之前按有无 children 分离为独立顶级组的逻辑
1 个文件变更 +6 -22 13172193298@163.com
•MPHX/plugin.php +6 -22
变更内容
diff --git a/MPHX/plugin.php b/MPHX/plugin.php
index d873fe5..cfe43c4 100644
--- a/MPHX/plugin.php
+++ b/MPHX/plugin.php
@@ -606,8 +606,7 @@ function _mnbt_plugin_render_menu_item($it, $depth = 0)
 	$icon  = htmlspecialchars($it['icon'] ?? 'mdi-puzzle', ENT_QUOTES, 'UTF-8');
 	if (!empty($it['children'])) {
 		$childrenHtml = _mnbt_plugin_render_menu_children($it['children'], $depth + 1);
-		$cls = $depth > 0 ? 'nav-item-has-subnav' : 'nav-item nav-item-has-subnav';
-		return '<li class="' . $cls . '">'
+		return '<li class="nav-item-has-subnav">'
 			. ' <a href="javascript:void(0)"><i class="mdi ' . $icon . '"></i> <span>' . $title . '</span></a>'
 			. '<ul class="nav nav-subnav">' . $childrenHtml . '</ul></li>';
 	}
@@ -635,29 +634,14 @@ function mnbt_plugin_render_menu_side_html($side)
 	if (!$items) {
 		return '';
 	}
-	$groups = [];
-	$flat   = [];
+	$inner = '';
 	foreach ($items as $it) {
-		if (!empty($it['children'])) {
-			$groups[] = $it;
-		} else {
-			$flat[] = $it;
-		}
-	}
-	$out = '';
-	// Groups (items with children) → top-level nav-item-has-subnav
-	foreach ($groups as $g) {
-		$out .= _mnbt_plugin_render_menu_item($g, 0);
+		$inner .= _mnbt_plugin_render_menu_item($it, 1);
 	}
-	// Flat items → legacy "插件" wrapper
-	if ($flat) {
-		$flatHtml = '';
-		foreach ($flat as $f) {
-			$flatHtml .= _mnbt_plugin_render_menu_item($f, 1);
-		}
-		$out .= '<li class="nav-item nav-item-has-subnav"> <a href="javascript:void(0)"> <i class="mdi mdi-puzzle"></i> <span>插件</span> </a><ul class="nav nav-subnav">' . $flatHtml . '</ul></li>';
+	if ($inner === '') {
+		return '';
 	}
-	return $out;
+	return '<li class="nav-item nav-item-has-subnav"> <a href="javascript:void(0)"> <i class="mdi mdi-puzzle"></i> <span>插件</span> </a><ul class="nav nav-subnav">' . $inner . '</ul></li>';
 }
 
 function mnbt_plugin_render_menu_admin_html()