feat(lora-pool): add external value handling and config update support

- Add `onSetValue` callback to handle external updates like workflow loading
- Implement `updateConfig` method for direct widget value updates
- Add value change detection in `restoreFromConfig` to prevent unnecessary updates
- Remove debug console log on component mount
- Extend widget value type to support legacy config format
This commit is contained in:
Will Miao
2026-01-11 20:37:17 +08:00
parent b44ef9ceaa
commit 7a5f4514f3
6 changed files with 84 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
import { createApp, type App as VueApp } from 'vue'
import PrimeVue from 'primevue/config'
import LoraPoolWidget from '@/components/LoraPoolWidget.vue'
import type { LoraPoolConfig, LegacyLoraPoolConfig } from './composables/types'
// @ts-ignore - ComfyUI external module
import { app } from '../../../scripts/app.js'
@@ -17,16 +18,30 @@ function createLoraPoolWidget(node) {
container.style.flexDirection = 'column'
container.style.overflow = 'hidden'
let internalValue: LoraPoolConfig | LegacyLoraPoolConfig | undefined
const widget = node.addDOMWidget(
'pool_config',
'LORA_POOL_CONFIG',
container,
{
// getMinHeight: () => 680,
getValue() {
return internalValue
},
setValue(v: LoraPoolConfig | LegacyLoraPoolConfig) {
internalValue = v
if (typeof widget.onSetValue === 'function') {
widget.onSetValue(v)
}
},
serialize: true
}
)
widget.updateConfig = (v: LoraPoolConfig) => {
internalValue = v
}
const vueApp = createApp(LoraPoolWidget, {
widget,
node