|
|
|
@ -39,10 +39,10 @@ import { appFLowHandle } from '@/pages/flowEditor/utils/appFlowhandle';
|
|
|
|
import { handelEventNodeList, updateEvent, upDatePublish } from '@/pages/flowEditor/utils/common';
|
|
|
|
import { handelEventNodeList, updateEvent, upDatePublish } from '@/pages/flowEditor/utils/common';
|
|
|
|
|
|
|
|
|
|
|
|
import { Dispatch } from 'redux';
|
|
|
|
import { Dispatch } from 'redux';
|
|
|
|
import { runMainFlow, stopApp } from '@/api/apps';
|
|
|
|
import { getAppListBySceneId, runMainFlow, stopApp } from '@/api/apps';
|
|
|
|
import store from '@/store';
|
|
|
|
import store from '@/store';
|
|
|
|
import { updateAppEvent, updateAppEventChannel, updateAppFlowData } from '@/api/appEvent';
|
|
|
|
import { updateAppEvent, updateAppEventChannel, updateAppFlowData } from '@/api/appEvent';
|
|
|
|
import { sleep } from '@/utils/common';
|
|
|
|
import { getUrlParams, sleep } from '@/utils/common';
|
|
|
|
import { queryEventItemBySceneIdOld, deleteEventSub, deleteEventPub } from '@/api/event';
|
|
|
|
import { queryEventItemBySceneIdOld, deleteEventSub, deleteEventPub } from '@/api/event';
|
|
|
|
|
|
|
|
|
|
|
|
export const useFlowCallbacks = (
|
|
|
|
export const useFlowCallbacks = (
|
|
|
|
@ -912,26 +912,10 @@ export const useFlowCallbacks = (
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
const flowSubMap = flowData[currentAppData.id]?.subMap || {};
|
|
|
|
newNode.data.component = {
|
|
|
|
const sameData: any = flowSubMap[newNode.data.compId];
|
|
|
|
type: nodeType,
|
|
|
|
if (sameData) {
|
|
|
|
compId: newNode.data.compId
|
|
|
|
newNode.data.component = {
|
|
|
|
};
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId,
|
|
|
|
|
|
|
|
customDef: JSON.stringify({
|
|
|
|
|
|
|
|
dataIns: newNode.data.parameters.dataIns,
|
|
|
|
|
|
|
|
dataOuts: newNode.data.parameters.dataOuts,
|
|
|
|
|
|
|
|
subflowId: sameData,
|
|
|
|
|
|
|
|
name: newNode.data.title
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
newNode.data.component = {
|
|
|
|
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nodeType === 'EVENTSEND' || nodeType === 'EVENTLISTENE') {
|
|
|
|
else if (nodeType === 'EVENTSEND' || nodeType === 'EVENTLISTENE') {
|
|
|
|
const { eventList } = store.getState().ideContainer;
|
|
|
|
const { eventList } = store.getState().ideContainer;
|
|
|
|
@ -1067,26 +1051,10 @@ export const useFlowCallbacks = (
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
else if (nodeType === 'SUB') {
|
|
|
|
const flowSubMap = flowData[currentAppData.id]?.subMap || {};
|
|
|
|
newNode.data.component = {
|
|
|
|
const sameData: any = flowSubMap[newNode.data.compId];
|
|
|
|
type: nodeType,
|
|
|
|
if (sameData) {
|
|
|
|
compId: newNode.data.compId
|
|
|
|
newNode.data.component = {
|
|
|
|
};
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId,
|
|
|
|
|
|
|
|
customDef: JSON.stringify({
|
|
|
|
|
|
|
|
dataIns: newNode.data.parameters.dataIns,
|
|
|
|
|
|
|
|
dataOuts: newNode.data.parameters.dataOuts,
|
|
|
|
|
|
|
|
subflowId: sameData,
|
|
|
|
|
|
|
|
name: newNode.data.title
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
newNode.data.component = {
|
|
|
|
|
|
|
|
type: nodeType,
|
|
|
|
|
|
|
|
compId: newNode.data.compId
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (nodeType === 'EVENTSEND' || nodeType === 'EVENTLISTENE') {
|
|
|
|
else if (nodeType === 'EVENTSEND' || nodeType === 'EVENTLISTENE') {
|
|
|
|
const { eventList } = store.getState().ideContainer;
|
|
|
|
const { eventList } = store.getState().ideContainer;
|
|
|
|
@ -1181,22 +1149,15 @@ export const useFlowCallbacks = (
|
|
|
|
const res1: any = await queryEventItemBySceneIdOld(info.id);
|
|
|
|
const res1: any = await queryEventItemBySceneIdOld(info.id);
|
|
|
|
if (res1.code === 200) dispatch(updateEventListOld(res1.data));
|
|
|
|
if (res1.code === 200) dispatch(updateEventListOld(res1.data));
|
|
|
|
|
|
|
|
|
|
|
|
// 更新缓存数据 - 与主流程保持一致
|
|
|
|
const appRes: any = await getAppInfoNew(currentAppData.parentAppId);
|
|
|
|
dispatch(updateCanvasDataMap({
|
|
|
|
|
|
|
|
...canvasDataMap,
|
|
|
|
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
const appRes: any = await getAppInfoNew(currentAppData.id);
|
|
|
|
|
|
|
|
// 更新 flowData 中的数据
|
|
|
|
// 更新 flowData 中的数据
|
|
|
|
dispatch(updateFlowData({ [currentAppData.id]: appRes.data }));
|
|
|
|
dispatch(updateFlowData({ [currentAppData.parentAppId]: appRes.data }));
|
|
|
|
// 同步更新到 canvasDataMap
|
|
|
|
// 同步更新到 canvasDataMap
|
|
|
|
if (appRes.data.main?.components) {
|
|
|
|
if (appRes.data.main?.components) {
|
|
|
|
const { nodes, edges } = convertFlowData(appRes.data.main.components, true);
|
|
|
|
const { nodes, edges } = convertFlowData(appRes.data.main.components, true);
|
|
|
|
setNodes(nodes);
|
|
|
|
|
|
|
|
setEdges(edges);
|
|
|
|
|
|
|
|
dispatch(updateCanvasDataMap({
|
|
|
|
dispatch(updateCanvasDataMap({
|
|
|
|
...canvasDataMap,
|
|
|
|
...canvasDataMap,
|
|
|
|
[currentAppData.id]: { nodes, edges }
|
|
|
|
[currentAppData.parentAppId]: { nodes, edges }
|
|
|
|
}));
|
|
|
|
}));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -1213,6 +1174,7 @@ export const useFlowCallbacks = (
|
|
|
|
appEventDefinition,
|
|
|
|
appEventDefinition,
|
|
|
|
sceneId: info.id
|
|
|
|
sceneId: info.id
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const res: any = await setMainFlowNew(params, initialData.appId);
|
|
|
|
const res: any = await setMainFlowNew(params, initialData.appId);
|
|
|
|
if (res.code === 200) {
|
|
|
|
if (res.code === 200) {
|
|
|
|
Message.success('保存成功');
|
|
|
|
Message.success('保存成功');
|
|
|
|
@ -1328,6 +1290,7 @@ export const useFlowCallbacks = (
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, [nodes, edges, initialData?.appId]);
|
|
|
|
}, [nodes, edges, initialData?.appId]);
|
|
|
|
|
|
|
|
|
|
|
|
// 运行处理函数
|
|
|
|
// 运行处理函数
|
|
|
|
const handleRun = useCallback(async (running: boolean) => {
|
|
|
|
const handleRun = useCallback(async (running: boolean) => {
|
|
|
|
const { currentAppData, socketId, appRuntimeData } = store.getState().ideContainer;
|
|
|
|
const { currentAppData, socketId, appRuntimeData } = store.getState().ideContainer;
|
|
|
|
|