From a09cdcc60cf35cfd3c2776ad4a16b2c8f0a4aa6e Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Fri, 10 Apr 2026 18:49:21 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E7=BC=96=E8=BE=91=E9=85=8D=E6=96=B9?= =?UTF-8?q?=E6=97=B6=E6=AD=A3=E7=A1=AE=E8=AF=86=E5=88=AB=E5=AE=B9=E9=87=8F?= =?UTF-8?q?=E5=92=8C=E7=A8=80=E9=87=8A=E6=AF=94=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 补充15ml/20ml的容量匹配 - 稀释比例取最近的可选值(3-20) - 自定义时显示ml而非drops - 无椰子油时默认单次模式 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/RecipeManager.vue | 32 +++++++++++++++++++++------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/frontend/src/views/RecipeManager.vue b/frontend/src/views/RecipeManager.vue index f6285a6..a1cbf1b 100644 --- a/frontend/src/views/RecipeManager.vue +++ b/frontend/src/views/RecipeManager.vue @@ -738,17 +738,33 @@ function calcDilutionFromIngs(ingredients) { const eoDrops = ings.filter(i => i.oil && i.oil !== '椰子油').reduce((s, i) => s + (i.drops || 0), 0) const cocoDrops = coco ? (coco.drops || 0) : 0 const totalDrops = eoDrops + cocoDrops + + // Set dilution ratio if (eoDrops > 0 && cocoDrops > 0) { - formDilution.value = Math.round(cocoDrops / eoDrops) + const ratio = Math.round(cocoDrops / eoDrops) + // Clamp to available options + const options = [3,4,5,6,7,8,9,10,12,15,20] + formDilution.value = options.reduce((prev, curr) => Math.abs(curr - ratio) < Math.abs(prev - ratio) ? curr : prev) } + + // Set coconut drops for single mode + if (coco) { + formCocoRow.value.drops = cocoDrops + } + // Guess volume - const DROPS_PER_ML = 18.6 - const ml = totalDrops / DROPS_PER_ML - if (ml <= 1.5) formVolume.value = 'single' - else if (Math.abs(ml - 5) < 1.5) formVolume.value = '5' - else if (Math.abs(ml - 10) < 3) formVolume.value = '10' - else if (Math.abs(ml - 30) < 8) formVolume.value = '30' - else { formVolume.value = 'custom'; formCustomVolume.value = Math.round(totalDrops); formCustomUnit.value = 'drops' } + if (!coco || cocoDrops === 0) { + formVolume.value = 'single' + } else { + const ml = totalDrops / DROPS_PER_ML + if (ml <= 2) formVolume.value = 'single' + else if (Math.abs(ml - 5) < 1.5) formVolume.value = '5' + else if (Math.abs(ml - 10) < 2.5) formVolume.value = '10' + else if (Math.abs(ml - 15) < 2.5) formVolume.value = '15' + else if (Math.abs(ml - 20) < 3) formVolume.value = '20' + else if (Math.abs(ml - 30) < 6) formVolume.value = '30' + else { formVolume.value = 'custom'; formCustomVolume.value = Math.round(ml) } + } } function editRecipe(recipe) {