Split batch clear buttons for source and target images

This commit is contained in:
Jony
2026-11-09 10:49:28 +08:00
parent f72d0a5c56
commit 81a0e50b2d
2 changed files with 72 additions and 27 deletions
+31 -6
View File
@@ -337,9 +337,10 @@ const renderReferenceRole = vm.runInContext("renderReferenceRole", context);
const editReference = vm.runInContext("editReference", context);
const replaceReference = vm.runInContext("replaceReference", context);
const updateBatchReferenceHint = vm.runInContext("updateBatchReferenceHint", context);
const clearAllReferences = vm.runInContext("clearAllReferences", context);
const clearReferenceRole = vm.runInContext("clearReferenceRole", context);
const syncClearReferenceButtons = vm.runInContext("syncClearReferenceButtons", context);
const referenceListsAreEmpty = vm.runInContext("referenceListsAreEmpty", context);
const referenceRoleIsEmpty = vm.runInContext("referenceRoleIsEmpty", context);
const setWidgetValue = vm.runInContext("setWidgetValue", context);
const updateBatchSummary = vm.runInContext("updateBatchSummary", context);
const initializeSaveSlots = vm.runInContext("initializeSaveSlots", context);
@@ -516,10 +517,12 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
assert.equal(modelActions.className, "o1ig-asset-actions");
assert.equal(modelActions.children[0], node._o1igClearModelReferences);
assert.equal(modelActions.children[1], node._o1igModelCanvasPick);
assert.equal(node._o1igClearModelReferences.children[0].textContent, "清空");
assert.equal(node._o1igClearModelReferences.children[0].textContent, "清空目标图");
assert.equal(node._o1igClearModelReferences.disabled, true);
assert.equal(node._o1igClearReferences.children[0].textContent, "清空素材图");
node._o1igBatchToggle.dispatch("click");
assert.equal(node._o1igBatchEnabled, false);
assert.equal(node._o1igClearReferences.children[0].textContent, "清空参考图");
const promptWidget = widgets.find(widget => widget.name === "prompt");
const computeSize = promptWidget.computeSize;
promptWidget.options = {};promptWidget.hidden = false;
@@ -3141,8 +3144,10 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
};
buildPanel(clearNode);
assert.equal(referenceListsAreEmpty(clearNode), true);
assert.equal(clearAllReferences(clearNode), false, "No-op when already empty");
assert.equal(referenceRoleIsEmpty(clearNode, "references"), true);
assert.equal(clearReferenceRole(clearNode, "references"), false, "No-op when already empty");
assert.equal(clearNode._o1igClearReferences.disabled, true);
assert.equal(clearNode._o1igClearReferences.children[0].textContent, "清空参考图");
clearNode._o1igReferences = [
{ name: "a.png", subfolder: "", type: "input" },
@@ -3153,11 +3158,10 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
setWidgetValue(clearNode, "蒙版清单", JSON.stringify(clearNode._o1igMask));
syncClearReferenceButtons(clearNode);
assert.equal(clearNode._o1igClearReferences.disabled, false);
assert.equal(clearAllReferences(clearNode), true);
assert.equal(clearReferenceRole(clearNode, "references"), true);
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igReferences)), []);
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, "[]");
assert.equal(widgets.find((widget) => widget.name === "模特图清单").value, "[]");
assert.deepEqual(
JSON.parse(JSON.stringify(clearNode._o1igMask)),
{ name: "mask.png", subfolder: "", type: "input" },
@@ -3176,7 +3180,24 @@ function createRecoveryNodes(batchId, generatorId, saveNodeId) {
syncClearReferenceButtons(clearNode);
assert.equal(clearNode._o1igClearReferences.disabled, false);
assert.equal(clearNode._o1igClearModelReferences.disabled, false);
assert.equal(clearNode._o1igClearReferences.children[0].textContent, "清空素材图");
assert.equal(clearNode._o1igClearModelReferences.children[0].textContent, "清空目标图");
assert.equal(clearNode._o1igClearReferences.title, "清空全部素材图");
assert.equal(clearNode._o1igClearModelReferences.title, "清空全部目标图");
clearNode._o1igClearModelReferences.dispatch("click");
assert.deepEqual(
JSON.parse(JSON.stringify(clearNode._o1igReferences)),
[{ name: "outfit.png", subfolder: "", type: "input" }],
"Clearing 目标图 must not touch 素材图",
);
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, JSON.stringify([{ name: "outfit.png", subfolder: "", type: "input" }]));
assert.equal(widgets.find((widget) => widget.name === "模特图清单").value, "[]");
assert.equal(clearNode._o1igClearReferences.disabled, false);
assert.equal(clearNode._o1igClearModelReferences.disabled, true);
clearNode._o1igClearReferences.dispatch("click");
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igReferences)), []);
assert.deepEqual(JSON.parse(JSON.stringify(clearNode._o1igModelReferences)), []);
assert.equal(widgets.find((widget) => widget.name === "参考图清单").value, "[]");
@@ -3274,8 +3295,12 @@ assert.match(source, /\.o1ig-thumb\{[\s\S]*?flex:0 0 102px;height:102px/);
assert.match(source, /\.o1ig-thumb img\{[\s\S]*?object-fit:contain;background:var\(--o1ig-surface\)/);
assert.match(source, /referenceActions\.append\(clearReferences, canvasPick\)/);
assert.match(source, /modelActions\.append\(clearModelReferences, modelCanvasPick\)/);
assert.match(source, /function clearAllReferences\(node\)/);
assert.match(source, /function clearReferenceRole\(node, role = "references"\)/);
assert.match(source, /textContent = "清空参考图"/);
assert.match(source, /textContent = "清空目标图"/);
assert.match(source, /batch \? "清空素材图" : "清空参考图"/);
assert.match(source, /clearReferenceRole\(node, "references"\)/);
assert.match(source, /clearReferenceRole\(node, "models"\)/);
assert.match(source, /\.o1ig-clear-refs\{/);
assert.doesNotMatch(source, /o1ig-add[\s\S]{0,400}?addLabel\.textContent = "上传"/, "头部不再有上传按钮");
assert.match(source, /upload\.addEventListener\("click", \(\) => requestReferenceUpload\(node, role\)\)/);