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

@@ -76,8 +76,6 @@ const openModal = (modal: ModalType) => {
// Lifecycle
onMounted(async () => {
console.log('[LoraPoolWidget] Mounted, node ID:', props.node.id)
// Setup serialization
props.widget.serializeValue = async () => {
const config = state.buildConfig()
@@ -85,6 +83,12 @@ onMounted(async () => {
return config
}
// Handle external value updates (e.g., loading workflow, paste)
props.widget.onSetValue = (v) => {
state.restoreFromConfig(v)
state.refreshPreview()
}
// Restore from saved value
if (props.widget.value) {
console.log('[LoraPoolWidget] Restoring from saved value:', props.widget.value)