mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-22 21:52:11 -03:00
- Add include/exclude folder modals for advanced filtering - Implement folder tree search with auto-expand functionality - Add hover tooltip to preview header showing matching LoRA thumbnails - Format match count with locale string for better readability - Prevent event propagation on refresh button click - Improve folder tree component with expand/collapse controls
93 lines
2.1 KiB
TypeScript
93 lines
2.1 KiB
TypeScript
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'
|
|
|
|
const vueApps = new Map<number, VueApp>()
|
|
|
|
// @ts-ignore
|
|
function createLoraPoolWidget(node) {
|
|
const container = document.createElement('div')
|
|
container.id = `lora-pool-widget-${node.id}`
|
|
container.style.width = '100%'
|
|
container.style.height = '100%'
|
|
container.style.display = 'flex'
|
|
container.style.flexDirection = 'column'
|
|
container.style.overflow = 'hidden'
|
|
|
|
let internalValue: LoraPoolConfig | LegacyLoraPoolConfig | undefined
|
|
|
|
const widget = node.addDOMWidget(
|
|
'pool_config',
|
|
'LORA_POOL_CONFIG',
|
|
container,
|
|
{
|
|
getValue() {
|
|
return internalValue
|
|
},
|
|
setValue(v: LoraPoolConfig | LegacyLoraPoolConfig) {
|
|
internalValue = v
|
|
if (typeof widget.onSetValue === 'function') {
|
|
widget.onSetValue(v)
|
|
}
|
|
},
|
|
serialize: true,
|
|
// Per dev guide: providing getMinHeight via options allows the system to
|
|
// skip expensive DOM measurements during rendering loop, improving performance
|
|
getMinHeight() {
|
|
return 400
|
|
}
|
|
}
|
|
)
|
|
|
|
widget.updateConfig = (v: LoraPoolConfig) => {
|
|
internalValue = v
|
|
}
|
|
|
|
const vueApp = createApp(LoraPoolWidget, {
|
|
widget,
|
|
node
|
|
})
|
|
|
|
vueApp.use(PrimeVue, {
|
|
unstyled: true,
|
|
ripple: false
|
|
})
|
|
|
|
vueApp.mount(container)
|
|
vueApps.set(node.id, vueApp)
|
|
|
|
widget.computeLayoutSize = () => {
|
|
const minWidth = 500
|
|
const minHeight = 400
|
|
|
|
return { minHeight, minWidth }
|
|
}
|
|
|
|
widget.onRemove = () => {
|
|
const vueApp = vueApps.get(node.id)
|
|
if (vueApp) {
|
|
vueApp.unmount()
|
|
vueApps.delete(node.id)
|
|
}
|
|
}
|
|
|
|
return { widget }
|
|
}
|
|
|
|
app.registerExtension({
|
|
name: 'LoraManager.VueWidgets',
|
|
|
|
getCustomWidgets() {
|
|
return {
|
|
// @ts-ignore
|
|
LORA_POOL_CONFIG(node) {
|
|
return createLoraPoolWidget(node)
|
|
}
|
|
}
|
|
}
|
|
})
|