mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-11 14:02:37 +08:00
Added a migration feature to smoothly load workflows written in the traditional combo into nodes written in toggle.
This commit is contained in:
parent
834ab278d2
commit
f4595cc816
21
web/extensions/core/toggle-migration.js
Normal file
21
web/extensions/core/toggle-migration.js
Normal file
@ -0,0 +1,21 @@
|
||||
import { ComfyApp, app } from "../../scripts/app.js";
|
||||
|
||||
app.registerExtension({
|
||||
name: "Comfy.ToggleMigration",
|
||||
|
||||
nodeCreated(node, app) {
|
||||
for(let i in node.widgets) {
|
||||
let widget = node.widgets[i];
|
||||
|
||||
if(widget.type == "toggle") {
|
||||
Object.defineProperty(widget, "value", {
|
||||
set: (value) => {
|
||||
delete widget.value;
|
||||
widget.value = value == true || value == widget.options.on;
|
||||
},
|
||||
get: () => { return false; }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user