Add bulk operation

This commit is contained in:
Will Miao
2025-03-07 13:15:39 +08:00
parent 69b1773ced
commit 0c4914909a
10 changed files with 471 additions and 44 deletions

View File

@@ -27,8 +27,14 @@ import { SettingsManager, toggleApiKeyVisibility } from './managers/SettingsMana
import { LoraContextMenu } from './components/ContextMenu.js';
import { moveManager } from './managers/MoveManager.js';
import { FilterManager } from './managers/FilterManager.js';
import { createLoraCard, updateCardsForBulkMode } from './components/LoraCard.js';
import { bulkManager } from './managers/BulkManager.js';
// Export all functions that need global access
// Add bulk mode to state
state.bulkMode = false;
state.selectedLoras = new Set();
// Export functions to global window object
window.loadMoreLoras = loadMoreLoras;
window.fetchCivitai = fetchCivitai;
window.deleteModel = deleteModel;
@@ -51,6 +57,14 @@ window.moveManager = moveManager;
window.toggleShowcase = toggleShowcase;
window.scrollToTop = scrollToTop;
// Export bulk manager methods to window
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;
// Initialize everything when DOM is ready
document.addEventListener('DOMContentLoaded', async () => {
state.loadingManager = new LoadingManager();
@@ -73,6 +87,12 @@ document.addEventListener('DOMContentLoaded', async () => {
initBackToTop();
window.searchManager = new SearchManager();
new LoraContextMenu();
// Initialize cards for current bulk mode state (should be false initially)
updateCardsForBulkMode(state.bulkMode);
// Initialize the bulk manager
bulkManager.initialize();
});
// Initialize event listeners