|
|
|
@ -7,10 +7,10 @@ import {
|
|
|
|
Node,
|
|
|
|
Node,
|
|
|
|
Edge
|
|
|
|
Edge
|
|
|
|
} from '@xyflow/react';
|
|
|
|
} from '@xyflow/react';
|
|
|
|
import { setMainFlow } from '@/api/appRes';
|
|
|
|
import { setMainFlow, setMainFlowNew } from '@/api/appRes';
|
|
|
|
import { Message } from '@arco-design/web-react';
|
|
|
|
import { Message } from '@arco-design/web-react';
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
import { nodeTypeMap, registerNodeType } from '@/components/FlowEditor/node';
|
|
|
|
import { convertFlowData, revertFlowData } from '@/utils/convertFlowData';
|
|
|
|
import { convertFlowData, reverseConvertFlowData, revertFlowData } from '@/utils/convertFlowData';
|
|
|
|
import { localNodeData } from '@/pages/flowEditor/sideBar/config/localNodeData';
|
|
|
|
import { localNodeData } from '@/pages/flowEditor/sideBar/config/localNodeData';
|
|
|
|
import { useAlignmentGuidelines } from '@/hooks/useAlignmentGuidelines';
|
|
|
|
import { useAlignmentGuidelines } from '@/hooks/useAlignmentGuidelines';
|
|
|
|
import LocalNode from '@/components/FlowEditor/node/localNode/LocalNode';
|
|
|
|
import LocalNode from '@/components/FlowEditor/node/localNode/LocalNode';
|
|
|
|
@ -843,6 +843,7 @@ export const useFlowCallbacks = (
|
|
|
|
if (nodeType === 'EVENTLISTENE') {
|
|
|
|
if (nodeType === 'EVENTLISTENE') {
|
|
|
|
// 事件接收节点
|
|
|
|
// 事件接收节点
|
|
|
|
params.eventListenes.push({
|
|
|
|
params.eventListenes.push({
|
|
|
|
|
|
|
|
nodeName: nodeConfig.nodeName || '',
|
|
|
|
eventId: eventConfig?.eventId || '',
|
|
|
|
eventId: eventConfig?.eventId || '',
|
|
|
|
topic: eventConfig?.topic || '',
|
|
|
|
topic: eventConfig?.topic || '',
|
|
|
|
eventName: eventConfig?.name || '',
|
|
|
|
eventName: eventConfig?.name || '',
|
|
|
|
@ -852,6 +853,7 @@ export const useFlowCallbacks = (
|
|
|
|
else if (nodeType === 'EVENTSEND') {
|
|
|
|
else if (nodeType === 'EVENTSEND') {
|
|
|
|
// 事件发送节点
|
|
|
|
// 事件发送节点
|
|
|
|
params.eventSends.push({
|
|
|
|
params.eventSends.push({
|
|
|
|
|
|
|
|
nodeName: nodeConfig.nodeName || '',
|
|
|
|
eventId: eventConfig?.eventId || '',
|
|
|
|
eventId: eventConfig?.eventId || '',
|
|
|
|
topic: eventConfig?.topic || '',
|
|
|
|
topic: eventConfig?.topic || '',
|
|
|
|
eventName: eventConfig?.name || '',
|
|
|
|
eventName: eventConfig?.name || '',
|
|
|
|
@ -860,9 +862,8 @@ export const useFlowCallbacks = (
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
// 调用更新事件的API
|
|
|
|
// 调用更新事件的API
|
|
|
|
if (initialData?.appId && params.eventListenes.lengrh > 0 && params.eventSends.length > 0) {
|
|
|
|
if (params.eventListenes.lengrh > 0 || params.eventSends.length > 0) {
|
|
|
|
updateAppEvent(initialData.appId, params);
|
|
|
|
updateAppEvent(initialData.appId, params);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -885,11 +886,21 @@ export const useFlowCallbacks = (
|
|
|
|
|
|
|
|
|
|
|
|
// 转换会原始数据类型
|
|
|
|
// 转换会原始数据类型
|
|
|
|
const revertedData = revertFlowData(nodes, edges);
|
|
|
|
const revertedData = revertFlowData(nodes, edges);
|
|
|
|
console.log('revertedData(中断):', revertedData);
|
|
|
|
const newRevertedData = reverseConvertFlowData(nodes, edges);
|
|
|
|
|
|
|
|
const { flowData, currentAppData } = store.getState().ideContainer;
|
|
|
|
|
|
|
|
// console.log('revertedData(中断):', revertedData);
|
|
|
|
|
|
|
|
// console.log('newRevertedData(中断):', newRevertedData);
|
|
|
|
|
|
|
|
const params = {
|
|
|
|
|
|
|
|
...flowData[currentAppData.id]?.main || {},
|
|
|
|
|
|
|
|
components: newRevertedData
|
|
|
|
|
|
|
|
};
|
|
|
|
// return;
|
|
|
|
// return;
|
|
|
|
|
|
|
|
|
|
|
|
updateEvent(revertedData.nodeConfigs);
|
|
|
|
updateEvent(revertedData.nodeConfigs);
|
|
|
|
const res: any = await setMainFlow(revertedData, initialData.appId);
|
|
|
|
// 旧版数据结构
|
|
|
|
|
|
|
|
// const res: any = await setMainFlow(revertedData, initialData.appId);
|
|
|
|
|
|
|
|
// 新版数据结构
|
|
|
|
|
|
|
|
const res: any = await setMainFlowNew(params, initialData.appId);
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
Message.success('保存成功');
|
|
|
|
Message.success('保存成功');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -919,13 +930,13 @@ export const useFlowCallbacks = (
|
|
|
|
socketId
|
|
|
|
socketId
|
|
|
|
};
|
|
|
|
};
|
|
|
|
runMainFlow(params);
|
|
|
|
runMainFlow(params);
|
|
|
|
|
|
|
|
|
|
|
|
// 设置运行状态为true
|
|
|
|
// 设置运行状态为true
|
|
|
|
dispatch(updateIsRunning(true));
|
|
|
|
dispatch(updateIsRunning(true));
|
|
|
|
|
|
|
|
|
|
|
|
// 重置节点状态
|
|
|
|
// 重置节点状态
|
|
|
|
dispatch(resetNodeStatus());
|
|
|
|
dispatch(resetNodeStatus());
|
|
|
|
|
|
|
|
|
|
|
|
// 开始运行时动画
|
|
|
|
// 开始运行时动画
|
|
|
|
setEdges((eds) => eds.map(edge => ({
|
|
|
|
setEdges((eds) => eds.map(edge => ({
|
|
|
|
...edge,
|
|
|
|
...edge,
|
|
|
|
@ -939,7 +950,7 @@ export const useFlowCallbacks = (
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
// 设置运行状态为false
|
|
|
|
// 设置运行状态为false
|
|
|
|
dispatch(updateIsRunning(false));
|
|
|
|
dispatch(updateIsRunning(false));
|
|
|
|
|
|
|
|
|
|
|
|
// 停止运行
|
|
|
|
// 停止运行
|
|
|
|
setEdges((eds) => eds.map(edge => ({
|
|
|
|
setEdges((eds) => eds.map(edge => ({
|
|
|
|
...edge,
|
|
|
|
...edge,
|
|
|
|
|