mirror of
https://github.com/willmiao/ComfyUI-Lora-Manager.git
synced 2026-03-25 07:05:43 -03:00
refactor: simplify API endpoint construction in FilterManager for top tags and base models
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
import { BASE_MODEL_CLASSES } from '../utils/constants.js';
|
|
||||||
import { getCurrentPageState } from '../state/index.js';
|
import { getCurrentPageState } from '../state/index.js';
|
||||||
import { showToast, updatePanelPositions } from '../utils/uiHelpers.js';
|
import { showToast, updatePanelPositions } from '../utils/uiHelpers.js';
|
||||||
import { getModelApiClient } from '../api/baseModelApi.js';
|
import { getModelApiClient } from '../api/baseModelApi.js';
|
||||||
@@ -67,14 +66,7 @@ export class FilterManager {
|
|||||||
tagsContainer.innerHTML = '<div class="tags-loading">Loading tags...</div>';
|
tagsContainer.innerHTML = '<div class="tags-loading">Loading tags...</div>';
|
||||||
|
|
||||||
// Determine the API endpoint based on the page type
|
// Determine the API endpoint based on the page type
|
||||||
let tagsEndpoint = '/api/loras/top-tags?limit=20';
|
const tagsEndpoint = `/api/${this.currentPage}/top-tags?limit=20`;
|
||||||
if (this.currentPage === 'recipes') {
|
|
||||||
tagsEndpoint = '/api/recipes/top-tags?limit=20';
|
|
||||||
} else if (this.currentPage === 'checkpoints') {
|
|
||||||
tagsEndpoint = '/api/checkpoints/top-tags?limit=20';
|
|
||||||
} else if (this.currentPage === 'embeddings') {
|
|
||||||
tagsEndpoint = '/api/embeddings/top-tags?limit=20';
|
|
||||||
}
|
|
||||||
|
|
||||||
const response = await fetch(tagsEndpoint);
|
const response = await fetch(tagsEndpoint);
|
||||||
if (!response.ok) throw new Error('Failed to fetch tags');
|
if (!response.ok) throw new Error('Failed to fetch tags');
|
||||||
@@ -141,19 +133,8 @@ export class FilterManager {
|
|||||||
const baseModelTagsContainer = document.getElementById('baseModelTags');
|
const baseModelTagsContainer = document.getElementById('baseModelTags');
|
||||||
if (!baseModelTagsContainer) return;
|
if (!baseModelTagsContainer) return;
|
||||||
|
|
||||||
// Set the appropriate API endpoint based on current page
|
// Set the API endpoint based on current page
|
||||||
let apiEndpoint = '';
|
const apiEndpoint = `/api/${this.currentPage}/base-models`;
|
||||||
if (this.currentPage === 'loras') {
|
|
||||||
apiEndpoint = '/api/loras/base-models';
|
|
||||||
} else if (this.currentPage === 'recipes') {
|
|
||||||
apiEndpoint = '/api/recipes/base-models';
|
|
||||||
} else if (this.currentPage === 'checkpoints') {
|
|
||||||
apiEndpoint = '/api/checkpoints/base-models';
|
|
||||||
} else if (this.currentPage === 'embeddings') {
|
|
||||||
apiEndpoint = '/api/embeddings/base-models';
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Fetch base models
|
// Fetch base models
|
||||||
fetch(apiEndpoint)
|
fetch(apiEndpoint)
|
||||||
|
|||||||
Reference in New Issue
Block a user