feat: 用户软删除+30天自动清理,操作日志共享配方统一显示
Some checks failed
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
PR Preview / test (pull_request) Successful in 5s
PR Preview / deploy-preview (pull_request) Successful in 17s
Test / e2e-test (push) Has been cancelled

用户删除改为软删除(deleted标记),撤销时数据完整恢复(配方/收藏/库存等)。
30天后自动硬删除清理。操作日志中共享配方和采纳配方统一显示为"共享配方"。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-11 22:03:36 +00:00
parent ad636f2df6
commit 5848a21540
3 changed files with 66 additions and 30 deletions

View File

@@ -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,13 @@ function parsedDetail(log) {
}
function canUndo(log) {
return ['delete_recipe', 'delete_user', 'delete_oil'].includes(log.action)
if (!['delete_recipe', 'delete_user', 'delete_oil'].includes(log.action)) return false
if (log.action === 'delete_user' && log.created_at) {
const deleted = new Date(log.created_at + 'Z')
const days = (Date.now() - deleted.getTime()) / (1000 * 60 * 60 * 24)
if (days > 30) return false
}
return true
}
async function undoAction(log) {