|
|
|
|
@ -9,11 +9,7 @@ import NavBar from './navBar';
|
|
|
|
|
import ProjectContainer from '@/pages/orchestration/project';
|
|
|
|
|
import ApplicationContainer from '@/pages/orchestration/application';
|
|
|
|
|
import { menuData, menuData2 } from './config/menuData';
|
|
|
|
|
|
|
|
|
|
interface Selected {
|
|
|
|
|
currentPath?: string;
|
|
|
|
|
currentKey?: string;
|
|
|
|
|
}
|
|
|
|
|
import { Selected } from '@/pages/ideContainer/types';
|
|
|
|
|
|
|
|
|
|
type UrlParamsOptions = {
|
|
|
|
|
identity?: string;
|
|
|
|
|
@ -50,12 +46,12 @@ function IDEContainer() {
|
|
|
|
|
setUrlParams(getUrlParams(window.location.href) as UrlParamsOptions);
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
// 当selected.currentPath变化时,添加到已打开的tab集合中
|
|
|
|
|
// 当selected.path变化时,添加到已打开的tab集合中
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
if (selected.currentPath) {
|
|
|
|
|
setOpenedTabs(prev => new Set(prev).add(selected.currentPath!));
|
|
|
|
|
if (selected.path) {
|
|
|
|
|
setOpenedTabs(prev => new Set(prev).add(selected.path!));
|
|
|
|
|
}
|
|
|
|
|
}, [selected.currentPath]);
|
|
|
|
|
}, [selected.path]);
|
|
|
|
|
|
|
|
|
|
// 根据选中的菜单项渲染对应组件
|
|
|
|
|
const renderContent = () => {
|
|
|
|
|
@ -65,7 +61,7 @@ function IDEContainer() {
|
|
|
|
|
// 检查该路径的组件是否已打开
|
|
|
|
|
const isOpened = openedTabs.has(path);
|
|
|
|
|
// 检查是否是当前选中的路径
|
|
|
|
|
const isSelected = selected.currentPath === path;
|
|
|
|
|
const isSelected = selected.path === path;
|
|
|
|
|
|
|
|
|
|
// 只有已打开的组件才渲染,通过CSS控制显示/隐藏
|
|
|
|
|
return isOpened ? (
|
|
|
|
|
@ -82,7 +78,7 @@ function IDEContainer() {
|
|
|
|
|
})}
|
|
|
|
|
|
|
|
|
|
{/* 默认内容,当没有选中任何tab时显示 */}
|
|
|
|
|
{!selected.currentPath && (
|
|
|
|
|
{!selected.path && (
|
|
|
|
|
<div>点击左侧菜单选择需要查看的功能</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
@ -160,8 +156,8 @@ function IDEContainer() {
|
|
|
|
|
|
|
|
|
|
if (menuItem) {
|
|
|
|
|
setSelected({
|
|
|
|
|
currentPath: menuItem.path,
|
|
|
|
|
currentKey: menuItem.parentKey || menuItem.key
|
|
|
|
|
...menuItem,
|
|
|
|
|
key: menuItem.parentKey || menuItem.key
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -179,7 +175,7 @@ function IDEContainer() {
|
|
|
|
|
setOpenedTabs(newOpenedTabs);
|
|
|
|
|
|
|
|
|
|
// 如果关闭的是当前激活的tab,则重置selected状态
|
|
|
|
|
// if (path === selected.currentPath) {
|
|
|
|
|
// if (path === selected.path) {
|
|
|
|
|
// setSelected({});
|
|
|
|
|
// }
|
|
|
|
|
};
|
|
|
|
|
@ -189,7 +185,7 @@ function IDEContainer() {
|
|
|
|
|
<div className={styles.IDEContainer}>
|
|
|
|
|
<SideBar
|
|
|
|
|
onMenuSelect={(select) => setSelected(select)}
|
|
|
|
|
selectedKey={selected.currentKey}
|
|
|
|
|
selectedKey={selected.key}
|
|
|
|
|
identity={urlParams.identity}
|
|
|
|
|
/>
|
|
|
|
|
<div className={styles.content}>
|
|
|
|
|
|