From cc31d303d12f9c7cd2c4574351b67db04069ae0d Mon Sep 17 00:00:00 2001
From: hejianhao <15708179461@qq.com>
Date: 星期五, 28 八月 2026 15:46:30 +0800
Subject: [PATCH] 828优化功能新需求

---
 tcm-training-admin/src/app.tsx |   13 ++++++++++++-
 1 files changed, 12 insertions(+), 1 deletions(-)

diff --git a/tcm-training-admin/src/app.tsx b/tcm-training-admin/src/app.tsx
index f0c27c3..f60de8d 100644
--- a/tcm-training-admin/src/app.tsx
+++ b/tcm-training-admin/src/app.tsx
@@ -1,4 +1,4 @@
-import type { Settings as LayoutSettings } from '@ant-design/pro-components';
+import type { MenuDataItem, Settings as LayoutSettings } from '@ant-design/pro-components';
 import { SettingDrawer } from '@ant-design/pro-components';
 import type { RunTimeLayoutConfig } from '@umijs/max';
 import { history } from '@umijs/max';
@@ -26,6 +26,16 @@
   loading?: boolean;
 };
 
+const ensureMenuKeys = (menuData: MenuDataItem[], parentKey = 'menu'): MenuDataItem[] =>
+  menuData.map((item, index) => {
+    const key = item.key || item.path || `${parentKey}-${String(item.name || index)}`;
+
+    return {
+      ...item,
+      key,
+      children: item.children ? ensureMenuKeys(item.children, String(key)) : item.children,
+    };
+  });
 
 /**
  * @see  https://umijs.org/zh-CN/plugins/plugin-initial-state
@@ -79,6 +89,7 @@
       );
     },
     ...initialState?.settings,
+    menuDataRender: ensureMenuKeys,
     pageTitleRender: () => '管理后台',
   };
 };

--
Gitblit v1.7.1