fix: 管理配方容量显示支持产品,混合g/ml统一显示ml
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 53s
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 6s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 12s
Test / e2e-test (push) Successful in 53s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -56,15 +56,15 @@ const volumeLabel = computed(() => {
|
|||||||
if (ml <= 2) return '单次'
|
if (ml <= 2) return '单次'
|
||||||
return `${Math.round(ml)}ml`
|
return `${Math.round(ml)}ml`
|
||||||
}
|
}
|
||||||
// Non-coconut: sum portion products by unit
|
// Non-coconut: sum all portion products as ml
|
||||||
const unitSums = {}
|
let totalMl = 0
|
||||||
|
let hasProduct = false
|
||||||
for (const ing of ings) {
|
for (const ing of ings) {
|
||||||
if (!oilsStore.isPortionUnit(ing.oil)) continue
|
if (!oilsStore.isPortionUnit(ing.oil)) continue
|
||||||
const u = oilsStore.unitLabel(ing.oil)
|
hasProduct = true
|
||||||
unitSums[u] = (unitSums[u] || 0) + (ing.drops || 0)
|
totalMl += ing.drops || 0
|
||||||
}
|
}
|
||||||
const parts = Object.entries(unitSums).map(([u, v]) => `${Math.round(v)}${u}`)
|
if (hasProduct && totalMl > 0) return `${Math.round(totalMl)}ml`
|
||||||
if (parts.length) return parts.join('+')
|
|
||||||
return ''
|
return ''
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -1458,12 +1458,23 @@ function openRecipeDetail(recipe) {
|
|||||||
function getVolumeLabel(ingredients) {
|
function getVolumeLabel(ingredients) {
|
||||||
const ings = ingredients || []
|
const ings = ingredients || []
|
||||||
const coco = ings.find(i => i.oil === '椰子油')
|
const coco = ings.find(i => i.oil === '椰子油')
|
||||||
if (!coco || !coco.drops) return ''
|
if (coco && coco.drops) {
|
||||||
const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0)
|
const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0)
|
||||||
const ml = totalDrops / 18.6
|
const ml = totalDrops / 18.6
|
||||||
if (ml <= 2) return '单次'
|
if (ml <= 2) return '单次'
|
||||||
return `${Math.round(ml)}ml`
|
return `${Math.round(ml)}ml`
|
||||||
}
|
}
|
||||||
|
// Non-coconut: sum portion products, mixed units all convert to ml
|
||||||
|
let totalMl = 0
|
||||||
|
let hasProduct = false
|
||||||
|
for (const ing of ings) {
|
||||||
|
if (!oils.isPortionUnit(ing.oil)) continue
|
||||||
|
hasProduct = true
|
||||||
|
totalMl += ing.drops || 0
|
||||||
|
}
|
||||||
|
if (hasProduct && totalMl > 0) return `${Math.round(totalMl)}ml`
|
||||||
|
return ''
|
||||||
|
}
|
||||||
|
|
||||||
function diaryMatchesPublic(d) {
|
function diaryMatchesPublic(d) {
|
||||||
const pub = recipeStore.recipes.find(r => r.name === d.name)
|
const pub = recipeStore.recipes.find(r => r.name === d.name)
|
||||||
|
|||||||
Reference in New Issue
Block a user