Files
Alfred Lee 7a9017e781 Refactor ComfyUI Workflow Preset Switch to ComfyUI Workflow State Presets
- Renamed the main node from `WorkflowPresetSwitch` to `Preset Switch` for clarity.
- Introduced a new node `Preset Group Editor` for managing node states in groups.
- Updated documentation across README files and development documentation to reflect the new naming and features.
- Changed storage key for presets from `comfyui_workflow_preset_switch` to `comfyui_workflow_state_presets`.
- Enhanced functionality to support dynamic state management for grouped nodes.
- Improved user interface elements for preset management, including buttons for recording, applying, and cycling through presets.
- Added persistence for preset states and improved error handling for missing nodes during preset application.
2026-02-27 13:48:03 +08:00

65 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
class PresetSwitch:
"""
Phase 1 骨架节点:提供 preset_index 输入。
后续由前端扩展监听该值变化并应用 preset。
"""
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"preset_index": (
"INT",
{
"default": 0,
"min": 0,
"max": 999999,
"step": 1,
},
)
}
}
RETURN_TYPES = ("INT",)
RETURN_NAMES = ("preset_index",)
FUNCTION = "run"
CATEGORY = "workflow/preset"
def run(self, preset_index):
return (int(preset_index),)
class PresetGroupEditor:
"""
Preset Group Editor:
统一管理工作流分组(Group)节点状态,提供三态切换:
- 启用(ALWAYS)
- 跳过(BYPASS / mode=4)
- 禁用(NEVER)
该节点主要由前端扩展提供交互能力,后端仅作为节点定义入口。
"""
@classmethod
def INPUT_TYPES(cls):
return {"required": {}}
RETURN_TYPES = ()
RETURN_NAMES = ()
FUNCTION = "run"
CATEGORY = "workflow/preset"
def run(self):
return tuple()
NODE_CLASS_MAPPINGS = {
"PresetSwitch": PresetSwitch,
"PresetGroupEditor": PresetGroupEditor,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"PresetSwitch": "Preset Switch",
"PresetGroupEditor": "Preset Group Editor",
}