feat: refactor API routes for renaming models and update related functions

This commit is contained in:
Will Miao
2025-06-25 19:38:38 +08:00
parent 7f523f167d
commit 8931b41c76
10 changed files with 151 additions and 343 deletions

View File

@@ -2,47 +2,6 @@
* Utility functions to update checkpoint cards after modal edits
*/
/**
* Update the Lora card after metadata edits in the modal
* @param {string} filePath - Path to the Lora file
* @param {Object} updates - Object containing the updates (model_name, base_model, notes, usage_tips, etc)
*/
export function updateModelCard(filePath, updates) {
// Find the card with matching filepath
const modelCard = document.querySelector(`.lora-card[data-filepath="${filePath}"]`);
if (!modelCard) return;
// Update card dataset and visual elements based on the updates object
Object.entries(updates).forEach(([key, value]) => {
// Update dataset
modelCard.dataset[key] = value;
// Update visual elements based on the property
switch(key) {
case 'model_name':
// Update the model name in the card title
const titleElement = modelCard.querySelector('.card-title');
if (titleElement) titleElement.textContent = value;
// Also update the model name in the footer if it exists
const modelNameElement = modelCard.querySelector('.model-name');
if (modelNameElement) modelNameElement.textContent = value;
break;
case 'base_model':
// Update the base model label in the card header if it exists
const baseModelLabel = modelCard.querySelector('.base-model-label');
if (baseModelLabel) {
baseModelLabel.textContent = value;
baseModelLabel.title = value;
}
break;
}
});
return modelCard; // Return the updated card element for chaining
}
/**
* Update the recipe card after metadata edits in the modal
* @param {string} recipeId - ID of the recipe to update