diff --git a/src/components/sidebar/index.tsx b/src/components/sidebar/index.tsx
index 5f6a6a4..5474513 100644
--- a/src/components/sidebar/index.tsx
+++ b/src/components/sidebar/index.tsx
@@ -13,6 +13,46 @@ export const AppSidebar = () => {
return `/tool/${pathSegments.join("/")}`;
};
+ // 递归渲染子菜单内容
+ const renderSubMenuContent = (child: Tool, currentPaths: string[]): ReactNode => {
+ if (child.children) {
+ // 子菜单内的可折叠项
+ return (
+
+
+
+ {child.icon}
+ {child.name}
+
+
+
+
+
+ {child.children.map((subChild) => (
+
+ {renderSubMenuContent(subChild, [...currentPaths, child.path])}
+
+ ))}
+
+
+
+ );
+ }
+
+ // 叶子节点
+ return (
+
+
+ {child.icon}
+ {child.name}
+
+
+ );
+ };
+
// 递归渲染菜单项
const renderMenuItem = (tool: Tool, parentPaths: string[] = []): ReactNode => {
const currentPaths = [...parentPaths, tool.path];
@@ -20,12 +60,11 @@ export const AppSidebar = () => {
if (tool.children) {
// 有子菜单的项目
return (
-
-
+
+
{tool.icon}
@@ -37,25 +76,13 @@ export const AppSidebar = () => {
{tool.children.map((child) => (
- {child.children ? (
- renderMenuItem(child, currentPaths)
- ) : (
-
-
- {child.icon}
- {child.name}
-
-
- )}
+ {renderSubMenuContent(child, currentPaths)}
))}
-
-
+
+
);
}