feat: 新功能改进 #20

Merged
hera merged 57 commits from feat/next-improvements into main 2026-04-10 20:30:37 +00:00
Showing only changes of commit a09cdcc60c - Show all commits

View File

@@ -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) {