feat(flowEditor): 优化连接线展示并添加数据展示功能
- 重构 CustomEdge 组件,更名为 DataDisplayEdge,用于展示数据信息 - 新增 CustomConnectionLine组件,用于自定义连接线样式 - 在 FlowEditor 组件中集成新组件和功能 - 优化连接线类型和展示效果master
parent
9629a54d04
commit
6a3721deb4
@ -0,0 +1,35 @@
|
||||
import React, { useEffect } from 'react';
|
||||
import { getBezierPath } from '@xyflow/react';
|
||||
|
||||
const CustomConnectionLine = ({ fromNode, fromX, fromY, toX, toY }) => {
|
||||
useEffect(() => {
|
||||
console.log('fromNode', fromNode);
|
||||
}, [fromNode]);
|
||||
const [path] = getBezierPath({
|
||||
sourceX: fromX,
|
||||
sourceY: fromY,
|
||||
targetX: toX,
|
||||
targetY: toY,
|
||||
curvature: 0.2// 调整这个值可以改变曲线的弯曲程度
|
||||
});
|
||||
|
||||
return (
|
||||
<g>
|
||||
<path
|
||||
d={path}
|
||||
stroke="#b1b1b7"
|
||||
strokeWidth={1}
|
||||
className="animated-stroke"
|
||||
fill="none"
|
||||
/>
|
||||
{/*TODO 临时定义,后续等接口字段。 存在事件信息的时候才展示连接提示*/}
|
||||
{fromNode.data.eventData && (
|
||||
<text x={(fromX + toX) / 2} y={(fromY + toY) / 2 - 10} fill="#000" fontSize={12}>
|
||||
正在连接...
|
||||
</text>
|
||||
)}
|
||||
</g>
|
||||
);
|
||||
};
|
||||
|
||||
export default CustomConnectionLine;
|
||||
Loading…
Reference in New Issue