3 Commits

Author SHA1 Message Date
f2c95985cf fix: 标签筛选时自动展开配方列表
All checks were successful
PR Preview / teardown-preview (pull_request) Has been skipped
Test / unit-test (push) Successful in 4s
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 52s
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 20:59:58 +00:00
ac3abc3c84 fix: 批量改标签只发送tags字段,不发送整个recipe
All checks were successful
Test / unit-test (push) Successful in 5s
Test / build-check (push) Successful in 4s
Test / e2e-test (push) Successful in 53s
修复因ingredients格式不匹配(oil vs oil_name)导致PUT请求失败
标签修改实际未保存到数据库的问题

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 20:55:32 +00:00
3a7e52360c fix: 操作日志详细记录权限变更
All checks were successful
Test / unit-test (push) Successful in 7s
Test / build-check (push) Successful in 6s
Test / e2e-test (push) Successful in 50s
- 修改用户权限时记录旧角色→新角色(中文)和用户名
- 日志显示"查看者 → 高级编辑"格式
- 商业认证日志显示商户名

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-10 20:53:22 +00:00
3 changed files with 27 additions and 9 deletions

View File

@@ -1094,6 +1094,9 @@ def delete_user(user_id: int, user=Depends(require_role("admin"))):
@app.put("/api/users/{user_id}")
def update_user(user_id: int, body: UserUpdate, user=Depends(require_role("admin"))):
conn = get_db()
target = conn.execute("SELECT role, display_name, username FROM users WHERE id = ?", (user_id,)).fetchone()
old_role = target["role"] if target else "unknown"
target_name = (target["display_name"] or target["username"]) if target else "unknown"
if body.role is not None:
if body.role == "admin":
conn.close()
@@ -1101,8 +1104,15 @@ def update_user(user_id: int, body: UserUpdate, user=Depends(require_role("admin
conn.execute("UPDATE users SET role = ?, role_changed_at = datetime('now') WHERE id = ?", (body.role, user_id))
if body.display_name is not None:
conn.execute("UPDATE users SET display_name = ? WHERE id = ?", (body.display_name, user_id))
log_audit(conn, user["id"], "update_user", "user", user_id, None,
json.dumps({"role": body.role, "display_name": body.display_name}))
role_labels = {"admin": "管理员", "senior_editor": "高级编辑", "editor": "编辑", "viewer": "查看者"}
detail = {}
if body.role is not None and body.role != old_role:
detail["from_role"] = role_labels.get(old_role, old_role)
detail["to_role"] = role_labels.get(body.role, body.role)
if body.display_name is not None:
detail["display_name"] = body.display_name
log_audit(conn, user["id"], "update_user", "user", user_id, target_name,
json.dumps(detail, ensure_ascii=False))
conn.commit()
conn.close()
return {"ok": True}

View File

@@ -153,9 +153,10 @@ function parsedDetail(log) {
try {
const d = JSON.parse(log.detail)
const parts = []
if (d.from_role && d.to_role) parts.push(`${d.from_role}${d.to_role}`)
if (d.from_user) parts.push(`来自: ${d.from_user}`)
if (d.reason) parts.push(`原因: ${d.reason}`)
if (d.role) parts.push(`角色: ${d.role}`)
if (d.business_name) parts.push(`商户: ${d.business_name}`)
if (d.display_name) parts.push(`显示名: ${d.display_name}`)
if (d.original_log_id) parts.push(`恢复自 #${d.original_log_id}`)
if (parts.length) return parts.join(' · ')

View File

@@ -109,7 +109,7 @@
<span v-if="!auth.isAdmin" class="contrib-tag">已贡献 {{ sharedCount.adopted }}/{{ sharedCount.total }} </span>
<span class="toggle-icon">{{ showMyRecipes ? '▾' : '▸' }}</span>
</h3>
<template v-if="showMyRecipes || manageSearch">
<template v-if="showMyRecipes || manageSearch || selectedTags.length">
<div class="recipe-list">
<div
v-for="d in myFilteredRecipes"
@@ -149,7 +149,7 @@
<span>🌿 公共配方库 ({{ publicRecipes.length }})</span>
<span class="toggle-icon">{{ showPublicRecipes ? '▾' : '▸' }}</span>
</h3>
<div v-if="showPublicRecipes || manageSearch" class="recipe-list">
<div v-if="showPublicRecipes || manageSearch || selectedTags.length" class="recipe-list">
<div
v-for="r in publicFilteredRecipes"
:key="r._id"
@@ -601,15 +601,22 @@ async function applyBatchTags() {
for (const id of pubIds) {
const recipe = recipeStore.recipes.find(r => r._id === id)
if (!recipe) continue
let newTags = [...recipe.tags]
let changed = false
for (const t of tagsToAdd) {
if (!recipe.tags.includes(t)) { recipe.tags.push(t); changed = true }
if (!newTags.includes(t)) { newTags.push(t); changed = true }
}
for (const t of tagsToRemove) {
const idx = recipe.tags.indexOf(t)
if (idx >= 0) { recipe.tags.splice(idx, 1); changed = true }
const idx = newTags.indexOf(t)
if (idx >= 0) { newTags.splice(idx, 1); changed = true }
}
if (changed) {
await api(`/api/recipes/${recipe._id}`, {
method: 'PUT',
body: JSON.stringify({ tags: newTags }),
})
recipe.tags = newTags
}
if (changed) await recipeStore.saveRecipe(recipe)
}
for (const id of diaryIds) {
const d = diaryStore.userDiary.find(r => r.id === id)