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 {