feat(flow):优化应用流程数据转换逻辑

production
钟良源 6 months ago
parent b388596499
commit 28721ad45a

@ -12,8 +12,6 @@ export const appFLowHandle = (initialData, useDefault, setNodes, setEdges, dispa
nodes: convertedNodes, nodes: convertedNodes,
edges: convertedEdges edges: convertedEdges
} = convertAppFlowData(initialData); } = convertAppFlowData(initialData);
console.log('nodes:', convertedNodes);
console.log('edges:', convertedEdges);
// 为所有边添加类型 // 为所有边添加类型

@ -14,6 +14,17 @@ export const convertAppFlowData = (appFlowData: any[]) => {
// 处理每个应用流程数据项(每个应用作为一个节点) // 处理每个应用流程数据项(每个应用作为一个节点)
appFlowData.forEach((app: any, index: number) => { appFlowData.forEach((app: any, index: number) => {
// 添加过滤逻辑:如果 eventListenes 和 eventSends 都为空,则不生成节点
const hasEventListenes = app.eventListenes && app.eventListenes.length > 0 &&
app.eventListenes.some((event: any) => event && !event.topic?.includes('**empty**'));
const hasEventSends = app.eventSends && app.eventSends.length > 0 &&
app.eventSends.some((event: any) => event && !event.topic?.includes('**empty**'));
// 如果两者都为空,则跳过当前应用节点的创建
if (!hasEventListenes && !hasEventSends) {
return;
}
// 构造节点数据 // 构造节点数据
const node: any = { const node: any = {
id: app.appId || `app_${index}`, id: app.appId || `app_${index}`,
@ -29,7 +40,7 @@ export const convertAppFlowData = (appFlowData: any[]) => {
dataType: '', dataType: '',
defaultValue: '', defaultValue: '',
topic: event.topic topic: event.topic
})) : [], })).filter((event: any) => event && !event.topic?.includes('**empty**')) : [],
// eventSends 作为 apiOuts输出 // eventSends 作为 apiOuts输出
apiOuts: app.eventSends ? app.eventSends.map((event: any) => ({ apiOuts: app.eventSends ? app.eventSends.map((event: any) => ({
name: event.eventName, name: event.eventName,
@ -37,7 +48,7 @@ export const convertAppFlowData = (appFlowData: any[]) => {
dataType: '', dataType: '',
defaultValue: '', defaultValue: '',
topic: event.topic topic: event.topic
})) : [], })).filter((event: any) => event && !event.topic?.includes('**empty**')) : [],
// 提取 dataIns 和 dataOuts 属性 // 提取 dataIns 和 dataOuts 属性
dataIns: [], dataIns: [],
dataOuts: [] dataOuts: []

Loading…
Cancel
Save