|
|
|
@ -129,6 +129,10 @@ export const useFlowCallbacks = (
|
|
|
|
return getCurrentAppKey(currentAppData) || initialData?.appId;
|
|
|
|
return getCurrentAppKey(currentAppData) || initialData?.appId;
|
|
|
|
}, [initialData]);
|
|
|
|
}, [initialData]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const refreshAppList = useCallback(() => {
|
|
|
|
|
|
|
|
document.dispatchEvent(new CustomEvent('refreshAppList'));
|
|
|
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
|
|
// region 画布操作
|
|
|
|
// region 画布操作
|
|
|
|
// 节点变更处理,添加防抖机制
|
|
|
|
// 节点变更处理,添加防抖机制
|
|
|
|
const onNodesChange = useCallback(
|
|
|
|
const onNodesChange = useCallback(
|
|
|
|
@ -548,8 +552,13 @@ export const useFlowCallbacks = (
|
|
|
|
// 实时更新 canvasDataMap
|
|
|
|
// 实时更新 canvasDataMap
|
|
|
|
const updateCanvasDataMapEffect = useCallback(() => {
|
|
|
|
const updateCanvasDataMapEffect = useCallback(() => {
|
|
|
|
const appKey = getCurrentFlowAppKey();
|
|
|
|
const appKey = getCurrentFlowAppKey();
|
|
|
|
|
|
|
|
const { appRuntimeData } = store.getState().ideContainer;
|
|
|
|
|
|
|
|
const isCurrentAppRunning =
|
|
|
|
|
|
|
|
appKey && appRuntimeData[appKey]?.isRunning;
|
|
|
|
|
|
|
|
|
|
|
|
if (
|
|
|
|
if (
|
|
|
|
appKey &&
|
|
|
|
appKey &&
|
|
|
|
|
|
|
|
!isCurrentAppRunning &&
|
|
|
|
shouldPersistCanvas({ nodes, edges })
|
|
|
|
shouldPersistCanvas({ nodes, edges })
|
|
|
|
) {
|
|
|
|
) {
|
|
|
|
updateCanvasDataMapDebounced(
|
|
|
|
updateCanvasDataMapDebounced(
|
|
|
|
@ -1401,6 +1410,7 @@ export const useFlowCallbacks = (
|
|
|
|
|
|
|
|
|
|
|
|
// 更新运行ID
|
|
|
|
// 更新运行ID
|
|
|
|
dispatch(updateRuntimeId(res.data));
|
|
|
|
dispatch(updateRuntimeId(res.data));
|
|
|
|
|
|
|
|
refreshAppList();
|
|
|
|
|
|
|
|
|
|
|
|
// 开始运行时动画
|
|
|
|
// 开始运行时动画
|
|
|
|
setEdges((eds) =>
|
|
|
|
setEdges((eds) =>
|
|
|
|
@ -1434,6 +1444,7 @@ export const useFlowCallbacks = (
|
|
|
|
|
|
|
|
|
|
|
|
// 更新运行ID
|
|
|
|
// 更新运行ID
|
|
|
|
dispatch(updateRuntimeId(res.data));
|
|
|
|
dispatch(updateRuntimeId(res.data));
|
|
|
|
|
|
|
|
refreshAppList();
|
|
|
|
|
|
|
|
|
|
|
|
// 开始运行时动画
|
|
|
|
// 开始运行时动画
|
|
|
|
setEdges((eds) =>
|
|
|
|
setEdges((eds) =>
|
|
|
|
@ -1462,9 +1473,8 @@ export const useFlowCallbacks = (
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// 特殊停止逻辑,持久化运行的应用使用这里的入参
|
|
|
|
// 特殊停止逻辑,持久化运行的应用使用这里的入参
|
|
|
|
await stopApp(currentAppData.instanceId);
|
|
|
|
await stopApp(currentAppData.instanceId);
|
|
|
|
// 特殊停止完成后触发事件,通知刷新应用列表
|
|
|
|
|
|
|
|
document.dispatchEvent(new CustomEvent('refreshAppList'));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
refreshAppList();
|
|
|
|
|
|
|
|
|
|
|
|
// 重置节点状态
|
|
|
|
// 重置节点状态
|
|
|
|
dispatch(resetNodeStatus());
|
|
|
|
dispatch(resetNodeStatus());
|
|
|
|
@ -1490,7 +1500,7 @@ export const useFlowCallbacks = (
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
[getCurrentFlowAppKey]
|
|
|
|
[getCurrentFlowAppKey, refreshAppList]
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
// 暂停/恢复应用
|
|
|
|
// 暂停/恢复应用
|
|
|
|
|