Enhance recipe metadata handling in RecipeRoutes and ExifUtils

- Added functionality to extract and process existing recipe metadata from images, including LoRA details and Civitai information.
- Updated ExifUtils to manage recipe metadata more effectively, including appending and removing metadata from user comments.
- Improved the ImportManager to utilize recipe metadata for setting default recipe names and tags when importing shared recipes.
This commit is contained in:
Will Miao
2025-03-18 16:49:04 +08:00
parent 78f8d4ecc7
commit 4264dd19a8
3 changed files with 167 additions and 34 deletions

View File

@@ -211,7 +211,21 @@ export class ImportManager {
// Set default recipe name from prompt or image filename
const recipeName = document.getElementById('recipeName');
if (this.recipeData && this.recipeData.gen_params && this.recipeData.gen_params.prompt) {
// Check if we have recipe metadata from a shared recipe
if (this.recipeData && this.recipeData.from_recipe_metadata) {
// Use title from recipe metadata
if (this.recipeData.title) {
recipeName.value = this.recipeData.title;
this.recipeName = this.recipeData.title;
}
// Use tags from recipe metadata
if (this.recipeData.tags && Array.isArray(this.recipeData.tags)) {
this.recipeTags = [...this.recipeData.tags];
this.updateTagsDisplay();
}
} else if (this.recipeData && this.recipeData.gen_params && this.recipeData.gen_params.prompt) {
// Use the first 15 words from the prompt as the default recipe name
const promptWords = this.recipeData.gen_params.prompt.split(' ');
const truncatedPrompt = promptWords.slice(0, 15).join(' ');
@@ -232,6 +246,14 @@ export class ImportManager {
this.recipeName = fileName;
}
// Always set up click handler for easy editing if not already set
if (!recipeName.hasSelectAllHandler) {
recipeName.addEventListener('click', function() {
this.select();
});
recipeName.hasSelectAllHandler = true;
}
// Display the uploaded image in the preview
const imagePreview = document.getElementById('recipeImagePreview');
if (imagePreview && this.recipeImage) {