fix: 处理频繁更新导致节点闪烁的问题

master
钟良源 3 weeks ago
parent 406b88e0cf
commit 294894ea56

@ -548,8 +548,13 @@ export const useFlowCallbacks = (
// 实时更新 canvasDataMap
const updateCanvasDataMapEffect = useCallback(() => {
const appKey = getCurrentFlowAppKey();
const { appRuntimeData } = store.getState().ideContainer;
const isCurrentAppRunning =
appKey && appRuntimeData[appKey]?.isRunning;
if (
appKey &&
!isCurrentAppRunning &&
shouldPersistCanvas({ nodes, edges })
) {
updateCanvasDataMapDebounced(

@ -61,7 +61,9 @@ export const useFlowEditorState = (initialData?: any, readOnly?: boolean) => {
Object.values(initialData.components).some((comp: any) => comp.status);
setNodes((prevNodes) => {
return prevNodes.map((node) => {
let hasChanges = false;
const nextNodes = prevNodes.map((node) => {
// 如果是只读模式(历史实例查看),优先使用节点自身的历史状态
// 如果是正常运行模式,只使用运行时状态
let nodeStatus = 'waiting';
@ -80,6 +82,14 @@ export const useFlowEditorState = (initialData?: any, readOnly?: boolean) => {
showStatus = currentAppIsRunning;
}
if (
node.data.status === nodeStatus &&
node.data.isStatusVisible === showStatus
) {
return node;
}
hasChanges = true;
return {
...node,
data: {
@ -89,6 +99,8 @@ export const useFlowEditorState = (initialData?: any, readOnly?: boolean) => {
},
};
});
return hasChanges ? nextNodes : prevNodes;
});
}, [
appRuntimeData,

@ -4,7 +4,6 @@ import {
updateSocketId,
updateNodeStatus,
updateEventListOld,
resetNodeStatus,
updateRuntimeId,
updateIsRunning
} from '@/store/ideContainer';
@ -149,7 +148,6 @@ function IDEContainer() {
const reconnectRuntime = async () => {
try {
dispatch(resetNodeStatus());
dispatch(updateRuntimeId(reconnectRequest.instanceId));
dispatch(updateIsRunning(true));

Loading…
Cancel
Save