Refactor API endpoints to use '/api/lm/' prefix

- Updated all relevant routes in `stats_routes.py` and `update_routes.py` to include the new '/api/lm/' prefix for consistency.
- Modified API endpoint configurations in `apiConfig.js` to reflect the new structure, ensuring all CRUD and bulk operations are correctly routed.
- Adjusted fetch calls in various components and managers to utilize the updated API paths, including recipe, model, and example image operations.
- Ensured all instances of the old API paths were replaced with the new '/api/lm/' prefix across the codebase for uniformity and to prevent broken links.
This commit is contained in:
Will Miao
2025-09-18 14:50:40 +08:00
parent ded17c1479
commit bdc86ddf15
40 changed files with 225 additions and 225 deletions

View File

@@ -172,7 +172,7 @@ export class ExampleImagesManager {
async checkDownloadStatus() {
try {
const response = await fetch('/api/example-images-status');
const response = await fetch('/api/lm/example-images-status');
const data = await response.json();
if (data.success) {
@@ -236,7 +236,7 @@ export class ExampleImagesManager {
const optimize = state.global.settings.optimizeExampleImages;
const response = await fetch('/api/download-example-images', {
const response = await fetch('/api/lm/download-example-images', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -278,7 +278,7 @@ export class ExampleImagesManager {
}
try {
const response = await fetch('/api/pause-example-images', {
const response = await fetch('/api/lm/pause-example-images', {
method: 'POST'
});
@@ -314,7 +314,7 @@ export class ExampleImagesManager {
}
try {
const response = await fetch('/api/resume-example-images', {
const response = await fetch('/api/lm/resume-example-images', {
method: 'POST'
});
@@ -358,7 +358,7 @@ export class ExampleImagesManager {
async updateProgress() {
try {
const response = await fetch('/api/example-images-status');
const response = await fetch('/api/lm/example-images-status');
const data = await response.json();
if (data.success) {
@@ -727,7 +727,7 @@ export class ExampleImagesManager {
const outputDir = document.getElementById('exampleImagesPath').value;
const optimize = state.global.settings.optimizeExampleImages;
const response = await fetch('/api/download-example-images', {
const response = await fetch('/api/lm/download-example-images', {
method: 'POST',
headers: {
'Content-Type': 'application/json'

View File

@@ -66,7 +66,7 @@ export class FilterManager {
tagsContainer.innerHTML = '<div class="tags-loading">Loading tags...</div>';
// Determine the API endpoint based on the page type
const tagsEndpoint = `/api/${this.currentPage}/top-tags?limit=20`;
const tagsEndpoint = `/api/lm/${this.currentPage}/top-tags?limit=20`;
const response = await fetch(tagsEndpoint);
if (!response.ok) throw new Error('Failed to fetch tags');
@@ -134,7 +134,7 @@ export class FilterManager {
if (!baseModelTagsContainer) return;
// Set the API endpoint based on current page
const apiEndpoint = `/api/${this.currentPage}/base-models`;
const apiEndpoint = `/api/lm/${this.currentPage}/base-models`;
// Fetch base models
fetch(apiEndpoint)

View File

@@ -429,7 +429,7 @@ export class SettingsManager {
if (!defaultLoraRootSelect) return;
// Fetch lora roots
const response = await fetch('/api/loras/roots');
const response = await fetch('/api/lm/loras/roots');
if (!response.ok) {
throw new Error('Failed to fetch LoRA roots');
}
@@ -468,7 +468,7 @@ export class SettingsManager {
if (!defaultCheckpointRootSelect) return;
// Fetch checkpoint roots
const response = await fetch('/api/checkpoints/roots');
const response = await fetch('/api/lm/checkpoints/roots');
if (!response.ok) {
throw new Error('Failed to fetch checkpoint roots');
}
@@ -507,7 +507,7 @@ export class SettingsManager {
if (!defaultEmbeddingRootSelect) return;
// Fetch embedding roots
const response = await fetch('/api/embeddings/roots');
const response = await fetch('/api/lm/embeddings/roots');
if (!response.ok) {
throw new Error('Failed to fetch embedding roots');
}
@@ -1023,7 +1023,7 @@ export class SettingsManager {
async updateMetadataArchiveStatus() {
try {
const response = await fetch('/api/metadata-archive-status');
const response = await fetch('/api/lm/metadata-archive-status');
const data = await response.json();
const statusContainer = document.getElementById('metadataArchiveStatus');
@@ -1152,7 +1152,7 @@ export class SettingsManager {
// Wait for WebSocket to be ready
await wsReady;
const response = await fetch(`/api/download-metadata-archive?download_id=${encodeURIComponent(actualDownloadId)}`, {
const response = await fetch(`/api/lm/download-metadata-archive?download_id=${encodeURIComponent(actualDownloadId)}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -1215,7 +1215,7 @@ export class SettingsManager {
removeBtn.textContent = translate('settings.metadataArchive.removingButton');
}
const response = await fetch('/api/remove-metadata-archive', {
const response = await fetch('/api/lm/remove-metadata-archive', {
method: 'POST',
headers: {
'Content-Type': 'application/json'

View File

@@ -97,7 +97,7 @@ export class UpdateService {
try {
// Call backend API to check for updates with nightly flag
const response = await fetch(`/api/check-updates?nightly=${this.nightlyMode}`);
const response = await fetch(`/api/lm/check-updates?nightly=${this.nightlyMode}`);
const data = await response.json();
if (data.success) {
@@ -280,7 +280,7 @@ export class UpdateService {
// Update progress
this.updateProgress(10, translate('update.updateProgress.preparing'));
const response = await fetch('/api/perform-update', {
const response = await fetch('/api/lm/perform-update', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -444,7 +444,7 @@ export class UpdateService {
async checkVersionInfo() {
try {
// Call API to get current version info
const response = await fetch('/api/version-info');
const response = await fetch('/api/lm/version-info');
const data = await response.json();
if (data.success) {

View File

@@ -68,7 +68,7 @@ export class DownloadManager {
formData.append('metadata', JSON.stringify(completeMetadata));
// Send save request
const response = await fetch('/api/recipes/save', {
const response = await fetch('/api/lm/recipes/save', {
method: 'POST',
body: formData
});

View File

@@ -100,7 +100,7 @@ export class FolderBrowser {
}
// Fetch LoRA roots
const rootsResponse = await fetch('/api/loras/roots');
const rootsResponse = await fetch('/api/lm/loras/roots');
if (!rootsResponse.ok) {
throw new Error(`Failed to fetch LoRA roots: ${rootsResponse.status}`);
}
@@ -120,7 +120,7 @@ export class FolderBrowser {
}
// Fetch folders
const foldersResponse = await fetch('/api/loras/folders');
const foldersResponse = await fetch('/api/lm/loras/folders');
if (!foldersResponse.ok) {
throw new Error(`Failed to fetch folders: ${foldersResponse.status}`);
}

View File

@@ -62,7 +62,7 @@ export class ImageProcessor {
async analyzeImageFromUrl(url) {
try {
// Call the API with URL data
const response = await fetch('/api/recipes/analyze-image', {
const response = await fetch('/api/lm/recipes/analyze-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -110,7 +110,7 @@ export class ImageProcessor {
async analyzeImageFromLocalPath(path) {
try {
// Call the API with local path data
const response = await fetch('/api/recipes/analyze-local-image', {
const response = await fetch('/api/lm/recipes/analyze-local-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
@@ -169,7 +169,7 @@ export class ImageProcessor {
formData.append('image', this.importManager.recipeImage);
// Upload image for analysis
const response = await fetch('/api/recipes/analyze-image', {
const response = await fetch('/api/lm/recipes/analyze-image', {
method: 'POST',
body: formData
});