refactor: unify API client usage across models and remove deprecated API files

This commit is contained in:
Will Miao
2025-07-25 21:38:54 +08:00
parent c5a3af2399
commit 1a3751acfa
11 changed files with 26 additions and 173 deletions

View File

@@ -2,8 +2,7 @@ import { state, getCurrentPageState } from '../state/index.js';
import { VirtualScroller } from './VirtualScroller.js';
import { createLoraCard, setupLoraCardEventDelegation } from '../components/LoraCard.js';
import { createCheckpointCard, setupCheckpointCardEventDelegation } from '../components/CheckpointCard.js';
import { fetchLorasPage } from '../api/loraApi.js';
import { fetchCheckpointsPage } from '../api/checkpointApi.js';
import { getModelApiClient } from '../api/baseModelApi.js';
import { showToast } from './uiHelpers.js';
// Function to dynamically import the appropriate card creator based on page type
@@ -31,14 +30,12 @@ async function getCardCreator(pageType) {
// Function to get the appropriate data fetcher based on page type
async function getDataFetcher(pageType) {
if (pageType === 'loras') {
return fetchLorasPage;
if (pageType === 'loras' || pageType === 'embeddings' || pageType === 'checkpoints') {
return (page = 1, pageSize = 100) => getModelApiClient().fetchModelsPage(page, pageSize);
} else if (pageType === 'recipes') {
// Import the recipeApi module and use the fetchRecipesPage function
const { fetchRecipesPage } = await import('../api/recipeApi.js');
return fetchRecipesPage;
} else if (pageType === 'checkpoints') {
return fetchCheckpointsPage;
}
return null;
}