|
|
|
|
@ -7,7 +7,7 @@ import {
|
|
|
|
|
Node,
|
|
|
|
|
Edge
|
|
|
|
|
} from '@xyflow/react';
|
|
|
|
|
import { setMainFlow, setMainFlowNew } from '@/api/appRes';
|
|
|
|
|
import { refPublish, setMainFlow, setMainFlowNew } from '@/api/appRes';
|
|
|
|
|
import { Message } from '@arco-design/web-react';
|
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
|
import { convertFlowData, reverseConvertFlowData, revertFlowData } from '@/utils/convertFlowData';
|
|
|
|
|
@ -60,8 +60,7 @@ export const useFlowCallbacks = (
|
|
|
|
|
setEdgeForNodeAdd: React.Dispatch<React.SetStateAction<Edge | null>>,
|
|
|
|
|
positionForNodeAdd: { x: number, y: number } | null,
|
|
|
|
|
setPositionForNodeAdd: React.Dispatch<React.SetStateAction<{ x: number, y: number } | null>>,
|
|
|
|
|
setIsDelete: React.Dispatch<React.SetStateAction<boolean>>,
|
|
|
|
|
setIsRunning: React.Dispatch<React.SetStateAction<boolean>>
|
|
|
|
|
setIsDelete: React.Dispatch<React.SetStateAction<boolean>>
|
|
|
|
|
) => {
|
|
|
|
|
const { getGuidelines, clearGuidelines } = useAlignmentGuidelines();
|
|
|
|
|
// region 画布操作
|
|
|
|
|
@ -633,7 +632,7 @@ export const useFlowCallbacks = (
|
|
|
|
|
...nodeDefinition.data,
|
|
|
|
|
title: nodeDefinition.nodeName,
|
|
|
|
|
type: nodeType,
|
|
|
|
|
compId: nodeDefinition.id
|
|
|
|
|
compId: nodeDefinition.id || nodeDefinition.flowHousVO.id
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -750,7 +749,7 @@ export const useFlowCallbacks = (
|
|
|
|
|
...nodeDefinition.data,
|
|
|
|
|
title: nodeDefinition.nodeName,
|
|
|
|
|
type: nodeType,
|
|
|
|
|
compId: nodeDefinition.id
|
|
|
|
|
compId: nodeDefinition.id || nodeDefinition.flowHousVO.id
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
@ -770,7 +769,6 @@ export const useFlowCallbacks = (
|
|
|
|
|
customDef: { eventId: emptyEvent.id, name: emptyEvent.name, topic: emptyEvent.topic }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 将未定义的节点动态追加进nodeTypes
|
|
|
|
|
const nodeMap = Array.from(Object.values(nodeTypeMap).map(key => key));
|
|
|
|
|
// 目前默认添加的都是系统组件/本地组件
|
|
|
|
|
@ -867,6 +865,17 @@ export const useFlowCallbacks = (
|
|
|
|
|
updateAppEvent(initialData.appId, params);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const upDatePublish = (revertedData) => {
|
|
|
|
|
const { currentAppData } = store.getState().ideContainer;
|
|
|
|
|
const params = {
|
|
|
|
|
appId: currentAppData.id,
|
|
|
|
|
publishAppId: []
|
|
|
|
|
};
|
|
|
|
|
revertedData.forEach(item => {
|
|
|
|
|
if (item?.component && item.component.type === 'SUB') params.publishAppId.push(item.component.compId); // 复合组件的这个compId实际上就是flowHousVO里面的id
|
|
|
|
|
});
|
|
|
|
|
if (params.publishAppId.length > 0) refPublish(params);
|
|
|
|
|
};
|
|
|
|
|
const saveFlowDataToServer = useCallback(async () => {
|
|
|
|
|
if (useDefault) {
|
|
|
|
|
try {
|
|
|
|
|
@ -895,7 +904,7 @@ export const useFlowCallbacks = (
|
|
|
|
|
components: newRevertedData
|
|
|
|
|
};
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
upDatePublish(revertedData.nodeConfigs);
|
|
|
|
|
updateEvent(revertedData.nodeConfigs);
|
|
|
|
|
// 旧版数据结构
|
|
|
|
|
// const res: any = await setMainFlow(revertedData, initialData.appId);
|
|
|
|
|
|