fix: 精油名不截断改用clamp缩放、下架错误提示、翻译双向同步
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Failing after 1m27s

精油名:
- 用 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) <noreply@anthropic.com>
This commit is contained in:
2026-04-09 16:19:18 +00:00
parent 2a823e5bac
commit 4826c00e27
2 changed files with 36 additions and 23 deletions

View File

@@ -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
}