fix: 无椰子油配方编辑时不显示容量/椰子油/摘要
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 16s
Test / e2e-test (push) Failing after 55s
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 16s
Test / e2e-test (push) Failing after 55s
- 无椰子油:容量不选中,摘要不显示,椰子油行不出现 - 有椰子油:自动匹配容量和稀释比例 - 新增配方默认无椰子油 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -317,8 +317,8 @@
|
|||||||
<button class="add-row-btn" @click="addOilRow">+ 添加精油</button>
|
<button class="add-row-btn" @click="addOilRow">+ 添加精油</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Real-time summary -->
|
<!-- Real-time summary (only when volume selected) -->
|
||||||
<div class="recipe-summary">
|
<div v-if="formVolume" class="recipe-summary">
|
||||||
{{ recipeSummaryText }}
|
{{ recipeSummaryText }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -749,10 +749,31 @@ function editRecipe(recipe) {
|
|||||||
const ings = recipe.ingredients || []
|
const ings = recipe.ingredients || []
|
||||||
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
|
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
|
||||||
const coco = ings.find(i => i.oil === '椰子油')
|
const coco = ings.find(i => i.oil === '椰子油')
|
||||||
formCocoRow.value = coco ? { ...coco, _search: '椰子油', _open: false } : { oil: '椰子油', drops: 10, _search: '椰子油', _open: false }
|
if (coco) {
|
||||||
|
formCocoRow.value = { ...coco, _search: '椰子油', _open: false }
|
||||||
|
// Guess volume from total drops
|
||||||
|
const eoDrops = ings.filter(i => i.oil && i.oil !== '椰子油').reduce((s, i) => s + (i.drops || 0), 0)
|
||||||
|
const totalDrops = eoDrops + coco.drops
|
||||||
|
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) }
|
||||||
|
// Guess dilution
|
||||||
|
if (eoDrops > 0 && coco.drops > 0) {
|
||||||
|
const ratio = Math.round(coco.drops / eoDrops)
|
||||||
|
const options = [3,4,5,6,7,8,9,10,12,15,20]
|
||||||
|
formDilution.value = options.reduce((a, b) => Math.abs(b - ratio) < Math.abs(a - ratio) ? b : a)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formCocoRow.value = null
|
||||||
|
formVolume.value = ''
|
||||||
|
}
|
||||||
formNote.value = recipe.note || ''
|
formNote.value = recipe.note || ''
|
||||||
formTags.value = [...(recipe.tags || [])]
|
formTags.value = [...(recipe.tags || [])]
|
||||||
calcDilutionFromIngs(recipe.ingredients)
|
|
||||||
showAddOverlay.value = true
|
showAddOverlay.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -765,7 +786,7 @@ function closeOverlay() {
|
|||||||
function resetForm() {
|
function resetForm() {
|
||||||
formName.value = ''
|
formName.value = ''
|
||||||
formIngredients.value = [{ oil: '', drops: 1, _search: '', _open: false }]
|
formIngredients.value = [{ oil: '', drops: 1, _search: '', _open: false }]
|
||||||
formCocoRow.value = { oil: '椰子油', drops: 10, _search: '椰子油', _open: false }
|
formCocoRow.value = null
|
||||||
formNote.value = ''
|
formNote.value = ''
|
||||||
formTags.value = []
|
formTags.value = []
|
||||||
smartPasteText.value = ''
|
smartPasteText.value = ''
|
||||||
@@ -1218,10 +1239,29 @@ function editDiaryRecipe(diary) {
|
|||||||
const ings = diary.ingredients || []
|
const ings = diary.ingredients || []
|
||||||
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
|
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
|
||||||
const coco = ings.find(i => i.oil === '椰子油')
|
const coco = ings.find(i => i.oil === '椰子油')
|
||||||
formCocoRow.value = coco ? { ...coco, _search: '椰子油', _open: false } : { oil: '椰子油', drops: 10, _search: '椰子油', _open: false }
|
if (coco) {
|
||||||
|
formCocoRow.value = { ...coco, _search: '椰子油', _open: false }
|
||||||
|
const eoDrops = ings.filter(i => i.oil && i.oil !== '椰子油').reduce((s, i) => s + (i.drops || 0), 0)
|
||||||
|
const totalDrops = eoDrops + coco.drops
|
||||||
|
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) }
|
||||||
|
if (eoDrops > 0 && coco.drops > 0) {
|
||||||
|
const ratio = Math.round(coco.drops / eoDrops)
|
||||||
|
const options = [3,4,5,6,7,8,9,10,12,15,20]
|
||||||
|
formDilution.value = options.reduce((a, b) => Math.abs(b - ratio) < Math.abs(a - ratio) ? b : a)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
formCocoRow.value = null
|
||||||
|
formVolume.value = ''
|
||||||
|
}
|
||||||
formNote.value = diary.note || ''
|
formNote.value = diary.note || ''
|
||||||
formTags.value = [...(diary.tags || [])]
|
formTags.value = [...(diary.tags || [])]
|
||||||
calcDilutionFromIngs(diary.ingredients)
|
|
||||||
showAddOverlay.value = true
|
showAddOverlay.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user