feat: Admin 用户列表禁言、认证与调积分

SSR /admin/users 复用 ListUsers/BanUser/SetVerified/AdminAdjust,并回写 02/06/09 指针至徽章。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-08-30 03:38:38 +08:00
parent 5fb3b2a165
commit 02a5ad0c30
10 changed files with 363 additions and 27 deletions

View File

@@ -4,6 +4,7 @@
<a href="/admin/boards"{{if eq .NavActive "boards"}} class="is-active"{{end}}>板块</a>
<a href="/admin/moderation"{{if eq .NavActive "moderation"}} class="is-active"{{end}}>审核</a>
<a href="/admin/reports"{{if eq .NavActive "reports"}} class="is-active"{{end}}>举报</a>
<a href="/admin/users"{{if eq .NavActive "users"}} class="is-active"{{end}}>用户</a>
<a href="/admin/trash"{{if eq .NavActive "trash"}} class="is-active"{{end}}>回收站</a>
<a href="/admin/friend-links"{{if eq .NavActive "friend-links"}} class="is-active"{{end}}>友链</a>
<a href="/admin/pages"{{if eq .NavActive "pages"}} class="is-active"{{end}}>单页</a>

110
templates/admin/users.tmpl Normal file
View File

@@ -0,0 +1,110 @@
{{define "admin/users"}}
{{template "base/head" .}}
{{template "base/navbar" .}}
<main class="j13-main j13-admin">
<h1>用户管理</h1>
{{template "admin/nav" .}}
{{template "base/alert" .}}
<form method="get" action="/admin/users" class="j13-form j13-admin-form j13-admin-search">
<label>搜索 <input name="q" value="{{.Keyword}}" placeholder="用户名 / 昵称 / 邮箱 / ID"/></label>
<label>筛选
<select name="filter">
<option value="all"{{if eq .Filter "all"}} selected{{end}}>全部</option>
<option value="verified"{{if eq .Filter "verified"}} selected{{end}}>认证用户</option>
<option value="banned"{{if eq .Filter "banned"}} selected{{end}}>已禁言</option>
<option value="admin"{{if eq .Filter "admin"}} selected{{end}}>管理员</option>
</select>
</label>
<button type="submit">查询</button>
</form>
<p class="j13-admin-filters">
<a href="/admin/users"{{if eq .Filter "all"}} class="is-active"{{end}}>全部</a>
<a href="/admin/users?filter=verified"{{if eq .Filter "verified"}} class="is-active"{{end}}>认证</a>
<a href="/admin/users?filter=banned"{{if eq .Filter "banned"}} class="is-active"{{end}}>禁言</a>
<a href="/admin/users?filter=admin"{{if eq .Filter "admin"}} class="is-active"{{end}}>管理员</a>
</p>
{{if .Users}}
<table class="j13-admin-table">
<thead>
<tr>
<th>ID</th>
<th>用户</th>
<th>角色</th>
<th>积分 / Lv</th>
<th>状态</th>
<th>注册</th>
<th>操作</th>
</tr>
</thead>
<tbody>
{{range .Users}}
<tr>
<td>{{.ID}}</td>
<td>
<a href="/user/{{.ID}}">{{.Nickname}}</a>
<div class="j13-muted">@{{.Username}}{{if .Email}} · {{.Email}}{{end}}</div>
</td>
<td>{{.RoleLabel}}</td>
<td>{{.Points}} · Lv{{.Level}}</td>
<td>
{{if .Banned}}<span class="j13-tag j13-tag--rejected">禁言</span>{{end}}
{{if .Verified}}<span class="j13-tag j13-tag--resolved">认证</span>{{end}}
{{if and (not .Banned) (not .Verified)}}<span class="j13-muted">—</span>{{end}}
</td>
<td>{{.Created}}</td>
<td class="j13-admin-user-ops">
{{if not .IsAdmin}}
<form method="post" action="/admin/users/{{.ID}}/ban" class="j13-inline-form">
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
{{if .Banned}}
<input type="hidden" name="banned" value="0"/>
<button type="submit" class="j13-btn-secondary">解禁</button>
{{else}}
<input type="hidden" name="banned" value="1"/>
<button type="submit">禁言</button>
{{end}}
</form>
<form method="post" action="/admin/users/{{.ID}}/verify" class="j13-inline-form">
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
{{if .Verified}}
<input type="hidden" name="verified" value="0"/>
<button type="submit" class="j13-btn-secondary">取消认证</button>
{{else}}
<input type="hidden" name="verified" value="1"/>
<button type="submit" class="j13-btn-secondary">设为认证</button>
{{end}}
</form>
{{else}}
<span class="j13-muted">管理员不可禁言</span>
{{end}}
<form method="post" action="/admin/users/{{.ID}}/points" class="j13-form j13-admin-points">
<input type="hidden" name="_csrf" value="{{$.CSRF}}"/>
<input name="delta" type="number" required placeholder="±积分" style="width:5.5rem"/>
<input name="note" maxlength="120" placeholder="备注(可选)" style="width:8rem"/>
<button type="submit" class="j13-btn-secondary">调积分</button>
</form>
</td>
</tr>
{{end}}
</tbody>
</table>
{{if or .HasPrev .HasMore}}
<nav class="j13-pager">
{{if .HasPrev}}
<a href="/admin/users?{{if .QuerySuffix}}{{.QuerySuffix}}&amp;{{end}}page={{.PrevPage}}">上一页</a>
{{end}}
<span>第 {{.Page}} 页</span>
{{if .HasMore}}
<a href="/admin/users?{{if .QuerySuffix}}{{.QuerySuffix}}&amp;{{end}}page={{.NextPage}}">下一页</a>
{{end}}
</nav>
{{end}}
{{else}}
<p class="j13-empty">没有匹配的用户。</p>
{{end}}
</main>
{{template "base/footer" .}}
{{end}}