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
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:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user