feat: 非精油产品(drop_count=1)显示"份"而非"滴"
All checks were successful
Test / unit-test (push) Successful in 5s
PR Preview / teardown-preview (pull_request) Has been skipped
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Successful in 54s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 13s

oils store新增 unitLabel/unitLabelPlural,根据 dropCount 判断:
- 精油(dropCount>1): 滴/drop
- 护肤品等(dropCount=1): 份/portion
影响: 配方卡片、个人配方、库存匹配、去重提示

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-13 14:25:41 +00:00
parent abc54f2d6a
commit 67d268bc92
5 changed files with 23 additions and 5 deletions

View File

@@ -64,7 +64,7 @@
<ul style="list-style:none;margin-bottom:20px;padding:0">
<li v-for="(ing, i) in cardIngredients" :key="i" class="ec-ing">
<span class="ec-oil-name">{{ getCardOilName(ing.oil) }}</span>
<span class="ec-drops">{{ ing.drops }} {{ cardLang === 'en' ? (ing.drops === 1 ? 'drop' : 'drops') : '滴' }}</span>
<span class="ec-drops">{{ ing.drops }} {{ oilsStore.unitLabelPlural(ing.oil, ing.drops, cardLang) }}</span>
<span class="ec-cost">{{ oilsStore.fmtPrice(oilsStore.pricePerDrop(ing.oil) * ing.drops) }}</span>
<span v-if="hasRetailForOil(ing.oil) && retailPerDrop(ing.oil) > oilsStore.pricePerDrop(ing.oil)" class="ec-retail">{{ oilsStore.fmtPrice(retailPerDrop(ing.oil) * ing.drops) }}</span>
</li>

View File

@@ -93,6 +93,21 @@ export const useOilsStore = defineStore('oils', () => {
delete oilsMeta.value[name]
}
function isPortionUnit(name) {
const meta = oilsMeta.value[name]
return meta && meta.dropCount === 1
}
function unitLabel(name, lang = 'zh') {
if (isPortionUnit(name)) return lang === 'en' ? 'portion' : '份'
return lang === 'en' ? 'drop' : '滴'
}
function unitLabelPlural(name, count, lang = 'zh') {
if (isPortionUnit(name)) return lang === 'en' ? (count === 1 ? 'portion' : 'portions') : '份'
return lang === 'en' ? (count === 1 ? 'drop' : 'drops') : '滴'
}
return {
oils,
oilsMeta,
@@ -105,5 +120,8 @@ export const useOilsStore = defineStore('oils', () => {
loadOils,
saveOil,
deleteOil,
isPortionUnit,
unitLabel,
unitLabelPlural,
}
})

View File

@@ -76,7 +76,7 @@
class="match-ing"
:class="{ missing: !ownedSet.has(ing.oil) }"
>
{{ ing.oil }} {{ ing.drops }}
{{ ing.oil }} {{ ing.drops }}{{ oils.unitLabel(ing.oil) }}
</span>
</div>
<div class="match-meta">

View File

@@ -31,7 +31,7 @@
<div class="diary-name">{{ d.name || '未命名' }}</div>
<div class="diary-ings">
<span v-for="ing in (d.ingredients || []).slice(0, 3)" :key="ing.oil" class="diary-ing">
{{ ing.oil }} {{ ing.drops }}
{{ ing.oil }} {{ ing.drops }}{{ oils.unitLabel(ing.oil) }}
</span>
<span v-if="(d.ingredients || []).length > 3" class="diary-more">+{{ (d.ingredients || []).length - 3 }}</span>
</div>

View File

@@ -1019,8 +1019,8 @@ async function checkDupName(name, ings, target = 'diary') {
return false
}
const existIngs = dupIngs.map(i => `${i.oil}${i.drops}`).join('、')
const newIngs = myIngs.map(i => `${i.oil}${i.drops}`).join('、')
const existIngs = dupIngs.map(i => `${i.oil}${i.drops}${oils.unitLabel(i.oil)}`).join('、')
const newIngs = myIngs.map(i => `${i.oil}${i.drops}${oils.unitLabel(i.oil)}`).join('、')
const ok = await showConfirm(
`${where}中已有同名配方「${currentName}」,内容不同:\n\n已有${existIngs}\n新的${newIngs}\n\n请改名后保存`,
{ okText: '改名', cancelText: '取消' }