mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-29 18:52:19 +00:00
[Cleanup] Refactor widget construction (#2861)
This commit is contained in:
@@ -59,33 +59,20 @@ export const useLitegraphService = () => {
|
|||||||
const inputType = inputSpec.type
|
const inputType = inputSpec.type
|
||||||
const nameKey = `nodeDefs.${normalizeI18nKey(nodeDef.name)}.inputs.${normalizeI18nKey(inputName)}.name`
|
const nameKey = `nodeDefs.${normalizeI18nKey(nodeDef.name)}.inputs.${normalizeI18nKey(inputName)}.name`
|
||||||
|
|
||||||
let widgetCreated = true
|
|
||||||
const widgetType = app.getWidgetType(
|
const widgetType = app.getWidgetType(
|
||||||
[inputType, inputSpec],
|
[inputType, inputSpec],
|
||||||
inputName
|
inputName
|
||||||
)
|
)
|
||||||
if (widgetType) {
|
if (widgetType) {
|
||||||
if (widgetType === 'COMBO') {
|
Object.assign(
|
||||||
Object.assign(
|
config,
|
||||||
config,
|
app.widgets[widgetType](
|
||||||
app.widgets.COMBO(
|
this,
|
||||||
this,
|
inputName,
|
||||||
inputName,
|
[inputType, inputSpec],
|
||||||
[inputType, inputSpec],
|
app
|
||||||
app
|
) ?? {}
|
||||||
) || {}
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
Object.assign(
|
|
||||||
config,
|
|
||||||
app.widgets[widgetType](
|
|
||||||
this,
|
|
||||||
inputName,
|
|
||||||
[inputType, inputSpec],
|
|
||||||
app
|
|
||||||
) || {}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
if (config.widget) {
|
if (config.widget) {
|
||||||
const fallback = config.widget.label ?? inputName
|
const fallback = config.widget.label ?? inputName
|
||||||
config.widget.label = st(nameKey, fallback)
|
config.widget.label = st(nameKey, fallback)
|
||||||
@@ -100,10 +87,9 @@ export const useLitegraphService = () => {
|
|||||||
...shapeOptions,
|
...shapeOptions,
|
||||||
localized_name: st(nameKey, inputName)
|
localized_name: st(nameKey, inputName)
|
||||||
})
|
})
|
||||||
widgetCreated = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (widgetCreated && config?.widget) {
|
if (widgetType && config?.widget) {
|
||||||
config.widget.options ??= {}
|
config.widget.options ??= {}
|
||||||
if (inputSpec.isOptional) {
|
if (inputSpec.isOptional) {
|
||||||
config.widget.options.inputIsOptional = true
|
config.widget.options.inputIsOptional = true
|
||||||
|
|||||||
Reference in New Issue
Block a user