From c072be8d2713c4a478ef0a8ffb1ea00521d6a8d4 Mon Sep 17 00:00:00 2001 From: ZLY Date: Tue, 26 Aug 2025 16:08:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(ideContainer):=20=E4=B8=BA=E8=8F=9C?= =?UTF-8?q?=E5=8D=95=E9=A1=B9=E6=B7=BB=E5=8A=A0=E5=94=AF=E4=B8=80=E9=94=AE?= =?UTF-8?q?=E5=80=BC=E5=B9=B6=E4=BC=98=E5=8C=96=E8=8F=9C=E5=8D=95=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 menuData 和 menuData2 中为每个菜单项添加了唯一的 key 属性 - 修改了侧边栏菜单的渲染逻辑,使用菜单项的 key作为唯一标识 - 优化了菜单选择时传递的 currentKey值,现在传递实际的菜单项 key --- src/pages/ideContainer/config/menuData.ts | 17 ++++++++++++----- src/pages/ideContainer/index.tsx | 2 +- src/pages/ideContainer/sideBar.tsx | 5 +++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/pages/ideContainer/config/menuData.ts b/src/pages/ideContainer/config/menuData.ts index e1f8679..83169d2 100644 --- a/src/pages/ideContainer/config/menuData.ts +++ b/src/pages/ideContainer/config/menuData.ts @@ -1,6 +1,7 @@ export const menuData = [ { title: '应用编排', + key: 'appFlow', children: null, path: 'appFlow' }, @@ -27,18 +28,21 @@ export const menuData = [ { title: '事件', children: null, - path: 'event' + path: 'event', + key: 'event' }, { title: '全局变量', children: null, - path: 'globalVar' + path: 'globalVar', + key: 'globalVar' } ]; export const menuData2 = [ { title: '组件列表', + key: 'componentList', children: [ { title: '我的组件', @@ -60,16 +64,19 @@ export const menuData2 = [ { title: '组件编码', children: null, - path: 'componentCoding' + path: 'componentCoding', + key: 'componentCoding' }, { title: '组件部署', children: null, - path: 'componentDeployment' + path: 'componentDeployment', + key: 'componentDeployment' }, { title: '组件测试', children: null, - path: 'componentTest' + path: 'componentTest', + key: 'componentTest' } ]; \ No newline at end of file diff --git a/src/pages/ideContainer/index.tsx b/src/pages/ideContainer/index.tsx index 526354f..2e461df 100644 --- a/src/pages/ideContainer/index.tsx +++ b/src/pages/ideContainer/index.tsx @@ -158,7 +158,7 @@ function IDEContainer() { if (menuItem) { setSelected({ currentPath: menuItem.path, - currentKey: '' // 这里可以优化为实际的key值 + currentKey: menuItem.key }); } } diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index 4b6e4ae..cc45a29 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -5,6 +5,7 @@ import { menuData, menuData2 } from './config/menuData'; interface MenuItemType { title: string; + key?: string; children?: MenuItemType[]; path?: string; icon?: React.ReactNode; @@ -42,9 +43,9 @@ const SideBar: React.FC = ({ onMenuSelect, selectedKey, identity } {menu.map((item, index) => (
{ - onMenuSelect?.({ currentPath: item.path, currentKey: `${index}` }); + onMenuSelect?.({ currentPath: item.path, currentKey: `${item.key}` }); }} >