mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-21 21:22:11 -03:00
Add cache management feature: implement clear cache API and modal confirmation
This commit is contained in:
@@ -170,6 +170,18 @@ export class ModalManager {
|
||||
});
|
||||
}
|
||||
|
||||
// Add clearCacheModal registration
|
||||
const clearCacheModal = document.getElementById('clearCacheModal');
|
||||
if (clearCacheModal) {
|
||||
this.registerModal('clearCacheModal', {
|
||||
element: clearCacheModal,
|
||||
onClose: () => {
|
||||
this.getModal('clearCacheModal').element.classList.remove('show');
|
||||
document.body.classList.remove('modal-open');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Set up event listeners for modal toggles
|
||||
const supportToggle = document.getElementById('supportToggleBtn');
|
||||
if (supportToggle) {
|
||||
@@ -233,7 +245,7 @@ export class ModalManager {
|
||||
// Store current scroll position before showing modal
|
||||
this.scrollPosition = window.scrollY;
|
||||
|
||||
if (id === 'deleteModal' || id === 'excludeModal' || id === 'duplicateDeleteModal') {
|
||||
if (id === 'deleteModal' || id === 'excludeModal' || id === 'duplicateDeleteModal' || id === 'clearCacheModal') {
|
||||
modal.element.classList.add('show');
|
||||
} else {
|
||||
modal.element.style.display = 'block';
|
||||
|
||||
@@ -341,6 +341,37 @@ export class SettingsManager {
|
||||
}
|
||||
}
|
||||
|
||||
confirmClearCache() {
|
||||
// Show confirmation modal
|
||||
modalManager.showModal('clearCacheModal');
|
||||
}
|
||||
|
||||
async executeClearCache() {
|
||||
try {
|
||||
// Call the API endpoint to clear cache files
|
||||
const response = await fetch('/api/clear-cache', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
}
|
||||
});
|
||||
|
||||
const result = await response.json();
|
||||
|
||||
if (result.success) {
|
||||
showToast('Cache files have been cleared successfully. Cache will rebuild on next action.', 'success');
|
||||
} else {
|
||||
showToast(`Failed to clear cache: ${result.error}`, 'error');
|
||||
}
|
||||
|
||||
// Close the confirmation modal
|
||||
modalManager.closeModal('clearCacheModal');
|
||||
} catch (error) {
|
||||
showToast(`Error clearing cache: ${error.message}`, 'error');
|
||||
modalManager.closeModal('clearCacheModal');
|
||||
}
|
||||
}
|
||||
|
||||
async reloadContent() {
|
||||
if (this.currentPage === 'loras') {
|
||||
// Reload the loras without updating folders
|
||||
|
||||
Reference in New Issue
Block a user