From 4826c00e2759ee503cdc826c1d4fb4d427e9f0fc Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Thu, 9 Apr 2026 16:19:18 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=B2=BE=E6=B2=B9=E5=90=8D=E4=B8=8D?= =?UTF-8?q?=E6=88=AA=E6=96=AD=E6=94=B9=E7=94=A8clamp=E7=BC=A9=E6=94=BE?= =?UTF-8?q?=E3=80=81=E4=B8=8B=E6=9E=B6=E9=94=99=E8=AF=AF=E6=8F=90=E7=A4=BA?= =?UTF-8?q?=E3=80=81=E7=BF=BB=E8=AF=91=E5=8F=8C=E5=90=91=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 精油名: - 用 font-size:clamp() 自适应缩小,不截断不换行 - 去掉 overflow:hidden/text-overflow:ellipsis 信息不全判定: - 缺英文名、零售价、或会员价 = 红色底色 - 下架的不算不全 - 补全后自动恢复 下架功能: - 修复:添加详细错误信息显示 - 编辑弹窗宽度恢复到默认520px(不再限制400px) 翻译双向同步: - 配方卡片修改翻译 → 同时保存到 oils.en_name(oilsStore.saveOil) - 精油价目页修改英文名 → 保存到 oils.en_name - 两处共用同一个DB字段,loadOils后自动同步 - getCardOilName fallback链:custom → oilsMeta.enName → oilEn → name Co-Authored-By: Claude Opus 4.6 (1M context) --- .../src/components/RecipeDetailOverlay.vue | 27 ++++++++++++---- frontend/src/views/OilReference.vue | 32 +++++++++---------- 2 files changed, 36 insertions(+), 23 deletions(-) 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 @@