|
|
|
@ -194,9 +194,6 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
? appRuntimeData[currentAppKey].isRunning
|
|
|
|
? appRuntimeData[currentAppKey].isRunning
|
|
|
|
: false;
|
|
|
|
: false;
|
|
|
|
|
|
|
|
|
|
|
|
// 在应用编排模式下(useDefault为false)禁用删除功能
|
|
|
|
|
|
|
|
const isDeleteDisabled = currentAppIsRunning;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 监听自定义事件以隐藏/显示节点
|
|
|
|
// 监听自定义事件以隐藏/显示节点
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
const handleToggleNodeVisibility = (event: CustomEvent) => {
|
|
|
|
const handleToggleNodeVisibility = (event: CustomEvent) => {
|
|
|
|
@ -334,6 +331,10 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
document.dispatchEvent(event);
|
|
|
|
document.dispatchEvent(event);
|
|
|
|
}, [nodes, edges]);
|
|
|
|
}, [nodes, edges]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
console.log(useDefault, menu);
|
|
|
|
|
|
|
|
}, [useDefault, menu]);
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div ref={reactFlowWrapper} style={{ width: '100%', height: '100%', position: 'relative' }}
|
|
|
|
<div ref={reactFlowWrapper} style={{ width: '100%', height: '100%', position: 'relative' }}
|
|
|
|
onContextMenu={(e) => e.preventDefault()}
|
|
|
|
onContextMenu={(e) => e.preventDefault()}
|
|
|
|
@ -388,7 +389,7 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
proOptions={{ hideAttribution: true }} // 隐藏水印
|
|
|
|
proOptions={{ hideAttribution: true }} // 隐藏水印
|
|
|
|
nodesConnectable={!currentAppIsRunning} // 运行时禁用节点连接
|
|
|
|
nodesConnectable={!currentAppIsRunning} // 运行时禁用节点连接
|
|
|
|
nodesDraggable={!currentAppIsRunning} // 运行时禁用节点拖拽
|
|
|
|
nodesDraggable={!currentAppIsRunning} // 运行时禁用节点拖拽
|
|
|
|
elementsSelectable={!currentAppIsRunning} // 运行时禁用元素选择
|
|
|
|
// elementsSelectable={!currentAppIsRunning} // 运行时禁用元素选择
|
|
|
|
connectOnClick={!currentAppIsRunning} // 运行时禁用点击连接
|
|
|
|
connectOnClick={!currentAppIsRunning} // 运行时禁用点击连接
|
|
|
|
disableKeyboardA11y={currentAppIsRunning} // 运行时禁用键盘交互
|
|
|
|
disableKeyboardA11y={currentAppIsRunning} // 运行时禁用键盘交互
|
|
|
|
onBeforeDelete={async ({ nodes, edges }) => {
|
|
|
|
onBeforeDelete={async ({ nodes, edges }) => {
|
|
|
|
@ -497,10 +498,10 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
connectionLineType={ConnectionLineType.SmoothStep}
|
|
|
|
connectionLineType={ConnectionLineType.SmoothStep}
|
|
|
|
connectionLineComponent={CustomConnectionLine}
|
|
|
|
connectionLineComponent={CustomConnectionLine}
|
|
|
|
onNodeDragStop={!currentAppIsRunning ? onNodeDragStop : undefined} // 运行时禁用节点拖拽停止
|
|
|
|
onNodeDragStop={!currentAppIsRunning ? onNodeDragStop : undefined} // 运行时禁用节点拖拽停止
|
|
|
|
onNodeContextMenu={(!currentAppIsRunning && useDefault) ? onNodeContextMenu : undefined} // 运行时或应用编排模式下禁用节点上下文菜单
|
|
|
|
onNodeContextMenu={(useDefault || currentAppIsRunning) ? onNodeContextMenu : undefined} // 应用编排模式下禁用节点上下文菜单,运行时仍可使用
|
|
|
|
onNodeDoubleClick={!currentAppIsRunning ? onNodeDoubleClick : undefined} // 运行时禁用节点双击
|
|
|
|
onNodeDoubleClick={!currentAppIsRunning ? onNodeDoubleClick : undefined} // 运行时禁用节点双击
|
|
|
|
onEdgeContextMenu={(!currentAppIsRunning && useDefault) ? onEdgeContextMenu : undefined} // 运行时或应用编排模式下禁用边上下文菜单
|
|
|
|
onEdgeContextMenu={(!currentAppIsRunning && useDefault) ? onEdgeContextMenu : undefined} // 运行时或应用编排模式下禁用边上下文菜单
|
|
|
|
onPaneClick={!currentAppIsRunning ? onPaneClick : undefined} // 运行时禁用面板点击
|
|
|
|
onPaneClick={(useDefault || currentAppIsRunning) ? onPaneClick : undefined} // 运行时禁用面板点击
|
|
|
|
onPaneContextMenu={(!currentAppIsRunning && useDefault) ? onPaneContextMenu : undefined} // 运行时或应用编排模式下禁用面板上下文菜单
|
|
|
|
onPaneContextMenu={(!currentAppIsRunning && useDefault) ? onPaneContextMenu : undefined} // 运行时或应用编排模式下禁用面板上下文菜单
|
|
|
|
onEdgeMouseEnter={(_event, edge) => {
|
|
|
|
onEdgeMouseEnter={(_event, edge) => {
|
|
|
|
setEdges((eds) => eds.map(e => {
|
|
|
|
setEdges((eds) => eds.map(e => {
|
|
|
|
@ -544,8 +545,8 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
<AlignmentGuides />
|
|
|
|
<AlignmentGuides />
|
|
|
|
</ReactFlow>
|
|
|
|
</ReactFlow>
|
|
|
|
|
|
|
|
|
|
|
|
{/*节点右键上下文 - 仅在默认模式且非运行时显示*/}
|
|
|
|
{/*节点右键上下文 - 在默认模式或运行状态下显示,运行时隐藏编辑复制删除功能*/}
|
|
|
|
{!currentAppIsRunning && useDefault && menu && menu.type === 'node' && (
|
|
|
|
{(useDefault || currentAppIsRunning) && menu && menu.type === 'node' && (
|
|
|
|
<div
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
position: 'absolute',
|
|
|
|
@ -561,6 +562,7 @@ const FlowEditorMain: React.FC<FlowEditorMainProps> = (props) => {
|
|
|
|
onCopy={copyNode}
|
|
|
|
onCopy={copyNode}
|
|
|
|
onCloseMenu={setMenu}
|
|
|
|
onCloseMenu={setMenu}
|
|
|
|
onCloseOpenModal={setIsEditModalOpen}
|
|
|
|
onCloseOpenModal={setIsEditModalOpen}
|
|
|
|
|
|
|
|
isRunning={currentAppIsRunning}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|