|
|
|
|
@ -121,8 +121,8 @@ export const useFlowCallbacks = (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取源节点和目标节点的参数信息
|
|
|
|
|
const sourceParams = sourceNode.data?.parameters || {};
|
|
|
|
|
const targetParams = targetNode.data?.parameters || {};
|
|
|
|
|
const sourceParams: any = sourceNode.data?.parameters || {};
|
|
|
|
|
const targetParams: any = targetNode.data?.parameters || {};
|
|
|
|
|
|
|
|
|
|
// 获取源handle和目标handle的类型 (api或data)
|
|
|
|
|
const sourceHandleType = getHandleType(params.sourceHandle, sourceParams);
|
|
|
|
|
@ -142,7 +142,52 @@ export const useFlowCallbacks = (
|
|
|
|
|
|
|
|
|
|
// 如果验证通过,创建连接
|
|
|
|
|
setEdges((edgesSnapshot: Edge[]) => {
|
|
|
|
|
const newEdges = addEdge({ ...params, type: 'custom' }, edgesSnapshot);
|
|
|
|
|
// 创建带有事件信息的连接
|
|
|
|
|
const edgeParams = { ...params, type: 'custom' };
|
|
|
|
|
|
|
|
|
|
// 检查源节点和目标节点是否都有事件信息
|
|
|
|
|
const sourceApi = (sourceParams.apiOuts || []).find((api: any) =>
|
|
|
|
|
api.name === params.sourceHandle || api.id === params.sourceHandle);
|
|
|
|
|
const targetApi = (targetParams.apiIns || []).find((api: any) =>
|
|
|
|
|
api.name === params.targetHandle || api.id === params.targetHandle);
|
|
|
|
|
|
|
|
|
|
// 如果源节点有事件topic信息
|
|
|
|
|
if (sourceApi && sourceApi.topic) {
|
|
|
|
|
// 如果目标节点的topic是**empty**或没有topic,则使用源节点的事件信息
|
|
|
|
|
if (!targetApi || !targetApi.topic || targetApi.topic.includes('**empty**')) {
|
|
|
|
|
edgeParams.data = {
|
|
|
|
|
displayData: {
|
|
|
|
|
name: sourceApi.name,
|
|
|
|
|
eventId: sourceApi.eventId,
|
|
|
|
|
topic: sourceApi.topic
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
// 如果两个节点都有非empty的topic,则以源节点为准
|
|
|
|
|
else if (sourceApi.topic && targetApi.topic &&
|
|
|
|
|
!sourceApi.topic.includes('**empty**') &&
|
|
|
|
|
!targetApi.topic.includes('**empty**')) {
|
|
|
|
|
edgeParams.data = {
|
|
|
|
|
displayData: {
|
|
|
|
|
name: sourceApi.name,
|
|
|
|
|
eventId: sourceApi.eventId,
|
|
|
|
|
topic: sourceApi.topic
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 如果源节点没有事件信息,但目标节点有
|
|
|
|
|
else if (targetApi && targetApi.topic && !targetApi.topic.includes('**empty**')) {
|
|
|
|
|
edgeParams.data = {
|
|
|
|
|
displayData: {
|
|
|
|
|
name: targetApi.name,
|
|
|
|
|
eventId: targetApi.eventId,
|
|
|
|
|
topic: targetApi.topic
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const newEdges = addEdge(edgeParams, edgesSnapshot);
|
|
|
|
|
|
|
|
|
|
// 连接建立后记录历史
|
|
|
|
|
setTimeout(() => {
|
|
|
|
|
|