fix: 配方卡片容量按单位分组求和,支持混合单位(30g+100ml)
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Successful in 52s
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 6s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Successful in 52s
- 有椰子油: 单次 / Xml(不变) - 无椰子油有产品: 同单位求和,不同单位用+连接 - 示例: 一个配方含30g面霜+100ml护手霜 → 显示"30g+100ml" Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,11 +56,15 @@ const volumeLabel = computed(() => {
|
||||
if (ml <= 2) return '单次'
|
||||
return `${Math.round(ml)}ml`
|
||||
}
|
||||
// Non-coconut: find portion product and show its amount + unit
|
||||
const portionIng = ings.find(i => oilsStore.isPortionUnit(i.oil))
|
||||
if (portionIng) {
|
||||
return `${portionIng.drops}${oilsStore.unitLabel(portionIng.oil)}`
|
||||
// Non-coconut: sum portion products by unit
|
||||
const unitSums = {}
|
||||
for (const ing of ings) {
|
||||
if (!oilsStore.isPortionUnit(ing.oil)) continue
|
||||
const u = oilsStore.unitLabel(ing.oil)
|
||||
unitSums[u] = (unitSums[u] || 0) + (ing.drops || 0)
|
||||
}
|
||||
const parts = Object.entries(unitSums).map(([u, v]) => `${Math.round(v)}${u}`)
|
||||
if (parts.length) return parts.join('+')
|
||||
return ''
|
||||
})
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user