From 5f1ead03ab3945a4a2402e3e762275eddbb293ca Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Mon, 13 Apr 2026 17:19:34 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=85=8D=E6=96=B9=E5=8D=A1=E7=89=87?= =?UTF-8?q?=E5=AE=B9=E9=87=8F=E6=8C=89=E5=8D=95=E4=BD=8D=E5=88=86=E7=BB=84?= =?UTF-8?q?=E6=B1=82=E5=92=8C=EF=BC=8C=E6=94=AF=E6=8C=81=E6=B7=B7=E5=90=88?= =?UTF-8?q?=E5=8D=95=E4=BD=8D(30g+100ml)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 有椰子油: 单次 / Xml(不变) - 无椰子油有产品: 同单位求和,不同单位用+连接 - 示例: 一个配方含30g面霜+100ml护手霜 → 显示"30g+100ml" Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/components/RecipeCard.vue | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/RecipeCard.vue b/frontend/src/components/RecipeCard.vue index 7606d35..fd91b53 100644 --- a/frontend/src/components/RecipeCard.vue +++ b/frontend/src/components/RecipeCard.vue @@ -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 '' })