diff --git a/src/pages/ideContainer/sideBar.tsx b/src/pages/ideContainer/sideBar.tsx index 9851514..441e776 100644 --- a/src/pages/ideContainer/sideBar.tsx +++ b/src/pages/ideContainer/sideBar.tsx @@ -183,30 +183,39 @@ const SideBar: React.FC = ({ case 'scene': const menuData = _.cloneDeep(menuData1); const newSubMenuData = _.cloneDeep(subMenuData); - const subMenuKey = Object.keys(newSubMenuData)[0]; - const subMenuValue: any = Object.values(newSubMenuData)[0]; - const menuIndex = menuData.findIndex(v => v.key === subMenuKey); - // 构建数据结构,这是目录默认需要的数据结构 - subMenuValue.forEach(v => { - v.title = v.name; - v.key = `compFlow-${v.id}`; - v.path = 'compFlow'; - v.parentKey = subMenuKey; - v.icon = '/ideContainer/icon/app.png'; - v.children = [ - { - title: '事件', - children: null, - icon: '/ideContainer/icon/list.png' - }, - { - title: '组件列表', - children: null, - icon: '/ideContainer/icon/list.png' - } - ]; + + // 遍历所有 subMenuKey 来构建子菜单数据结构 + Object.keys(newSubMenuData).forEach(subMenuKey => { + const subMenuValue: any = _.cloneDeep(newSubMenuData[subMenuKey]); + const menuIndex = menuData.findIndex(v => v.key === subMenuKey); + + if (menuIndex !== -1) { + // 构建数据结构,这是目录默认需要的数据结构 + subMenuValue.forEach(v => { + v.title = v.name; + v.key = `compFlow-${v.id}`; + v.path = 'compFlow'; + v.parentKey = subMenuKey; + v.icon = '/ideContainer/icon/app.png'; + if (subMenuKey !== 'appFlow') { + v.children = [ + { + title: '事件', + children: null, + icon: '/ideContainer/icon/list.png' + }, + { + title: '组件列表', + children: null, + icon: '/ideContainer/icon/list.png' + } + ]; + } + }); + menuData[menuIndex]['children'] = subMenuValue; + } }); - menuData[menuIndex]['children'] = subMenuValue; + dispatch(updateMenuData({ 'scene': menuData })); return menuData; case 'componentDevelopment' : @@ -256,7 +265,6 @@ const SideBar: React.FC = ({ const parentKey = menu[activeKey]?.key; const currentMenu = _.cloneDeep(menuData[identity]); const index = currentMenu.findIndex(v => v.key === parentKey); - // const res: any = await getProjectEnv(data.id); const res: any = await getAppInfoNew(data.id); if (res.code === 200) { const children = currentMenu[index].children.find(v => v.id === data.id); @@ -483,13 +491,15 @@ const SideBar: React.FC = ({ onSelect={async (_selectedKeys, info) => { const selectedNode = info.node; const originalData = selectedNode.props.dataRef; - await getProjectEnvData(originalData); + if (selected?.parentKey === 'appList') { + await getProjectEnvData(originalData); - // 调用外部传入的菜单选择处理函数 - originalData.key && onMenuSelect?.({ ...originalData } as Selected); + // 调用外部传入的菜单选择处理函数 + originalData.key && onMenuSelect?.({ ...originalData } as Selected); + } }} style={{ background: 'transparent' }} // 移除背景色 - renderExtra={renderNodeExtra} + renderExtra={selected?.parentKey === 'appList' ? renderNodeExtra : null} > {renderMenuItems(menu[activeKey]?.children)}