Files
lv8girl/templates/admin_users.html
nannanwu 690b4d5961 fix(admin): 添加管理操作错误处理及更新模板样式
- 管理后台帖子与用户审核操作中添加失败错误重定向处理
- 管理后台帖子、用户、评论删除操作中添加错误检查及提示
- 用户角色更新操作失败时添加错误重定向
- 用户封禁通知失败时添加相应错误提示
- 登录登出时session保存加入错误处理
- 讨论区上传目录创建失败时显示错误提示
- 移除admin_dashboard.html多余样式及修正侧边栏当前页高亮
- admin_posts.html和admin_users.html添加状态样式动态使用的隐藏span元素
- admin_users.html为角色选择添加label以提升无障碍性
- 升级项目依赖版本,包含gin、gorm、validator等核心库版本更新
2026-02-24 21:14:55 +08:00

113 lines
7.2 KiB
HTML

<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>用户管理 · lv8girl</title>
<style>
* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
--bg: #0f0f1a; --surface: #1a1a2f; --surface-light: #252540; --border: #2d2d4a;
--text: #e0e0f0; --text-soft: #b0b0d0; --text-hint: #8080a0;
--primary: #c5a572; --gradient: linear-gradient(135deg, #c5a572, #9a7e5a);
--sidebar-width: 220px;
}
body { background: var(--bg); color: var(--text); font-family: -apple-system, 'Segoe UI', 'PingFang SC', sans-serif; }
.admin-wrapper { display: flex; min-height: 100vh; }
.sidebar { width: var(--sidebar-width); background: var(--surface); border-right: 1px solid var(--border); padding: 20px 0; position: sticky; top: 0; height: 100vh; }
.sidebar-header { padding: 0 20px 20px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.sidebar-header .logo { font-size: 1.6rem; font-weight: 800; background: var(--gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.sidebar-header p { color: var(--text-soft); font-size: 0.85rem; }
.sidebar-menu { list-style: none; }
.sidebar-menu li { margin: 5px 0; }
.sidebar-menu a { display: block; padding: 10px 20px; color: var(--text-soft); text-decoration: none; border-left: 4px solid transparent; }
.sidebar-menu a:hover, .sidebar-menu a.active { background: var(--surface-light); border-left-color: var(--primary); color: var(--primary); }
.sidebar-menu .separator { height: 1px; background: var(--border); margin: 15px 20px; }
.main-content { flex: 1; padding: 20px 30px; }
.top-bar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }
.page-title { font-size: 1.8rem; font-weight: 600; color: var(--primary); }
.user-info span { background: var(--surface-light); padding: 6px 16px; border-radius: 30px; }
.message { background: var(--surface-light); border-left: 4px solid var(--primary); padding: 12px 20px; margin-bottom: 20px; border-radius: 8px; }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 900px; }
th { background: var(--surface-light); padding: 12px 15px; text-align: left; font-weight: 600; color: var(--primary); border-bottom: 1px solid var(--border); }
td { padding: 12px 15px; border-bottom: 1px solid var(--border); color: var(--text-soft); }
tr:hover { background: var(--surface-light); }
.actions a { margin-right: 10px; color: var(--text-hint); text-decoration: none; }
.actions .delete { color: #ff6b6b; }
select { background: var(--surface-light); border: 1px solid var(--border); padding: 5px 10px; border-radius: 8px; color: var(--text); }
.status-approved { color: var(--primary); }
.status-pending { color: #ffb347; }
.status-rejected { color: #ff6b6b; }
@media (max-width: 768px) { .admin-wrapper { flex-direction: column; } .sidebar { width: 100%; height: auto; position: static; } }
</style>
</head>
<body>
<!-- 状态样式类通过模板动态使用: status-approved, status-pending, status-rejected -->
<span style="display:none;" class="status-approved status-pending status-rejected"></span>
<div class="admin-wrapper">
<aside class="sidebar">
<div class="sidebar-header"><div class="logo">lv8girl</div><p>管理面板</p></div>
<ul class="sidebar-menu">
<li><a href="/admin">📊 仪表盘</a></li>
<li><a href="/admin/pending_posts">⏳ 待审核帖子</a></li>
<li><a href="/admin/pending_users">👥 待审核用户</a></li>
<li><a href="/admin/posts">📝 帖子管理</a></li>
<li><a href="/admin/users" class="active">👥 用户管理</a></li>
<li><a href="/admin/comments">💬 评论管理</a></li>
<li class="separator"></li>
<li><a href="/">🏠 返回首页</a></li>
</ul>
</aside>
<main class="main-content">
<div class="top-bar">
<h1 class="page-title">用户管理</h1>
<div class="user-info"><span>{{.Username}}</span></div>
</div>
{{if .Message}}<div class="message">{{.Message}}</div>{{end}}
<div class="table-card">
<table>
<thead><tr><th>ID</th><th>用户名</th><th>邮箱</th><th>角色</th><th>状态</th><th>注册时间</th><th>最后活动</th><th>帖子</th><th>评论</th><th>操作</th></tr></thead>
<tbody>
{{range .Users}}
<tr>
<td>{{.ID}}</td>
<td>{{.Username}}</td>
<td>{{.Email}}</td>
<td>
{{if eq .ID $.CurrentUserID}}
{{if eq .Role "admin"}}管理员{{else if eq .Role "banned"}}封禁{{else}}用户{{end}}
{{else}}
<form method="post" action="/admin/users/role" style="display:inline;">
<input type="hidden" name="user_id" value="{{.ID}}">
<label for="role-{{.ID}}" style="display:none;">角色</label>
<select id="role-{{.ID}}" name="new_role" onchange="this.form.submit()">
<option value="user" {{if eq .Role "user"}}selected{{end}}>用户</option>
<option value="admin" {{if eq .Role "admin"}}selected{{end}}>管理员</option>
<option value="banned" {{if eq .Role "banned"}}selected{{end}}>封禁</option>
</select>
</form>
{{end}}
</td>
<td><span class="status-{{.Status}}">{{if eq .Status "approved"}}已通过{{else if eq .Status "pending"}}待审核{{else}}已拒绝{{end}}</span></td>
<td>{{.CreatedAt.Format "2006-01-02 15:04"}}</td>
<td>{{if .LastActive}}{{.LastActive.Format "2006-01-02 15:04"}}{{else}}从未{{end}}</td>
<td>{{.PostCount}}</td>
<td>{{.CommentCount}}</td>
<td class="actions">
{{if ne .ID $.CurrentUserID}}
<a href="/admin/users/delete/{{.ID}}" class="delete" onclick="return confirm('确定删除?')">删除</a>
{{else}}
<span style="color:var(--text-hint)">当前用户</span>
{{end}}
</td>
</tr>
{{end}}
</tbody>
</table>
</div>
</main>
</div>
</body>
</html>