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
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:
@@ -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,
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user