|
|
|
@ -325,23 +325,6 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [menuData, identity]);
|
|
|
|
}, [menuData, identity]);
|
|
|
|
|
|
|
|
|
|
|
|
// 当 selected 变化时,检查是否需要更新子菜单数据
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
if (selected?.parentKey === 'appList' && selected?.id) {
|
|
|
|
|
|
|
|
// 检查当前菜单数据是否已加载
|
|
|
|
|
|
|
|
const currentMenu = menuData[identity] || [];
|
|
|
|
|
|
|
|
const appParent = currentMenu.find(item => item.key === 'appList');
|
|
|
|
|
|
|
|
if (appParent && appParent.children) {
|
|
|
|
|
|
|
|
const appItem = appParent.children.find((item: any) => item.id === selected.id);
|
|
|
|
|
|
|
|
if (appItem) {
|
|
|
|
|
|
|
|
// 如果应用项没有子菜单数据或者子菜单数据为空,则获取它
|
|
|
|
|
|
|
|
if (!appItem.children || appItem.children.length === 0) {
|
|
|
|
|
|
|
|
getProjectEnvData(selected);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, [selected, identity, menuData]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 根据搜索值过滤菜单数据
|
|
|
|
// 根据搜索值过滤菜单数据
|
|
|
|
const filteredMenu = useMemo(() => {
|
|
|
|
const filteredMenu = useMemo(() => {
|
|
|
|
@ -451,7 +434,6 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染子菜单
|
|
|
|
// 渲染子菜单
|
|
|
|
const renderMenuItems = (menuItems?: MenuItemType[], parentKey = '0') => {
|
|
|
|
const renderMenuItems = (menuItems?: MenuItemType[], parentKey = '0') => {
|
|
|
|
console.log('menuItems sidebar', menuItems);
|
|
|
|
|
|
|
|
if (menuItems && menuItems.length) {
|
|
|
|
if (menuItems && menuItems.length) {
|
|
|
|
return menuItems.map((item, index) => {
|
|
|
|
return menuItems.map((item, index) => {
|
|
|
|
const key = `${parentKey}-${index}`;
|
|
|
|
const key = `${parentKey}-${index}`;
|
|
|
|
@ -697,8 +679,6 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
style={{ background: 'transparent' }} // 移除背景色
|
|
|
|
style={{ background: 'transparent' }} // 移除背景色
|
|
|
|
renderExtra={selected?.parentKey === 'appList' ? renderNodeExtra : null}
|
|
|
|
renderExtra={selected?.parentKey === 'appList' ? renderNodeExtra : null}
|
|
|
|
// 当selected或activeKey变化时,强制Tree组件重新渲染
|
|
|
|
|
|
|
|
key={`tree-${activeKey}-${selected?.key || 'none'}`}
|
|
|
|
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{renderMenuItems(filteredMenu[activeKey]?.children)}
|
|
|
|
{renderMenuItems(filteredMenu[activeKey]?.children)}
|
|
|
|
</Tree>
|
|
|
|
</Tree>
|
|
|
|
|