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

@@ -156,7 +156,7 @@ class AutoComplete {
async search(term = '') {
try {
this.currentSearchTerm = term;
const response = await api.fetchApi(`/${this.modelType}/relative-paths?search=${encodeURIComponent(term)}&limit=${this.options.maxItems}`);
const response = await api.fetchApi(`/lm/${this.modelType}/relative-paths?search=${encodeURIComponent(term)}&limit=${this.options.maxItems}`);
const data = await response.json();
if (data.success && data.relative_paths && data.relative_paths.length > 0) {
@@ -383,7 +383,7 @@ class AutoComplete {
// Get usage tips and extract strength
let strength = 1.0; // Default strength
try {
const response = await api.fetchApi(`/loras/usage-tips-by-path?relative_path=${encodeURIComponent(relativePath)}`);
const response = await api.fetchApi(`/lm/loras/usage-tips-by-path?relative_path=${encodeURIComponent(relativePath)}`);
if (response.ok) {
const data = await response.json();
if (data.success && data.usage_tips) {

View File

@@ -269,7 +269,7 @@ export class PreviewTooltip {
this.currentLora = loraName;
// Get preview URL
const response = await api.fetchApi(`/loras/preview-url?name=${encodeURIComponent(loraName)}`, {
const response = await api.fetchApi(`/lm/loras/preview-url?name=${encodeURIComponent(loraName)}`, {
method: 'GET'
});

View File

@@ -491,7 +491,7 @@ export function createContextMenu(x, y, loraName, widget, previewTooltip, render
try {
// Get Civitai URL from API
const response = await api.fetchApi(`/loras/civitai-url?name=${encodeURIComponent(loraName)}`, {
const response = await api.fetchApi(`/lm/loras/civitai-url?name=${encodeURIComponent(loraName)}`, {
method: 'GET'
});
@@ -547,7 +547,7 @@ export function createContextMenu(x, y, loraName, widget, previewTooltip, render
try {
// Get notes from API
const response = await api.fetchApi(`/loras/get-notes?name=${encodeURIComponent(loraName)}`, {
const response = await api.fetchApi(`/lm/loras/get-notes?name=${encodeURIComponent(loraName)}`, {
method: 'GET'
});
@@ -584,7 +584,7 @@ export function createContextMenu(x, y, loraName, widget, previewTooltip, render
try {
// Get trigger words from API
const response = await api.fetchApi(`/loras/get-trigger-words?name=${encodeURIComponent(loraName)}`, {
const response = await api.fetchApi(`/lm/loras/get-trigger-words?name=${encodeURIComponent(loraName)}`, {
method: 'GET'
});

View File

@@ -70,7 +70,7 @@ export async function saveRecipeDirectly() {
}
// Send the request to the backend API
const response = await fetch('/api/recipes/save-from-widget', {
const response = await fetch('/api/lm/recipes/save-from-widget', {
method: 'POST'
});

View File

@@ -107,7 +107,7 @@ const initializeWidgets = () => {
// Fetch version info from the API
const fetchVersionInfo = async () => {
try {
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

@@ -38,7 +38,7 @@ app.registerExtension({
async updateUsageStats(promptId) {
try {
// Call backend endpoint with the prompt_id
const response = await fetch(`/api/update-usage-stats`, {
const response = await fetch(`/api/lm/update-usage-stats`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -79,7 +79,7 @@ app.registerExtension({
}
}
const response = await fetch('/api/register-nodes', {
const response = await fetch('/api/lm/register-nodes', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
@@ -158,7 +158,7 @@ app.registerExtension({
try {
// Search for current relative path
const response = await api.fetchApi(`/${modelType}/relative-paths?search=${encodeURIComponent(fileName)}&limit=2`);
const response = await api.fetchApi(`/lm/${modelType}/relative-paths?search=${encodeURIComponent(fileName)}&limit=2`);
const data = await response.json();
if (!data.success || !data.relative_paths || data.relative_paths.length === 0) {