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
69 lines
2.6 KiB
JavaScript
69 lines
2.6 KiB
JavaScript
import { BaseContextMenu } from './BaseContextMenu.js';
|
|
import { ModelContextMenuMixin } from './ModelContextMenuMixin.js';
|
|
import { resetAndReload } from '../../api/checkpointApi.js';
|
|
import { getModelApiClient } from '../../api/baseModelApi.js';
|
|
import { showToast } from '../../utils/uiHelpers.js';
|
|
import { showDeleteModal, showExcludeModal } from '../../utils/modalUtils.js';
|
|
|
|
export class CheckpointContextMenu extends BaseContextMenu {
|
|
constructor() {
|
|
super('checkpointContextMenu', '.lora-card');
|
|
this.nsfwSelector = document.getElementById('nsfwLevelSelector');
|
|
this.modelType = 'checkpoint';
|
|
this.resetAndReload = resetAndReload;
|
|
|
|
// Initialize NSFW Level Selector events
|
|
if (this.nsfwSelector) {
|
|
this.initNSFWSelector();
|
|
}
|
|
}
|
|
|
|
// Implementation needed by the mixin
|
|
async saveModelMetadata(filePath, data) {
|
|
return getModelApiClient().saveModelMetadata(filePath, data);
|
|
}
|
|
|
|
handleMenuAction(action) {
|
|
// First try to handle with common actions
|
|
if (ModelContextMenuMixin.handleCommonMenuActions.call(this, action)) {
|
|
return;
|
|
}
|
|
|
|
const apiClient = getModelApiClient();
|
|
|
|
// Otherwise handle checkpoint-specific actions
|
|
switch(action) {
|
|
case 'details':
|
|
// Show checkpoint details
|
|
this.currentCard.click();
|
|
break;
|
|
case 'replace-preview':
|
|
// Add new action for replacing preview images
|
|
apiClient.replaceModelPreview(this.currentCard.dataset.filepath);
|
|
break;
|
|
case 'delete':
|
|
showDeleteModal(this.currentCard.dataset.filepath);
|
|
break;
|
|
case 'copyname':
|
|
// Copy checkpoint name
|
|
if (this.currentCard.querySelector('.fa-copy')) {
|
|
this.currentCard.querySelector('.fa-copy').click();
|
|
}
|
|
break;
|
|
case 'refresh-metadata':
|
|
// Refresh metadata from CivitAI
|
|
apiClient.refreshSingleModelMetadata(this.currentCard.dataset.filepath);
|
|
break;
|
|
case 'move':
|
|
// Move to folder (placeholder)
|
|
showToast('Move to folder feature coming soon', 'info');
|
|
break;
|
|
case 'exclude':
|
|
showExcludeModal(this.currentCard.dataset.filepath);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Mix in shared methods
|
|
Object.assign(CheckpointContextMenu.prototype, ModelContextMenuMixin); |