diff --git a/src/stores/coreSettings.ts b/src/stores/coreSettings.ts new file mode 100644 index 000000000..556874054 --- /dev/null +++ b/src/stores/coreSettings.ts @@ -0,0 +1,266 @@ +import { NodeBadgeMode } from '@/types/nodeSource' +import { + LinkReleaseTriggerAction, + LinkReleaseTriggerMode +} from '@/types/searchBoxTypes' +import type { SettingParams } from '@/types/settingTypes' + +export const CORE_SETTINGS: SettingParams[] = [ + { + id: 'Comfy.Validation.Workflows', + name: 'Validate workflows', + type: 'boolean', + defaultValue: true + }, + + { + id: 'Comfy.NodeSearchBoxImpl', + category: ['Comfy', 'Node Search Box', 'Implementation'], + experimental: true, + name: 'Node search box implementation', + type: 'combo', + options: ['default', 'litegraph (legacy)'], + defaultValue: 'default' + }, + { + id: 'Comfy.NodeSearchBoxImpl.LinkReleaseTrigger', + category: ['Comfy', 'Node Search Box', 'LinkReleaseTrigger'], + name: 'Trigger on link release', + type: 'hidden', + options: Object.values(LinkReleaseTriggerMode), + defaultValue: LinkReleaseTriggerMode.ALWAYS, + deprecated: true + }, + { + id: 'Comfy.LinkRelease.Action', + name: 'Action on link release (No modifier)', + type: 'combo', + options: Object.values(LinkReleaseTriggerAction), + defaultValue: LinkReleaseTriggerAction.CONTEXT_MENU + }, + { + id: 'Comfy.LinkRelease.ActionShift', + name: 'Action on link release (Shift)', + type: 'combo', + options: Object.values(LinkReleaseTriggerAction), + defaultValue: LinkReleaseTriggerAction.SEARCH_BOX + }, + { + id: 'Comfy.NodeSearchBoxImpl.NodePreview', + category: ['Comfy', 'Node Search Box', 'NodePreview'], + name: 'Node preview', + tooltip: 'Only applies to the default implementation', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.NodeSearchBoxImpl.ShowCategory', + category: ['Comfy', 'Node Search Box', 'ShowCategory'], + name: 'Show node category in search results', + tooltip: 'Only applies to the default implementation', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.NodeSearchBoxImpl.ShowIdName', + category: ['Comfy', 'Node Search Box', 'ShowIdName'], + name: 'Show node id name in search results', + tooltip: 'Only applies to the default implementation', + type: 'boolean', + defaultValue: false + }, + { + id: 'Comfy.Sidebar.Location', + category: ['Comfy', 'Sidebar', 'Location'], + name: 'Sidebar location', + type: 'combo', + options: ['left', 'right'], + defaultValue: 'left' + }, + { + id: 'Comfy.Sidebar.Size', + category: ['Comfy', 'Sidebar', 'Size'], + name: 'Sidebar size', + type: 'combo', + options: ['normal', 'small'], + defaultValue: window.innerWidth < 1600 ? 'small' : 'normal' + }, + { + id: 'Comfy.TextareaWidget.FontSize', + category: ['Comfy', 'Node Widget', 'TextareaWidget', 'FontSize'], + name: 'Textarea widget font size', + type: 'slider', + defaultValue: 10, + attrs: { + min: 8, + max: 24 + } + }, + { + id: 'Comfy.TextareaWidget.Spellcheck', + category: ['Comfy', 'Node Widget', 'TextareaWidget', 'Spellcheck'], + name: 'Textarea widget spellcheck', + type: 'boolean', + defaultValue: false + }, + { + id: 'Comfy.Workflow.SortNodeIdOnSave', + name: 'Sort node IDs when saving workflow', + type: 'boolean', + defaultValue: false + }, + { + id: 'Comfy.Graph.CanvasInfo', + name: 'Show canvas info (fps, etc.)', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.Node.ShowDeprecated', + name: 'Show deprecated nodes in search', + tooltip: + 'Deprecated nodes are hidden by default in the UI, but remain functional in existing workflows that use them.', + type: 'boolean', + defaultValue: false + }, + { + id: 'Comfy.Node.ShowExperimental', + name: 'Show experimental nodes in search', + tooltip: + 'Experimental nodes are marked as such in the UI and may be subject to significant changes or removal in future versions. Use with caution in production workflows', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.Workflow.ShowMissingNodesWarning', + name: 'Show missing nodes warning', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.Workflow.ShowMissingModelsWarning', + name: 'Show missing models warning', + type: 'boolean', + defaultValue: false, + experimental: true + }, + { + id: 'Comfy.Graph.ZoomSpeed', + name: 'Canvas zoom speed', + type: 'slider', + defaultValue: 1.1, + attrs: { + min: 1.01, + max: 2.5, + step: 0.01 + } + }, + // Bookmarks are stored in the settings store. + // Bookmarks are in format of category/display_name. e.g. "conditioning/CLIPTextEncode" + { + id: 'Comfy.NodeLibrary.Bookmarks', + name: 'Node library bookmarks with display name (deprecated)', + type: 'hidden', + defaultValue: [], + deprecated: true + }, + { + id: 'Comfy.NodeLibrary.Bookmarks.V2', + name: 'Node library bookmarks v2 with unique name', + type: 'hidden', + defaultValue: [] + }, + // Stores mapping from bookmark folder name to its customization. + { + id: 'Comfy.NodeLibrary.BookmarksCustomization', + name: 'Node library bookmarks customization', + type: 'hidden', + defaultValue: {} + }, + // Hidden setting used by the queue for how to fit images + { + id: 'Comfy.Queue.ImageFit', + name: 'Queue image fit', + type: 'hidden', + defaultValue: 'cover' + }, + { + id: 'Comfy.Workflow.ModelDownload.AllowedSources', + name: 'Allowed model download sources', + type: 'hidden', + defaultValue: ['https://huggingface.co/', 'https://civitai.com/'] + }, + { + id: 'Comfy.Workflow.ModelDownload.AllowedSuffixes', + name: 'Allowed model download suffixes', + type: 'hidden', + defaultValue: ['.safetensors', '.sft'] + }, + { + id: 'Comfy.GroupSelectedNodes.Padding', + name: 'Group selected nodes padding', + type: 'slider', + defaultValue: 10, + attrs: { + min: 0, + max: 100 + } + }, + { + id: 'Comfy.Node.DoubleClickTitleToEdit', + name: 'Double click node title to edit', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.Group.DoubleClickTitleToEdit', + name: 'Double click group title to edit', + type: 'boolean', + defaultValue: true + }, + { + id: 'Comfy.Window.UnloadConfirmation', + name: 'Show confirmation when closing window', + type: 'boolean', + defaultValue: false + }, + { + id: 'Comfy.TreeExplorer.ItemPadding', + name: 'Tree explorer item padding', + type: 'slider', + defaultValue: 2, + attrs: { + min: 0, + max: 8, + step: 1 + } + }, + { + id: 'Comfy.Locale', + name: 'Locale', + type: 'combo', + options: ['en', 'zh'], + defaultValue: navigator.language.split('-')[0] || 'en' + }, + { + id: 'Comfy.NodeBadge.NodeSourceBadgeMode', + name: 'Node source badge mode', + type: 'combo', + options: Object.values(NodeBadgeMode), + defaultValue: NodeBadgeMode.HideBuiltIn + }, + { + id: 'Comfy.NodeBadge.NodeIdBadgeMode', + name: 'Node ID badge mode', + type: 'combo', + options: [NodeBadgeMode.None, NodeBadgeMode.ShowAll], + defaultValue: NodeBadgeMode.ShowAll + }, + { + id: 'Comfy.NodeBadge.NodeLifeCycleBadgeMode', + name: 'Node life cycle badge mode', + type: 'combo', + options: [NodeBadgeMode.None, NodeBadgeMode.ShowAll], + defaultValue: NodeBadgeMode.ShowAll + } +] diff --git a/src/stores/settingStore.ts b/src/stores/settingStore.ts index 1f79a07a3..31ee389ca 100644 --- a/src/stores/settingStore.ts +++ b/src/stores/settingStore.ts @@ -9,16 +9,12 @@ import { app } from '@/scripts/app' import { ComfySettingsDialog } from '@/scripts/ui/settings' -import { Settings } from '@/types/apiTypes' -import { NodeBadgeMode } from '@/types/nodeSource' -import { - LinkReleaseTriggerAction, - LinkReleaseTriggerMode -} from '@/types/searchBoxTypes' -import { SettingParams } from '@/types/settingTypes' +import type { Settings } from '@/types/apiTypes' +import type { SettingParams } from '@/types/settingTypes' import { buildTree } from '@/utils/treeUtil' import { defineStore } from 'pinia' import type { TreeNode } from 'primevue/treenode' +import { CORE_SETTINGS } from '@/stores/coreSettings' export interface SettingTreeNode extends TreeNode { data?: SettingParams @@ -66,294 +62,8 @@ export const useSettingStore = defineStore('setting', { } this.settings = settings.settingsParamLookup - app.ui.settings.addSetting({ - id: 'Comfy.Validation.Workflows', - name: 'Validate workflows', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeSearchBoxImpl', - category: ['Comfy', 'Node Search Box', 'Implementation'], - experimental: true, - name: 'Node search box implementation', - type: 'combo', - options: ['default', 'litegraph (legacy)'], - defaultValue: 'default' - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeSearchBoxImpl.LinkReleaseTrigger', - category: ['Comfy', 'Node Search Box', 'LinkReleaseTrigger'], - name: 'Trigger on link release', - type: 'hidden', - options: Object.values(LinkReleaseTriggerMode), - defaultValue: LinkReleaseTriggerMode.ALWAYS, - deprecated: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.LinkRelease.Action', - name: 'Action on link release (No modifier)', - type: 'combo', - options: Object.values(LinkReleaseTriggerAction), - defaultValue: LinkReleaseTriggerAction.CONTEXT_MENU - }) - - app.ui.settings.addSetting({ - id: 'Comfy.LinkRelease.ActionShift', - name: 'Action on link release (Shift)', - type: 'combo', - options: Object.values(LinkReleaseTriggerAction), - defaultValue: LinkReleaseTriggerAction.SEARCH_BOX - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeSearchBoxImpl.NodePreview', - category: ['Comfy', 'Node Search Box', 'NodePreview'], - name: 'Node preview', - tooltip: 'Only applies to the default implementation', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeSearchBoxImpl.ShowCategory', - category: ['Comfy', 'Node Search Box', 'ShowCategory'], - name: 'Show node category in search results', - tooltip: 'Only applies to the default implementation', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeSearchBoxImpl.ShowIdName', - category: ['Comfy', 'Node Search Box', 'ShowIdName'], - name: 'Show node id name in search results', - tooltip: 'Only applies to the default implementation', - type: 'boolean', - defaultValue: false - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Sidebar.Location', - category: ['Comfy', 'Sidebar', 'Location'], - name: 'Sidebar location', - type: 'combo', - options: ['left', 'right'], - defaultValue: 'left' - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Sidebar.Size', - category: ['Comfy', 'Sidebar', 'Size'], - name: 'Sidebar size', - type: 'combo', - options: ['normal', 'small'], - defaultValue: window.innerWidth < 1600 ? 'small' : 'normal' - }) - - app.ui.settings.addSetting({ - id: 'Comfy.TextareaWidget.FontSize', - category: ['Comfy', 'Node Widget', 'TextareaWidget', 'FontSize'], - name: 'Textarea widget font size', - type: 'slider', - defaultValue: 10, - attrs: { - min: 8, - max: 24 - } - }) - - app.ui.settings.addSetting({ - id: 'Comfy.TextareaWidget.Spellcheck', - category: ['Comfy', 'Node Widget', 'TextareaWidget', 'Spellcheck'], - name: 'Textarea widget spellcheck', - type: 'boolean', - defaultValue: false - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Workflow.SortNodeIdOnSave', - name: 'Sort node IDs when saving workflow', - type: 'boolean', - defaultValue: false - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Graph.CanvasInfo', - name: 'Show canvas info (fps, etc.)', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Node.ShowDeprecated', - name: 'Show deprecated nodes in search', - tooltip: - 'Deprecated nodes are hidden by default in the UI, but remain functional in existing workflows that use them.', - type: 'boolean', - defaultValue: false - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Node.ShowExperimental', - name: 'Show experimental nodes in search', - tooltip: - 'Experimental nodes are marked as such in the UI and may be subject to significant changes or removal in future versions. Use with caution in production workflows', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Workflow.ShowMissingNodesWarning', - name: 'Show missing nodes warning', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Workflow.ShowMissingModelsWarning', - name: 'Show missing models warning', - type: 'boolean', - defaultValue: false, - experimental: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Graph.ZoomSpeed', - name: 'Canvas zoom speed', - type: 'slider', - defaultValue: 1.1, - attrs: { - min: 1.01, - max: 2.5, - step: 0.01 - } - }) - - // Bookmarks are stored in the settings store. - // Bookmarks are in format of category/display_name. e.g. "conditioning/CLIPTextEncode" - app.ui.settings.addSetting({ - id: 'Comfy.NodeLibrary.Bookmarks', - name: 'Node library bookmarks with display name (deprecated)', - type: 'hidden', - defaultValue: [], - deprecated: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeLibrary.Bookmarks.V2', - name: 'Node library bookmarks v2 with unique name', - type: 'hidden', - defaultValue: [] - }) - - // Stores mapping from bookmark folder name to its customization. - app.ui.settings.addSetting({ - id: 'Comfy.NodeLibrary.BookmarksCustomization', - name: 'Node library bookmarks customization', - type: 'hidden', - defaultValue: {} - }) - - // Hidden setting used by the queue for how to fit images - app.ui.settings.addSetting({ - id: 'Comfy.Queue.ImageFit', - name: 'Queue image fit', - type: 'hidden', - defaultValue: 'cover' - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Workflow.ModelDownload.AllowedSources', - name: 'Allowed model download sources', - type: 'hidden', - defaultValue: ['https://huggingface.co/', 'https://civitai.com/'] - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Workflow.ModelDownload.AllowedSuffixes', - name: 'Allowed model download suffixes', - type: 'hidden', - defaultValue: ['.safetensors', '.sft'] - }) - - app.ui.settings.addSetting({ - id: 'Comfy.GroupSelectedNodes.Padding', - name: 'Group selected nodes padding', - type: 'slider', - defaultValue: 10, - attrs: { - min: 0, - max: 100 - } - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Node.DoubleClickTitleToEdit', - name: 'Double click node title to edit', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Group.DoubleClickTitleToEdit', - name: 'Double click group title to edit', - type: 'boolean', - defaultValue: true - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Window.UnloadConfirmation', - name: 'Show confirmation when closing window', - type: 'boolean', - defaultValue: false - }) - - app.ui.settings.addSetting({ - id: 'Comfy.TreeExplorer.ItemPadding', - name: 'Tree explorer item padding', - type: 'slider', - defaultValue: 2, - attrs: { - min: 0, - max: 8, - step: 1 - } - }) - - app.ui.settings.addSetting({ - id: 'Comfy.Locale', - name: 'Locale', - type: 'combo', - options: ['en', 'zh'], - defaultValue: navigator.language.split('-')[0] || 'en' - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeBadge.NodeSourceBadgeMode', - name: 'Node source badge mode', - type: 'combo', - options: Object.values(NodeBadgeMode), - defaultValue: NodeBadgeMode.HideBuiltIn - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeBadge.NodeIdBadgeMode', - name: 'Node ID badge mode', - type: 'combo', - options: [NodeBadgeMode.None, NodeBadgeMode.ShowAll], - defaultValue: NodeBadgeMode.ShowAll - }) - - app.ui.settings.addSetting({ - id: 'Comfy.NodeBadge.NodeLifeCycleBadgeMode', - name: 'Node life cycle badge mode', - type: 'combo', - options: [NodeBadgeMode.None, NodeBadgeMode.ShowAll], - defaultValue: NodeBadgeMode.ShowAll + CORE_SETTINGS.forEach((setting: SettingParams) => { + settings.addSetting(setting) }) },