mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Refactor Lora widget and dynamic module loading
- Updated lora_loader.js to dynamically import the appropriate loras widget based on ComfyUI version, enhancing compatibility and maintainability. - Enhanced loras_widget.js with improved height management and styling for better user experience. - Introduced utility functions in utils.js for version checking and dynamic imports, streamlining widget loading processes. - Improved overall structure and readability of the code, ensuring better performance and easier future updates.
This commit is contained in:
@@ -1,5 +1,32 @@
|
||||
export const CONVERTED_TYPE = 'converted-widget';
|
||||
|
||||
export function getComfyUIFrontendVersion() {
|
||||
return window['__COMFYUI_FRONTEND_VERSION__'] || "0.0.0";
|
||||
}
|
||||
|
||||
// Dynamically import the appropriate widget based on app version
|
||||
export async function dynamicImportByVersion(latestModulePath, legacyModulePath) {
|
||||
// Parse app version and compare with 1.12.6 (version when tags widget API changed)
|
||||
const currentVersion = getComfyUIFrontendVersion();
|
||||
const versionParts = currentVersion.split('.').map(part => parseInt(part, 10));
|
||||
const requiredVersion = [1, 12, 6];
|
||||
|
||||
// Compare version numbers
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (versionParts[i] > requiredVersion[i]) {
|
||||
console.log(`Using latest widget: ${latestModulePath}`);
|
||||
return import(latestModulePath);
|
||||
} else if (versionParts[i] < requiredVersion[i]) {
|
||||
console.log(`Using legacy widget: ${legacyModulePath}`);
|
||||
return import(legacyModulePath);
|
||||
}
|
||||
}
|
||||
|
||||
// If we get here, versions are equal, use the latest module
|
||||
console.log(`Using latest widget: ${latestModulePath}`);
|
||||
return import(latestModulePath);
|
||||
}
|
||||
|
||||
export function hideWidgetForGood(node, widget, suffix = "") {
|
||||
widget.origType = widget.type;
|
||||
widget.origComputeSize = widget.computeSize;
|
||||
|
||||
Reference in New Issue
Block a user