mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-23 14:12:11 -03:00
- Introduced MODEL_TYPES and MODEL_CONFIG for centralized model type management. - Created a unified API client for checkpoints and loras to streamline operations. - Updated all API calls in checkpointApi.js and loraApi.js to use the new client. - Simplified context menus and model card operations to leverage the unified API client. - Enhanced state management to accommodate new model types and their configurations. - Added virtual scrolling functions for recipes and improved loading states. - Refactored modal utilities to handle model exclusion and deletion generically. - Improved error handling and user feedback across various operations.
43 lines
2.1 KiB
JavaScript
43 lines
2.1 KiB
JavaScript
import { createModelApiClient } from './baseModelApi.js';
|
|
import { MODEL_TYPES } from './apiConfig.js';
|
|
|
|
// Create Checkpoint-specific API client
|
|
const checkpointApiClient = createModelApiClient(MODEL_TYPES.CHECKPOINT);
|
|
|
|
// Export all common operations using the unified client
|
|
export const deleteModel = (filePath) => checkpointApiClient.deleteModel(filePath);
|
|
export const excludeCheckpoint = (filePath) => checkpointApiClient.excludeModel(filePath);
|
|
export const renameCheckpointFile = (filePath, newFileName) => checkpointApiClient.renameModelFile(filePath, newFileName);
|
|
export const replacePreview = (filePath) => checkpointApiClient.replaceModelPreview(filePath);
|
|
export const saveModelMetadata = (filePath, data) => checkpointApiClient.saveModelMetadata(filePath, data);
|
|
export const refreshCheckpoints = (fullRebuild = false) => checkpointApiClient.refreshModels(fullRebuild);
|
|
export const refreshSingleCheckpointMetadata = (filePath) => checkpointApiClient.refreshSingleModelMetadata(filePath);
|
|
export const fetchCivitai = (resetAndReloadFunction) => checkpointApiClient.fetchCivitaiMetadata(resetAndReloadFunction);
|
|
|
|
// Pagination functions
|
|
export const fetchCheckpointsPage = (page = 1, pageSize = 50) => checkpointApiClient.fetchModelsPage(page, pageSize);
|
|
|
|
// Virtual scrolling operations
|
|
export async function loadMoreCheckpoints(resetPage = false, updateFolders = false) {
|
|
return checkpointApiClient.loadMoreWithVirtualScroll(resetPage, updateFolders);
|
|
}
|
|
|
|
export async function resetAndReload(updateFolders = false) {
|
|
return checkpointApiClient.resetAndReloadWithVirtualScroll(updateFolders);
|
|
}
|
|
|
|
// Checkpoint-specific functions
|
|
export async function getCheckpointInfo(name) {
|
|
try {
|
|
const response = await fetch(`${checkpointApiClient.apiConfig.endpoints.specific.info}/${encodeURIComponent(name)}`);
|
|
|
|
if (!response.ok) {
|
|
throw new Error(`Failed to fetch checkpoint info: ${response.statusText}`);
|
|
}
|
|
|
|
return await response.json();
|
|
} catch (error) {
|
|
console.error('Error fetching checkpoint info:', error);
|
|
throw error;
|
|
}
|
|
} |