fix: 审核同名配方流程优化
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 14s
Test / e2e-test (push) Failing after 55s

- 一模一样:提示忽略,确认后删除重复,从待审核消失
- 不一样:显示对比,改名后采纳 / 放弃(删除并从待审核消失)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-10 19:05:51 +00:00
parent 3adcfc1169
commit 8a7fb75b75

View File

@@ -1275,16 +1275,30 @@ 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 chose to discard
try {
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
@@ -1299,7 +1313,6 @@ async function approveRecipe(recipe) {
return
}
}
}
try {
const res = await api('/api/recipes/' + recipe._id + '/adopt', { method: 'POST' })
if (res.ok) {