feat: 更多改进 #21
@@ -744,7 +744,7 @@ function calcDilutionFromIngs() {
|
||||
}
|
||||
|
||||
function editRecipe(recipe) {
|
||||
editingRecipe.value = recipe
|
||||
editingRecipe.value = { _id: recipe._id, _version: recipe._version, name: recipe.name }
|
||||
formName.value = recipe.name
|
||||
const ings = recipe.ingredients || []
|
||||
formIngredients.value = ings.filter(i => i.oil !== '椰子油').map(i => ({ ...i, _search: i.oil, _open: false }))
|
||||
@@ -1016,12 +1016,17 @@ async function saveCurrentRecipe() {
|
||||
}
|
||||
|
||||
if (editingRecipe.value && editingRecipe.value._id) {
|
||||
// Editing an existing public recipe
|
||||
// Editing an existing public recipe — safety check
|
||||
const mappedIngs = cleanIngs.map(i => ({ oil_name: i.oil, drops: i.drops }))
|
||||
if (mappedIngs.length === 0) {
|
||||
const ok = await showConfirm('配方中没有精油成分,确定保存吗?这将清空所有成分。')
|
||||
if (!ok) return
|
||||
}
|
||||
const payload = {
|
||||
_id: editingRecipe.value._id,
|
||||
_version: editingRecipe.value._version,
|
||||
name: formName.value.trim(),
|
||||
ingredients: cleanIngs.map(i => ({ oil_name: i.oil, drops: i.drops })),
|
||||
ingredients: mappedIngs,
|
||||
note: formNote.value,
|
||||
tags: formTags.value,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user