- Update documentation to reflect new widget filename `lora-manager-widgets.js` - Remove `LoraManagerDemoNode` import and registration from `__init__.py` - Translate development guide from Chinese to English for broader accessibility - Clean up obsolete demo references to align with actual widget implementation
5.8 KiB
Vue + PrimeVue Widget Development Setup
This guide explains the Vue + PrimeVue widget development scaffold for ComfyUI LoRA Manager.
Overview
The project now supports developing custom ComfyUI widgets using Vue 3 + PrimeVue, providing a modern reactive framework for building rich UI components.
Architecture
ComfyUI-Lora-Manager/
├── vue-widgets/ # Vue widget source code (TypeScript)
│ ├── src/
│ │ ├── main.ts # Extension registration
│ │ └── components/ # Vue components
│ ├── package.json
│ ├── vite.config.mts # Build to web/comfyui/vue-widgets/
│ └── tsconfig.json
│
├── web/comfyui/ # ComfyUI web directory
│ ├── vue-widgets/ # Compiled Vue widgets (gitignored)
│ │ ├── lora-manager-widgets.js # Built JavaScript
│ │ └── assets/ # CSS and other assets
│ └── *.js # Existing vanilla JS widgets
│
├── py/nodes/ # Python node definitions
│ ├── demo_vue_widget_node.py # Demo node
│ └── ...
│
└── __init__.py # Node registration
Quick Start
1. Install Dependencies
cd vue-widgets
npm install
2. Build the Demo Widget
npm run build
This compiles the TypeScript/Vue code and outputs to web/comfyui/vue-widgets/.
3. Test in ComfyUI
- Start/restart ComfyUI
- Open the ComfyUI interface
- Add the "LoRA Manager Demo (Vue)" node from the node menu
- You should see a Vue-powered widget with PrimeVue components:
- Text input for model name
- Number input for strength (with +/- buttons)
- Apply and Reset buttons
- Result card showing current configuration
Development Workflow
Watch Mode for Development
cd vue-widgets
npm run dev
This watches for file changes and automatically rebuilds. You'll need to refresh ComfyUI's browser page to see changes.
Project Structure
Python Side (py/nodes/demo_vue_widget_node.py):
- Defines the ComfyUI node class
- Specifies input types (including the custom widget type)
- Implements the processing logic
- The widget type name must match the key in the frontend's
getCustomWidgets()
Frontend Side (vue-widgets/src/):
main.ts- Registers the extension with ComfyUI and creates Vue appscomponents/DemoWidget.vue- The actual Vue component with PrimeVue UI
Data Flow
-
Widget Creation:
- ComfyUI calls
getCustomWidgets()when creating a node - Creates a container DOM element
- Mounts a Vue app with the component inside the container
- ComfyUI calls
-
Widget State:
- Component props receive
widgetandnodeobjects from ComfyUI - Use Vue's reactive state management within the component
- Component props receive
-
Serialization:
- Implement
widget.serializeValue()inonMounted() - This function is called when the workflow is saved or executed
- Return the data that should be passed to the Python node
- Implement
-
Processing:
- Python node receives the serialized data in its
process()method - Process the data and return results to the workflow
- Python node receives the serialized data in its
Creating Your Own Widget
See the detailed guide in vue-widgets/README.md.
Quick checklist:
- Create Python node in
py/nodes/ - Create Vue component in
vue-widgets/src/components/ - Register widget in
vue-widgets/src/main.ts - Register node in
__init__.py - Build with
npm run build - Test in ComfyUI
Key Technologies
- Vue 3: Modern reactive framework with Composition API
- PrimeVue 4: Rich UI component library with 90+ components
- TypeScript: Type-safe development
- Vite: Fast build tool with HMR support
Build Configuration
The build is configured to:
- Output ES modules to
../web/comfyui/vue-widgets/ - Mark ComfyUI's
app.jsas external (not bundled) - Generate source maps for debugging
- Keep code unminified for easier debugging
- Split vendor code into separate chunks
PrimeVue Components
The demo widget showcases several PrimeVue components:
Button- Styled buttons with iconsInputText- Text input fieldsInputNumber- Number inputs with spinnersCard- Container component
For the full component library, see PrimeVue Documentation.
Troubleshooting
Build fails with module errors
- Make sure you're in the
vue-widgetsdirectory - Run
npm installto ensure all dependencies are installed - Check that Node.js version is 18+ (
node --version)
Widget doesn't appear in ComfyUI
- Verify the build completed successfully (
web/comfyui/vue-widgets/lora-manager-widgets.jsexists) - Check that the Python node is registered in
__init__.py - Restart ComfyUI completely (not just refresh browser)
- Check browser console for JavaScript errors
Widget type mismatch error
- Ensure the widget type in Python (e.g.,
"LORA_DEMO_WIDGET") matches the key ingetCustomWidgets() - Type names are case-sensitive
Changes not reflected after rebuild
- Hard refresh the browser (Ctrl+Shift+R / Cmd+Shift+R)
- Clear browser cache
- Restart ComfyUI server
Next Steps
Now that the scaffold is set up, you can:
- Extend the demo widget - Add more PrimeVue components and functionality
- Create production widgets - Build widgets for actual LoRA management features
- Add styling - Customize the look with CSS/Tailwind
- Add i18n - Implement vue-i18n for internationalization
- Add state management - Use Pinia if you need shared state across widgets
References
- ComfyUI Custom Nodes Documentation
- PrimeVue Documentation
- Vue 3 Documentation
- Vite Documentation
- Reference implementation:
/refs/ComfyUI_frontend_vue_basic