parent
88a43e8e02
commit
afa5de1030
@ -0,0 +1,30 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Handle, Position } from '@xyflow/react';
|
||||||
|
|
||||||
|
const DraggableNode = ({ data }: { data: any }) => {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
padding: '10px 20px',
|
||||||
|
backgroundColor: '#1890ff',
|
||||||
|
borderRadius: '5px',
|
||||||
|
color: 'white',
|
||||||
|
fontWeight: 'bold'
|
||||||
|
}}>
|
||||||
|
<div>{data.label || '任务节点'}</div>
|
||||||
|
<Handle
|
||||||
|
type="target"
|
||||||
|
position={Position.Left}
|
||||||
|
id="task-target"
|
||||||
|
style={{ background: '#555' }}
|
||||||
|
/>
|
||||||
|
<Handle
|
||||||
|
type="source"
|
||||||
|
position={Position.Right}
|
||||||
|
id="task-source"
|
||||||
|
style={{ background: '#555' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default DraggableNode;
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Handle, Position } from '@xyflow/react';
|
||||||
|
|
||||||
|
const EndNode = ({ data }: { data: any }) => {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
padding: '10px 20px',
|
||||||
|
backgroundColor: '#ff4d4f',
|
||||||
|
borderRadius: '5px',
|
||||||
|
color: 'white',
|
||||||
|
fontWeight: 'bold'
|
||||||
|
}}>
|
||||||
|
<div>结束</div>
|
||||||
|
<Handle
|
||||||
|
type="target"
|
||||||
|
position={Position.Left}
|
||||||
|
id="end-target"
|
||||||
|
style={{ background: '#555' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default EndNode;
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Handle, Position } from '@xyflow/react';
|
||||||
|
|
||||||
|
const StartNode = ({ data }: { data: any }) => {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
padding: '10px 20px',
|
||||||
|
backgroundColor: '#52c41a',
|
||||||
|
borderRadius: '5px',
|
||||||
|
color: 'white',
|
||||||
|
fontWeight: 'bold'
|
||||||
|
}}>
|
||||||
|
<div>开始</div>
|
||||||
|
<Handle
|
||||||
|
type="source"
|
||||||
|
position={Position.Right}
|
||||||
|
id="start-source"
|
||||||
|
style={{ background: '#555' }}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StartNode;
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import { Card } from '@arco-design/web-react';
|
||||||
|
|
||||||
|
const onDragStart = (event: React.DragEvent, nodeType: string) => {
|
||||||
|
event.dataTransfer.setData('application/reactflow', nodeType);
|
||||||
|
event.dataTransfer.effectAllowed = 'move';
|
||||||
|
};
|
||||||
|
|
||||||
|
const SideBar: React.FC = () => {
|
||||||
|
return (
|
||||||
|
<div style={{
|
||||||
|
width: 200,
|
||||||
|
padding: 10,
|
||||||
|
borderRight: '1px solid #eee',
|
||||||
|
backgroundColor: '#fafafa'
|
||||||
|
}}>
|
||||||
|
<div style={{ marginBottom: 20 }}>
|
||||||
|
<h3>节点库</h3>
|
||||||
|
<p>将节点拖拽到画布中</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
style={{ marginBottom: 10, cursor: 'grab' }}
|
||||||
|
draggable
|
||||||
|
onDragStart={(event) => onDragStart(event, 'draggable')}
|
||||||
|
>
|
||||||
|
<div>任务节点 1</div>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Card
|
||||||
|
style={{ marginBottom: 10, cursor: 'grab' }}
|
||||||
|
draggable
|
||||||
|
onDragStart={(event) => onDragStart(event, 'textUpdater')}
|
||||||
|
>
|
||||||
|
<div>文本节点</div>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default SideBar;
|
||||||
Loading…
Reference in New Issue