From 13b675e63d368f09dfa41fdada58f83944d53406 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Mon, 13 Apr 2026 17:23:32 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=AE=A1=E7=90=86=E9=85=8D=E6=96=B9?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E6=98=BE=E7=A4=BA=E6=94=AF=E6=8C=81=E4=BA=A7?= =?UTF-8?q?=E5=93=81=EF=BC=8C=E6=B7=B7=E5=90=88g/ml=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E6=98=BE=E7=A4=BAml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/components/RecipeCard.vue | 12 ++++++------ frontend/src/views/RecipeManager.vue | 21 ++++++++++++++++----- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/RecipeCard.vue b/frontend/src/components/RecipeCard.vue index fd91b53..07b6965 100644 --- a/frontend/src/components/RecipeCard.vue +++ b/frontend/src/components/RecipeCard.vue @@ -56,15 +56,15 @@ const volumeLabel = computed(() => { if (ml <= 2) return '单次' return `${Math.round(ml)}ml` } - // Non-coconut: sum portion products by unit - const unitSums = {} + // Non-coconut: sum all portion products as ml + let totalMl = 0 + let hasProduct = false 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) + hasProduct = true + totalMl += ing.drops || 0 } - const parts = Object.entries(unitSums).map(([u, v]) => `${Math.round(v)}${u}`) - if (parts.length) return parts.join('+') + if (hasProduct && totalMl > 0) return `${Math.round(totalMl)}ml` return '' }) diff --git a/frontend/src/views/RecipeManager.vue b/frontend/src/views/RecipeManager.vue index 6f0b5f8..ed8f15e 100644 --- a/frontend/src/views/RecipeManager.vue +++ b/frontend/src/views/RecipeManager.vue @@ -1458,11 +1458,22 @@ function openRecipeDetail(recipe) { function getVolumeLabel(ingredients) { const ings = ingredients || [] const coco = ings.find(i => i.oil === '椰子油') - if (!coco || !coco.drops) return '' - const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0) - const ml = totalDrops / 18.6 - if (ml <= 2) return '单次' - return `${Math.round(ml)}ml` + if (coco && coco.drops) { + const totalDrops = ings.reduce((s, i) => s + (i.drops || 0), 0) + const ml = totalDrops / 18.6 + if (ml <= 2) return '单次' + 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) {