|
|
|
@ -1,6 +1,7 @@
|
|
|
|
import React from 'react';
|
|
|
|
import React from 'react';
|
|
|
|
import styles from '@/pages/flowEditor/node/style/base.module.less';
|
|
|
|
import styles from '@/pages/flowEditor/node/style/base.module.less';
|
|
|
|
import { Handle, Position } from '@xyflow/react';
|
|
|
|
import { Handle, Position } from '@xyflow/react';
|
|
|
|
|
|
|
|
import { Divider } from '@arco-design/web-react';
|
|
|
|
|
|
|
|
|
|
|
|
interface NodeContentData {
|
|
|
|
interface NodeContentData {
|
|
|
|
parameters?: {
|
|
|
|
parameters?: {
|
|
|
|
@ -13,6 +14,104 @@ interface NodeContentData {
|
|
|
|
[key: string]: any;
|
|
|
|
[key: string]: any;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染特殊节点(开始/结束节点)的句柄
|
|
|
|
|
|
|
|
const renderSpecialNodeHandles = (isStartNode: boolean, isEndNode: boolean, inputs: any[], outputs: any[]) => {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
type={isStartNode ? 'source' : 'target'}
|
|
|
|
|
|
|
|
position={isStartNode ? Position.Right : Position.Left}
|
|
|
|
|
|
|
|
id={isStartNode ? 'start-source' : 'end-target'}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: '40px'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* 为特殊节点的参数也添加句柄 */}
|
|
|
|
|
|
|
|
{isStartNode && outputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`output-handle-${index}`}
|
|
|
|
|
|
|
|
type="source"
|
|
|
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
|
|
|
id={outputs[index].name || `output-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${60 + index * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{isEndNode && inputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`input-handle-${index}`}
|
|
|
|
|
|
|
|
type="target"
|
|
|
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
|
|
|
id={inputs[index].name || `input-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${60 + index * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 渲染普通节点的句柄
|
|
|
|
|
|
|
|
const renderRegularNodeHandles = (inputs: any[], outputs: any[]) => {
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
type="source"
|
|
|
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
|
|
|
id="start-source"
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: '40px'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
type="target"
|
|
|
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
|
|
|
id="end-target"
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: '40px'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* 输入参数连接端点 */}
|
|
|
|
|
|
|
|
{inputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`input-handle-${index}`}
|
|
|
|
|
|
|
|
type="target"
|
|
|
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
|
|
|
id={inputs[index].name || `input-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${40 + (index + 1) * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* 输出参数连接端点 */}
|
|
|
|
|
|
|
|
{outputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`output-handle-${index}`}
|
|
|
|
|
|
|
|
type="source"
|
|
|
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
|
|
|
id={outputs[index].name || `output-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${40 + (index + 1) * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const NodeContent = ({ data }: { data: NodeContentData }) => {
|
|
|
|
const NodeContent = ({ data }: { data: NodeContentData }) => {
|
|
|
|
const inputs = data.parameters?.inputs || [];
|
|
|
|
const inputs = data.parameters?.inputs || [];
|
|
|
|
const outputs = data.parameters?.outputs || [];
|
|
|
|
const outputs = data.parameters?.outputs || [];
|
|
|
|
@ -55,78 +154,10 @@ const NodeContent = ({ data }: { data: NodeContentData }) => {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
|
|
{/* 流程传输(开始/结束)只在一侧显示端点 */}
|
|
|
|
{/* 根据节点类型渲染不同的句柄 */}
|
|
|
|
{isSpecialNode ? (
|
|
|
|
{isSpecialNode
|
|
|
|
<>
|
|
|
|
? renderSpecialNodeHandles(isStartNode, isEndNode, inputs, outputs)
|
|
|
|
<Handle
|
|
|
|
: renderRegularNodeHandles(inputs, outputs)}
|
|
|
|
type={isStartNode ? 'source' : 'target'}
|
|
|
|
|
|
|
|
position={isStartNode ? Position.Right : Position.Left}
|
|
|
|
|
|
|
|
id={isStartNode ? 'start-source' : 'end-target'}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: '40px'
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* 为流程传输的参数也添加句柄 */}
|
|
|
|
|
|
|
|
{isStartNode && outputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`output-handle-${index}`}
|
|
|
|
|
|
|
|
type="source"
|
|
|
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
|
|
|
id={outputs[index].name || `output-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${60 + index * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{isEndNode && inputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`input-handle-${index}`}
|
|
|
|
|
|
|
|
type="target"
|
|
|
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
|
|
|
id={inputs[index].name || `input-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${60 + index * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
) : (
|
|
|
|
|
|
|
|
/* 普通节点可以在两侧显示多个端点 */
|
|
|
|
|
|
|
|
<>
|
|
|
|
|
|
|
|
{/* 输入参数连接端点 */}
|
|
|
|
|
|
|
|
{inputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`input-handle-${index}`}
|
|
|
|
|
|
|
|
type="target"
|
|
|
|
|
|
|
|
position={Position.Left}
|
|
|
|
|
|
|
|
id={inputs[index].name || `input-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${40 + index * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{/* 输出参数连接端点 */}
|
|
|
|
|
|
|
|
{outputs.map((_, index) => (
|
|
|
|
|
|
|
|
<Handle
|
|
|
|
|
|
|
|
key={`output-handle-${index}`}
|
|
|
|
|
|
|
|
type="source"
|
|
|
|
|
|
|
|
position={Position.Right}
|
|
|
|
|
|
|
|
id={outputs[index].name || `output-${index}`}
|
|
|
|
|
|
|
|
style={{
|
|
|
|
|
|
|
|
background: '#555',
|
|
|
|
|
|
|
|
top: `${40 + index * 20}px`
|
|
|
|
|
|
|
|
}}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
))}
|
|
|
|
|
|
|
|
</>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|