feat(ui): add Open Source URL action to recipe modal header, align header styles with model modal

This commit is contained in:
Will Miao
2026-05-16 16:11:14 +08:00
parent ff240db5b1
commit 612612f1c7
3 changed files with 101 additions and 11 deletions

View File

@@ -383,6 +383,7 @@ class RecipeModal {
this.syncGenerationParams(hydratedRecipe.gen_params);
this.syncResourcesSection(hydratedRecipe);
this.syncSourceUrlAction();
// Show the modal
modalManager.showModal('recipeModal');
@@ -515,6 +516,7 @@ class RecipeModal {
} else {
this.updateSourceUrlDisplay(this.currentRecipe.source_path || '');
}
this.syncSourceUrlAction();
}
getPreviewMediaUrl(recipe = {}) {
@@ -582,6 +584,30 @@ class RecipeModal {
}
}
syncSourceUrlAction() {
const actionsContainer = document.getElementById('recipeHeaderActions');
if (!actionsContainer) {
return;
}
actionsContainer.innerHTML = '';
const sourcePath = this.currentRecipe?.source_path || '';
const isValidUrl = sourcePath.startsWith('http://') || sourcePath.startsWith('https://');
if (!isValidUrl) {
return;
}
const btn = document.createElement('button');
btn.className = 'recipe-source-url-btn';
btn.title = sourcePath;
btn.innerHTML = '<i class="fas fa-globe"></i> Open Source URL';
btn.addEventListener('click', () => {
window.open(sourcePath, '_blank');
});
actionsContainer.appendChild(btn);
}
syncTagsDisplay(tags) {
const tagsContainer = document.getElementById('recipeTagsCompact');
if (!tagsContainer) {
@@ -1316,6 +1342,7 @@ class RecipeModal {
// Update source URL in the UI
this.commitField('source_path');
this.updateSourceUrlDisplay(newSourceUrl, { forceInputSync: true });
this.syncSourceUrlAction();
// Update the current recipe object
this.currentRecipe.source_path = newSourceUrl;