|
|
|
@ -9,7 +9,7 @@ import { Dispatch } from 'redux';
|
|
|
|
export const useFlowEditorState = (initialData?: any) => {
|
|
|
|
export const useFlowEditorState = (initialData?: any) => {
|
|
|
|
const [nodes, setNodes] = useState<Node[]>([]);
|
|
|
|
const [nodes, setNodes] = useState<Node[]>([]);
|
|
|
|
const [edges, setEdges] = useState<Edge[]>([]);
|
|
|
|
const [edges, setEdges] = useState<Edge[]>([]);
|
|
|
|
const { canvasDataMap, nodeStatusMap } = useSelector((state: any) => state.ideContainer);
|
|
|
|
const { canvasDataMap, nodeStatusMap, isRunning } = useSelector((state: any) => state.ideContainer);
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
const dispatch = useDispatch();
|
|
|
|
|
|
|
|
|
|
|
|
// 添加编辑弹窗相关状态
|
|
|
|
// 添加编辑弹窗相关状态
|
|
|
|
@ -21,9 +21,6 @@ export const useFlowEditorState = (initialData?: any) => {
|
|
|
|
const [edgeForNodeAdd, setEdgeForNodeAdd] = useState<Edge | null>(null);
|
|
|
|
const [edgeForNodeAdd, setEdgeForNodeAdd] = useState<Edge | null>(null);
|
|
|
|
const [positionForNodeAdd, setPositionForNodeAdd] = useState<{ x: number, y: number } | null>(null);
|
|
|
|
const [positionForNodeAdd, setPositionForNodeAdd] = useState<{ x: number, y: number } | null>(null);
|
|
|
|
|
|
|
|
|
|
|
|
// 添加运行状态
|
|
|
|
|
|
|
|
const [isRunning, setIsRunning] = useState(false);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 在组件顶部添加历史记录相关状态
|
|
|
|
// 在组件顶部添加历史记录相关状态
|
|
|
|
const [historyInitialized, setHistoryInitialized] = useState(false);
|
|
|
|
const [historyInitialized, setHistoryInitialized] = useState(false);
|
|
|
|
const historyTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
|
|
const historyTimeoutRef = useRef<NodeJS.Timeout | null>(null);
|
|
|
|
@ -35,11 +32,12 @@ export const useFlowEditorState = (initialData?: any) => {
|
|
|
|
...node,
|
|
|
|
...node,
|
|
|
|
data: {
|
|
|
|
data: {
|
|
|
|
...node.data,
|
|
|
|
...node.data,
|
|
|
|
status: nodeStatusMap[node.id] || 'waiting'
|
|
|
|
status: nodeStatusMap[node.id] || 'waiting',
|
|
|
|
|
|
|
|
isStatusVisible: isRunning // 只有在运行时才显示状态指示器
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
}))
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}, [nodeStatusMap]);
|
|
|
|
}, [nodeStatusMap, isRunning]);
|
|
|
|
|
|
|
|
|
|
|
|
const updateCanvasDataMapDebounced = useRef(
|
|
|
|
const updateCanvasDataMapDebounced = useRef(
|
|
|
|
debounce((dispatch: Dispatch<any>, canvasDataMap: any, id: string, nodes: Node[], edges: Edge[]) => {
|
|
|
|
debounce((dispatch: Dispatch<any>, canvasDataMap: any, id: string, nodes: Node[], edges: Edge[]) => {
|
|
|
|
@ -68,7 +66,6 @@ export const useFlowEditorState = (initialData?: any) => {
|
|
|
|
positionForNodeAdd,
|
|
|
|
positionForNodeAdd,
|
|
|
|
setPositionForNodeAdd,
|
|
|
|
setPositionForNodeAdd,
|
|
|
|
isRunning,
|
|
|
|
isRunning,
|
|
|
|
setIsRunning,
|
|
|
|
|
|
|
|
historyInitialized,
|
|
|
|
historyInitialized,
|
|
|
|
setHistoryInitialized,
|
|
|
|
setHistoryInitialized,
|
|
|
|
historyTimeoutRef,
|
|
|
|
historyTimeoutRef,
|
|
|
|
|