mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
- Add download-related methods to baseModelApi.js for fetching versions, roots, folders, and downloading models - Replace separate download managers with a unified DownloadManager.js supporting all model types - Create a single download_modals.html template that adapts to model type (LoRA, checkpoint, etc.) - Remove old download modals from lora_modals.html and checkpoint_modals.html - Update apiConfig.js to include civitaiVersions endpoints for each model type - Centralize event handler binding in DownloadManager.js (no more inline HTML handlers) - Modal UI and logic now auto-adapt to the current model type, making future extension easier
77 lines
3.1 KiB
JavaScript
77 lines
3.1 KiB
JavaScript
import { appCore } from './core.js';
|
|
import { state } from './state/index.js';
|
|
import { loadMoreLoras } from './api/loraApi.js';
|
|
import { updateCardsForBulkMode } from './components/LoraCard.js';
|
|
import { bulkManager } from './managers/BulkManager.js';
|
|
import { moveManager } from './managers/MoveManager.js';
|
|
import { LoraContextMenu } from './components/ContextMenu/index.js';
|
|
import { createPageControls } from './components/controls/index.js';
|
|
import { confirmDelete, closeDeleteModal, confirmExclude, closeExcludeModal } from './utils/modalUtils.js';
|
|
import { ModelDuplicatesManager } from './components/ModelDuplicatesManager.js';
|
|
|
|
// Initialize the LoRA page
|
|
class LoraPageManager {
|
|
constructor() {
|
|
// Add bulk mode to state
|
|
state.bulkMode = false;
|
|
state.selectedLoras = new Set();
|
|
|
|
// Initialize page controls
|
|
this.pageControls = createPageControls('loras');
|
|
|
|
// Initialize the ModelDuplicatesManager
|
|
this.duplicatesManager = new ModelDuplicatesManager(this);
|
|
|
|
// Expose necessary functions to the page that still need global access
|
|
// These will be refactored in future updates
|
|
this._exposeRequiredGlobalFunctions();
|
|
}
|
|
|
|
_exposeRequiredGlobalFunctions() {
|
|
// Only expose what's still needed globally
|
|
// Most functionality is now handled by the PageControls component
|
|
window.loadMoreLoras = loadMoreLoras;
|
|
window.confirmDelete = confirmDelete;
|
|
window.closeDeleteModal = closeDeleteModal;
|
|
window.confirmExclude = confirmExclude;
|
|
window.closeExcludeModal = closeExcludeModal;
|
|
window.moveManager = moveManager;
|
|
|
|
// Bulk operations
|
|
window.toggleBulkMode = () => bulkManager.toggleBulkMode();
|
|
window.clearSelection = () => bulkManager.clearSelection();
|
|
window.toggleCardSelection = (card) => bulkManager.toggleCardSelection(card);
|
|
window.copyAllLorasSyntax = () => bulkManager.copyAllLorasSyntax();
|
|
window.updateSelectedCount = () => bulkManager.updateSelectedCount();
|
|
window.bulkManager = bulkManager;
|
|
|
|
// Expose duplicates manager
|
|
window.modelDuplicatesManager = this.duplicatesManager;
|
|
}
|
|
|
|
async initialize() {
|
|
// Initialize page-specific components
|
|
this.pageControls.restoreFolderFilter();
|
|
this.pageControls.initFolderTagsVisibility();
|
|
new LoraContextMenu();
|
|
|
|
// Initialize cards for current bulk mode state (should be false initially)
|
|
updateCardsForBulkMode(state.bulkMode);
|
|
|
|
// Initialize the bulk manager
|
|
bulkManager.initialize();
|
|
|
|
// Initialize common page features (virtual scroll)
|
|
appCore.initializePageFeatures();
|
|
}
|
|
}
|
|
|
|
// Initialize everything when DOM is ready
|
|
document.addEventListener('DOMContentLoaded', async () => {
|
|
// Initialize core application
|
|
await appCore.initialize();
|
|
|
|
// Initialize page-specific functionality
|
|
const loraPage = new LoraPageManager();
|
|
await loraPage.initialize();
|
|
}); |