Files
oil-formula-calculator/frontend/src/composables/useOilTranslation.js
Hera Zhao 3912e2d122
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 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Has been cancelled
fix: 价格字号随名称缩放、翻译表补全、编辑框全宽、下架修复
价格字号:
- 用 clamp() 跟精油名同步缩放
- 不再硬编码 13px/11px

翻译表 (useOilTranslation):
- 补充: 舒缓→Deep Blue, 保卫→On Guard, 乐活→DigestZen 等
- oilEn() 支持模糊匹配: 去掉/添加"复方""呵护"后缀再试

编辑弹窗:
- form-input 加 width:100% + box-sizing:border-box
- 去掉 max-width:400px 限制(已在上一次提交)

下架:
- 需要重启后端才能生效(OilIn model 变更需重启 uvicorn)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-09 16:28:34 +00:00

56 lines
2.3 KiB
JavaScript

// Oil English names map
const OIL_EN = {
'薰衣草': 'Lavender', '茶树': 'Tea Tree', '乳香': 'Frankincense',
'柠檬': 'Lemon', '椒样薄荷': 'Peppermint', '丝柏': 'Cypress',
'尤加利': 'Eucalyptus', '迷迭香': 'Rosemary', '天竺葵': 'Geranium',
'依兰依兰': 'Ylang Ylang', '佛手柑': 'Bergamot', '生姜': 'Ginger',
'没药': 'Myrrh', '檀香': 'Sandalwood', '雪松': 'Cedarwood',
'罗马洋甘菊': 'Roman Chamomile', '永久花': 'Helichrysum',
'快乐鼠尾草': 'Clary Sage', '广藿香': 'Patchouli',
'百里香': 'Thyme', '牛至': 'Oregano', '冬青': 'Wintergreen',
'肉桂': 'Cinnamon', '丁香': 'Clove', '黑胡椒': 'Black Pepper',
'葡萄柚': 'Grapefruit', '橙花': 'Neroli', '玫瑰': 'Rose',
'岩兰草': 'Vetiver', '马郁兰': 'Marjoram', '芫荽': 'Coriander',
'柠檬草': 'Lemongrass', '杜松浆果': 'Juniper Berry', '甜橙': 'Wild Orange',
'香茅': 'Citronella', '薄荷': 'Peppermint', '扁柏': 'Arborvitae',
'古巴香脂': 'Copaiba', '椰子油': 'Coconut Oil',
'芳香调理': 'AromaTouch', '保卫复方': 'On Guard', '保卫': 'On Guard',
'乐活复方': 'Balance', '乐活': 'DigestZen',
'舒缓复方': 'Past Tense', '舒缓': 'Deep Blue',
'净化复方': 'Purify', '净化清新': 'Purify',
'呼吸复方': 'Breathe', '顺畅呼吸': 'Breathe',
'舒压复方': 'Adaptiv', '安定情绪': 'Balance',
'安宁神气': 'Serenity', '多特瑞': 'doTERRA',
'野橘': 'Wild Orange', '柑橘清新': 'Citrus Bliss',
'新瑞活力': 'MetaPWR', '元气': 'Zendocrine',
'温柔呵护': 'ClaryCalm', '西洋蓍草': 'Yarrow|Pom',
'西班牙牛至': 'Oregano',
}
export function oilEn(name) {
if (OIL_EN[name]) return OIL_EN[name]
// Try without common suffixes
const base = name.replace(/复方$|呵护$/, '')
if (base !== name && OIL_EN[base]) return OIL_EN[base]
// Try adding suffixes
if (OIL_EN[name + '复方']) return OIL_EN[name + '复方']
return ''
}
export function recipeNameEn(name) {
// Try to translate known keywords
// Simple approach: return original name for now, user can customize
return name
}
// Custom translations (can be set by admin)
const customTranslations = {}
export function setCustomTranslation(zhName, enName) {
customTranslations[zhName] = enName
}
export function getCustomTranslation(zhName) {
return customTranslations[zhName]
}