From 8a7fb75b75b16b8ed6e169b624895b8262287164 Mon Sep 17 00:00:00 2001 From: Hera Zhao Date: Fri, 10 Apr 2026 19:05:51 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=A1=E6=A0=B8=E5=90=8C=E5=90=8D?= =?UTF-8?q?=E9=85=8D=E6=96=B9=E6=B5=81=E7=A8=8B=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 一模一样:提示忽略,确认后删除重复,从待审核消失 - 不一样:显示对比,改名后采纳 / 放弃(删除并从待审核消失) Co-Authored-By: Claude Opus 4.6 (1M context) --- frontend/src/views/RecipeManager.vue | 49 ++++++++++++++++++---------- 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/frontend/src/views/RecipeManager.vue b/frontend/src/views/RecipeManager.vue index 15b33fb..3410f93 100644 --- a/frontend/src/views/RecipeManager.vue +++ b/frontend/src/views/RecipeManager.vue @@ -1275,29 +1275,42 @@ async function approveRecipe(recipe) { const dup = recipeStore.recipes.find(r => r.name === recipe.name && r._id !== recipe._id) if (dup) { if (recipesIdentical(recipe, dup)) { - ui.showToast('公共配方库中已有一模一样的配方「' + recipe.name + '」,无需重复采纳') + // Identical — delete this duplicate silently + const ok = await showConfirm(`公共配方库中已有一模一样的配方「${recipe.name}」,忽略这条?`) + if (!ok) return + try { + await api(`/api/recipes/${recipe._id}/reject`, { method: 'POST', body: '{}' }) + await recipeStore.loadRecipes() + ui.showToast('已忽略重复配方') + } catch { ui.showToast('操作失败') } return } - // Different content, show comparison - const msg = `公共配方库中已有同名配方「${recipe.name}」但内容不同:\n\n` + + // Different content + const msg = `已有同名配方「${recipe.name}」但内容不同:\n\n` + `已有:${formatIngsCompare(dup.ingredients)}\n` + - `新的:${formatIngsCompare(recipe.ingredients)}\n\n` + - `点击"采纳"直接采纳,或"改名"修改新配方名称后采纳` - const action = await showConfirm(msg, { okText: '采纳', cancelText: '改名' }) + `新的:${formatIngsCompare(recipe.ingredients)}` + const action = await showConfirm(msg, { okText: '改名后采纳', cancelText: '放弃' }) if (!action) { - // User wants to rename - const newName = await showPrompt('请输入新名称:', recipe.name) - if (!newName || !newName.trim()) return + // User chose to discard try { - await api(`/api/recipes/${recipe._id}`, { - method: 'PUT', - body: JSON.stringify({ name: newName.trim() }), - }) - recipe.name = newName.trim() - } catch { - ui.showToast('改名失败') - return - } + await api(`/api/recipes/${recipe._id}/reject`, { method: 'POST', body: JSON.stringify({ reason: '与已有同名配方重复' }) }) + await recipeStore.loadRecipes() + ui.showToast('已放弃') + } catch { ui.showToast('操作失败') } + return + } + // User wants to rename + const newName = await showPrompt('请输入新名称:', recipe.name) + if (!newName || !newName.trim()) return + try { + await api(`/api/recipes/${recipe._id}`, { + method: 'PUT', + body: JSON.stringify({ name: newName.trim() }), + }) + recipe.name = newName.trim() + } catch { + ui.showToast('改名失败') + return } } try {