|
|
|
|
@ -145,6 +145,9 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
? appRuntimeData[currentAppData.id].isRunning
|
|
|
|
|
: false;
|
|
|
|
|
|
|
|
|
|
// 在应用编排模式下(useDefault为false)禁用删除功能
|
|
|
|
|
const isDeleteDisabled = !useDefault || currentAppIsRunning;
|
|
|
|
|
|
|
|
|
|
// 监听键盘事件实现快捷键
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
const handleKeyDown = (e: KeyboardEvent) => {
|
|
|
|
|
@ -210,9 +213,14 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 允许删除操作继续进行
|
|
|
|
|
return !currentAppIsRunning; // 运行时禁止删除节点
|
|
|
|
|
return !isDeleteDisabled; // 在应用编排模式或运行时禁止删除节点
|
|
|
|
|
}}
|
|
|
|
|
onNodesDelete={(deleted) => {
|
|
|
|
|
// 如果在应用编排模式或运行时,禁止删除
|
|
|
|
|
if (isDeleteDisabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 检查是否有循环节点
|
|
|
|
|
const loopNodes = deleted.filter(node =>
|
|
|
|
|
node.data?.type === 'LOOP_START' || node.data?.type === 'LOOP_END'
|
|
|
|
|
@ -279,11 +287,11 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
connectionLineType={ConnectionLineType.SmoothStep}
|
|
|
|
|
connectionLineComponent={CustomConnectionLine}
|
|
|
|
|
onNodeDragStop={!currentAppIsRunning ? onNodeDragStop : undefined} // 运行时禁用节点拖拽停止
|
|
|
|
|
onNodeContextMenu={!currentAppIsRunning ? onNodeContextMenu : undefined} // 运行时禁用节点上下文菜单
|
|
|
|
|
onNodeContextMenu={(!currentAppIsRunning && useDefault) ? onNodeContextMenu : undefined} // 运行时或应用编排模式下禁用节点上下文菜单
|
|
|
|
|
onNodeDoubleClick={!currentAppIsRunning ? onNodeDoubleClick : undefined} // 运行时禁用节点双击
|
|
|
|
|
onEdgeContextMenu={!currentAppIsRunning ? onEdgeContextMenu : undefined} // 运行时禁用边上下文菜单
|
|
|
|
|
onEdgeContextMenu={(!currentAppIsRunning && useDefault) ? onEdgeContextMenu : undefined} // 运行时或应用编排模式下禁用边上下文菜单
|
|
|
|
|
onPaneClick={!currentAppIsRunning ? onPaneClick : undefined} // 运行时禁用面板点击
|
|
|
|
|
onPaneContextMenu={!currentAppIsRunning ? onPaneContextMenu : undefined} // 运行时禁用面板上下文菜单
|
|
|
|
|
onPaneContextMenu={(!currentAppIsRunning && useDefault) ? onPaneContextMenu : undefined} // 运行时或应用编排模式下禁用面板上下文菜单
|
|
|
|
|
onEdgeMouseEnter={(_event, edge) => {
|
|
|
|
|
setEdges((eds) => eds.map(e => {
|
|
|
|
|
if (e.id === edge.id) {
|
|
|
|
|
@ -320,8 +328,8 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
<AlignmentGuides />
|
|
|
|
|
</ReactFlow>
|
|
|
|
|
|
|
|
|
|
{/*节点右键上下文*/}
|
|
|
|
|
{!currentAppIsRunning && menu && menu.type === 'node' && (
|
|
|
|
|
{/*节点右键上下文 - 仅在默认模式且非运行时显示*/}
|
|
|
|
|
{!currentAppIsRunning && useDefault && menu && menu.type === 'node' && (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
@ -341,8 +349,8 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/*边右键上下文*/}
|
|
|
|
|
{!currentAppIsRunning && menu && menu.type === 'edge' && (
|
|
|
|
|
{/*边右键上下文 - 仅在默认模式且非运行时显示*/}
|
|
|
|
|
{!currentAppIsRunning && useDefault && menu && menu.type === 'edge' && (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
@ -364,8 +372,8 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/*画布右键上下文*/}
|
|
|
|
|
{!currentAppIsRunning && menu && menu.type === 'pane' && (
|
|
|
|
|
{/*画布右键上下文 - 仅在默认模式且非运行时显示*/}
|
|
|
|
|
{!currentAppIsRunning && useDefault && menu && menu.type === 'pane' && (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
@ -395,8 +403,8 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
|
onClose={closeEditModal}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/*统一的添加节点菜单*/}
|
|
|
|
|
{!currentAppIsRunning && (edgeForNodeAdd || positionForNodeAdd) && (
|
|
|
|
|
{/*统一的添加节点菜单 - 仅在默认模式且非运行时显示*/}
|
|
|
|
|
{!currentAppIsRunning && useDefault && (edgeForNodeAdd || positionForNodeAdd) && (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'absolute',
|
|
|
|
|
|