feat(canvas): 画布节点 - 恢复批量创作表与转换能力

This commit is contained in:
ddCat committed 2026-09-15 20:56:19 +08:00
1 parent f59b59b3e6
commit c57f1b36ae
36 files changed
+3341 -34

No files matched your search

@@ -56,7 +56,7 @@ export function useCanvasGenerationBatches({ projectId, projectLoaded, nodes, no
);
const enqueueGenerationBatch = useCallback(
(sourceNodeId: string, mode: CanvasGenerationBatchMode, targets: BatchTarget[]) => {
(sourceNodeId: string, mode: CanvasGenerationBatchMode, targets: BatchTarget[], options?: { concurrency?: number }) => {
const sourceNode = nodesRef.current.find((node) => node.id === sourceNodeId);
if (!sourceNode || !targets.length) return;
const activeNodeIds = new Set((sourceNode.metadata?.generationBatches || []).flatMap((batch) => batch.items.filter((item) => ["waiting", "submitting", "queued", "running"].includes(item.status)).map((item) => item.nodeId)));
@@ -73,6 +73,7 @@ export function useCanvasGenerationBatches({ projectId, projectLoaded, nodes, no
mode,
status: "queued",
items: availableTargets.map((target) => ({ id: nanoid(), ...target, status: "waiting", retryCount: 0 })),
concurrency: options?.concurrency ? Math.max(1, Math.min(10, Math.floor(options.concurrency))) : undefined,
createdAt: now,
updatedAt: now,
};
@@ -181,14 +182,18 @@ export function useCanvasGenerationBatches({ projectId, projectLoaded, nodes, no
for (const sourceNode of currentNodes) {
for (const batch of sourceNode.metadata?.generationBatches || []) {
if (batch.projectId !== projectId || batch.status === "completed" || batch.status === "cancelled") continue;
let batchAvailableSlots = batch.concurrency
? Math.max(0, batch.concurrency - batch.items.filter((item) => ["submitting", "queued", "running"].includes(item.status)).length)
: Number.POSITIVE_INFINITY;
for (const item of batch.items) {
if (item.status !== "waiting" || availableSlots <= 0) continue;
if (item.status !== "waiting" || availableSlots <= 0 || batchAvailableSlots <= 0) continue;
const node = nodeById.get(item.nodeId);
if (!node) continue;
// 已绑定任务或已有成品的节点交给恢复/对账链路处理,绝不重复提交。
if (node.metadata?.taskId || (node.metadata?.status === "success" && node.metadata.content)) continue;
candidates.push({ batch, item, node });
availableSlots -= 1;
batchAvailableSlots -= 1;
}
}
}