From ac3abc3c84704f268e926742c3c3e8c44c9ac724 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Fri, 10 Apr 2026 20:55:32 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=89=B9=E9=87=8F=E6=94=B9=E6=A0=87?= =?UTF-8?q?=E7=AD=BE=E5=8F=AA=E5=8F=91=E9=80=81tags=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=EF=BC=8C=E4=B8=8D=E5=8F=91=E9=80=81=E6=95=B4=E4=B8=AArecipe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复因ingredients格式不匹配(oil vs oil_name)导致PUT请求失败 标签修改实际未保存到数据库的问题 Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/RecipeManager.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/RecipeManager.vue b/frontend/src/views/RecipeManager.vue index 16beca7..cd5f6f7 100644 --- a/frontend/src/views/RecipeManager.vue +++ b/frontend/src/views/RecipeManager.vue @@ -601,15 +601,22 @@ async function applyBatchTags() { for (const id of pubIds) { const recipe = recipeStore.recipes.find(r => r._id === id) if (!recipe) continue + let newTags = [...recipe.tags] let changed = false for (const t of tagsToAdd) { - if (!recipe.tags.includes(t)) { recipe.tags.push(t); changed = true } + if (!newTags.includes(t)) { newTags.push(t); changed = true } } for (const t of tagsToRemove) { - const idx = recipe.tags.indexOf(t) - if (idx >= 0) { recipe.tags.splice(idx, 1); changed = true } + const idx = newTags.indexOf(t) + if (idx >= 0) { newTags.splice(idx, 1); changed = true } + } + if (changed) { + await api(`/api/recipes/${recipe._id}`, { + method: 'PUT', + body: JSON.stringify({ tags: newTags }), + }) + recipe.tags = newTags } - if (changed) await recipeStore.saveRecipe(recipe) } for (const id of diaryIds) { const d = diaryStore.userDiary.find(r => r.id === id)