diff --git a/frontend/src/components/RecipeDetailOverlay.vue b/frontend/src/components/RecipeDetailOverlay.vue index f5a5f47..61ba2b5 100644 --- a/frontend/src/components/RecipeDetailOverlay.vue +++ b/frontend/src/components/RecipeDetailOverlay.vue @@ -597,18 +597,33 @@ function copyText() { async function applyTranslation() { showTranslationEditor.value = false - // Persist en_name to backend + let saved = 0 + + // 1. Save recipe English name if (recipe.value._id && customRecipeNameEn.value) { try { await api.put(`/api/recipes/${recipe.value._id}`, { en_name: customRecipeNameEn.value, version: recipe.value._version, }) - ui.showToast('翻译已保存') - } catch (e) { - ui.showToast('翻译保存失败') - } + recipe.value.en_name = customRecipeNameEn.value + saved++ + } catch {} } + + // 2. Save each oil's English name to oils table (syncs with oil reference page) + for (const [oilName, enName] of Object.entries(customOilNameEn.value)) { + if (!enName?.trim()) continue + const meta = oilsStore.oilsMeta[oilName] + if (!meta || meta.enName === enName.trim()) continue + try { + await oilsStore.saveOil(oilName, meta.bottlePrice, meta.dropCount, meta.retailPrice, enName.trim()) + saved++ + } catch {} + } + + if (saved > 0) ui.showToast(`翻译已保存(${saved}项)`) + cardImageUrl.value = null nextTick(() => generateCardImage()) } @@ -616,7 +631,7 @@ async function applyTranslation() { // Override translation getters for card rendering function getCardOilName(name) { if (cardLang.value === 'en') { - return customOilNameEn.value[name] || oilEn(name) || name + return customOilNameEn.value[name] || oilsStore.oilsMeta[name]?.enName || oilEn(name) || name } return name } diff --git a/frontend/src/views/OilReference.vue b/frontend/src/views/OilReference.vue index 805d171..e5ec392 100644 --- a/frontend/src/views/OilReference.vue +++ b/frontend/src/views/OilReference.vue @@ -257,7 +257,7 @@