|
|
|
@ -12,9 +12,17 @@ import {
|
|
|
|
Menu,
|
|
|
|
Menu,
|
|
|
|
Popconfirm
|
|
|
|
Popconfirm
|
|
|
|
} from '@arco-design/web-react';
|
|
|
|
} from '@arco-design/web-react';
|
|
|
|
import { IconApps, IconMore, IconDelete, IconEdit } from '@arco-design/web-react/icon';
|
|
|
|
import {
|
|
|
|
|
|
|
|
IconApps,
|
|
|
|
|
|
|
|
IconMore,
|
|
|
|
|
|
|
|
IconDelete,
|
|
|
|
|
|
|
|
IconEdit,
|
|
|
|
|
|
|
|
IconEye,
|
|
|
|
|
|
|
|
IconSearch,
|
|
|
|
|
|
|
|
IconPlus,
|
|
|
|
|
|
|
|
IconEyeInvisible
|
|
|
|
|
|
|
|
} from '@arco-design/web-react/icon';
|
|
|
|
import { menuData1, menuData2 } from './config/menuData';
|
|
|
|
import { menuData1, menuData2 } from './config/menuData';
|
|
|
|
import { IconSearch, IconPlus } from '@arco-design/web-react/icon';
|
|
|
|
|
|
|
|
import { Selected } from '@/pages/ideContainer/types';
|
|
|
|
import { Selected } from '@/pages/ideContainer/types';
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
import { useDispatch, useSelector } from 'react-redux';
|
|
|
|
import {
|
|
|
|
import {
|
|
|
|
@ -197,6 +205,8 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
y: 0,
|
|
|
|
y: 0,
|
|
|
|
nodeData: null
|
|
|
|
nodeData: null
|
|
|
|
}); // 添加右键菜单状态
|
|
|
|
}); // 添加右键菜单状态
|
|
|
|
|
|
|
|
// 用于存储隐藏的节点ID
|
|
|
|
|
|
|
|
const [hiddenNodes, setHiddenNodes] = useState<Set<string>>(new Set());
|
|
|
|
const resizeBoxRef = useRef<HTMLDivElement>(null); // 引用第一个 ResizeBox 容器
|
|
|
|
const resizeBoxRef = useRef<HTMLDivElement>(null); // 引用第一个 ResizeBox 容器
|
|
|
|
const contextMenuRef = useRef<HTMLDivElement>(null); // 右键菜单引用
|
|
|
|
const contextMenuRef = useRef<HTMLDivElement>(null); // 右键菜单引用
|
|
|
|
const { menuData, info, canvasDataMap } = useSelector(state => state.ideContainer);
|
|
|
|
const { menuData, info, canvasDataMap } = useSelector(state => state.ideContainer);
|
|
|
|
@ -551,12 +561,35 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 监听自定义事件以更新隐藏节点状态
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
const handleToggleNodeVisibility = (event: CustomEvent) => {
|
|
|
|
|
|
|
|
const { appId, isVisible } = event.detail;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (isVisible) {
|
|
|
|
|
|
|
|
// 显示节点 - 从隐藏节点集合中移除
|
|
|
|
|
|
|
|
setHiddenNodes(prev => {
|
|
|
|
|
|
|
|
const newSet = new Set(prev);
|
|
|
|
|
|
|
|
newSet.delete(appId);
|
|
|
|
|
|
|
|
return newSet;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// 隐藏节点 - 添加到隐藏节点集合
|
|
|
|
|
|
|
|
setHiddenNodes(prev => new Set(prev).add(appId));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
document.addEventListener('toggleNodeVisibility', handleToggleNodeVisibility as EventListener);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
|
|
|
|
document.removeEventListener('toggleNodeVisibility', handleToggleNodeVisibility as EventListener);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染节点的额外操作按钮
|
|
|
|
// 渲染节点的额外操作按钮
|
|
|
|
const renderNodeExtra = (node) => {
|
|
|
|
const renderNodeExtra = (node) => {
|
|
|
|
// 只有当 node.dataRef.id 存在时才渲染操作按钮
|
|
|
|
// 只有当 node.dataRef.id 存在时才渲染操作按钮
|
|
|
|
if (!node.dataRef?.id) {
|
|
|
|
if (!node.dataRef?.id) return null;
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dropList = (
|
|
|
|
const dropList = (
|
|
|
|
<Menu>
|
|
|
|
<Menu>
|
|
|
|
@ -622,6 +655,44 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const renderNodeExtraEye = (node) => {
|
|
|
|
|
|
|
|
// console.log('node:', node);
|
|
|
|
|
|
|
|
// 只有当 node.dataRef.id 存在时才渲染操作按钮
|
|
|
|
|
|
|
|
if (!node.dataRef?.id) return null;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 检查节点当前是否被隐藏
|
|
|
|
|
|
|
|
const isNodeHidden = hiddenNodes?.has(node.dataRef.id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function handleEyeClick(e) {
|
|
|
|
|
|
|
|
e.stopPropagation();
|
|
|
|
|
|
|
|
// 发送自定义事件,通知流程图组件隐藏/显示节点
|
|
|
|
|
|
|
|
const event = new CustomEvent('toggleNodeVisibility', {
|
|
|
|
|
|
|
|
detail: {
|
|
|
|
|
|
|
|
appId: node.dataRef.id,
|
|
|
|
|
|
|
|
isVisible: isNodeHidden // 如果当前是隐藏的,点击后应该显示
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
document.dispatchEvent(event);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
|
|
|
right: 8,
|
|
|
|
|
|
|
|
fontSize: 20,
|
|
|
|
|
|
|
|
fontWeight: 700,
|
|
|
|
|
|
|
|
top: 10,
|
|
|
|
|
|
|
|
color: '#000000',
|
|
|
|
|
|
|
|
cursor: 'pointer'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
onClick={handleEyeClick}
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{isNodeHidden ? <IconEye /> : <IconEyeInvisible />}
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
className={styles['sider']}
|
|
|
|
className={styles['sider']}
|
|
|
|
@ -699,7 +770,7 @@ const SideBar: React.FC<SideBarProps> = ({
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}}
|
|
|
|
}}
|
|
|
|
style={{ background: 'transparent' }} // 移除背景色
|
|
|
|
style={{ background: 'transparent' }} // 移除背景色
|
|
|
|
renderExtra={selected?.parentKey === 'appList' ? renderNodeExtra : null}
|
|
|
|
renderExtra={selected?.parentKey === 'appList' ? renderNodeExtra : renderNodeExtraEye}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{renderMenuItems(filteredMenu[activeKey]?.children)}
|
|
|
|
{renderMenuItems(filteredMenu[activeKey]?.children)}
|
|
|
|
</Tree>
|
|
|
|
</Tree>
|
|
|
|
|