feat: 操作日志共享配方统一显示,移除用户删除撤销
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Successful in 49s
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 3s
PR Preview / test (pull_request) Successful in 4s
PR Preview / deploy-preview (pull_request) Successful in 15s
Test / e2e-test (push) Successful in 49s
share_recipe/adopt_recipe 统一显示为"共享配方"。 删除用户不可撤销,回退软删除方案。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -800,7 +800,9 @@ def create_recipe(recipe: RecipeIn, user=Depends(get_current_user)):
|
||||
for tag in recipe.tags:
|
||||
c.execute("INSERT OR IGNORE INTO tags (name) VALUES (?)", (tag,))
|
||||
c.execute("INSERT OR IGNORE INTO recipe_tags (recipe_id, tag_name) VALUES (?, ?)", (rid, tag))
|
||||
log_audit(conn, user["id"], "create_recipe", "recipe", rid, recipe.name)
|
||||
# Only log for admin/senior_editor direct adds (share); others wait for adopt
|
||||
if user["role"] in ("admin", "senior_editor"):
|
||||
log_audit(conn, user["id"], "share_recipe", "recipe", rid, recipe.name)
|
||||
who = user.get("display_name") or user["username"]
|
||||
if user["role"] == "senior_editor":
|
||||
# Senior editor adds directly — just inform admin
|
||||
|
||||
@@ -82,10 +82,10 @@ const selectedUser = ref('')
|
||||
const selectedTarget = ref('')
|
||||
|
||||
const ACTION_MAP = {
|
||||
create_recipe: '新增配方',
|
||||
share_recipe: '共享配方',
|
||||
adopt_recipe: '共享配方',
|
||||
update_recipe: '编辑配方',
|
||||
delete_recipe: '删除配方',
|
||||
adopt_recipe: '采纳配方',
|
||||
reject_recipe: '拒绝配方',
|
||||
undo_delete_recipe: '恢复配方',
|
||||
upsert_oil: '编辑精油',
|
||||
@@ -105,8 +105,8 @@ const ACTION_MAP = {
|
||||
}
|
||||
|
||||
const actionGroups = {
|
||||
'配方': ['create_recipe', 'update_recipe', 'delete_recipe', 'undo_delete_recipe'],
|
||||
'审核': ['adopt_recipe', 'reject_recipe'],
|
||||
'配方': ['share_recipe', 'adopt_recipe', 'update_recipe', 'delete_recipe', 'undo_delete_recipe'],
|
||||
'审核': ['reject_recipe'],
|
||||
'精油': ['upsert_oil', 'delete_oil', 'undo_delete_oil'],
|
||||
'标签': ['create_tag', 'delete_tag'],
|
||||
'用户': ['create_user', 'update_user', 'delete_user', 'undo_delete_user', 'register'],
|
||||
@@ -153,7 +153,7 @@ function actionColorClass(action) {
|
||||
if (action.includes('create') || action.includes('upsert')) return 'color-create'
|
||||
if (action.includes('update')) return 'color-update'
|
||||
if (action.includes('delete') || action.includes('reject')) return 'color-delete'
|
||||
if (action.includes('adopt') || action.includes('undo')) return 'color-approve'
|
||||
if (action.includes('adopt') || action.includes('undo') || action.includes('share')) return 'color-approve'
|
||||
return ''
|
||||
}
|
||||
|
||||
@@ -179,7 +179,7 @@ function parsedDetail(log) {
|
||||
}
|
||||
|
||||
function canUndo(log) {
|
||||
return ['delete_recipe', 'delete_user', 'delete_oil'].includes(log.action)
|
||||
return ['delete_recipe', 'delete_oil'].includes(log.action)
|
||||
}
|
||||
|
||||
async function undoAction(log) {
|
||||
|
||||
Reference in New Issue
Block a user