refactor: 拆分 middleware/router 为单一职责文件,新增站点设置管理页面

middleware:
- 拆分 auth.go → auth.go + auth_token.go + auth_parser.go + auth_admin.go
- 拆分 csrf.go → csrf.go + csrf_token.go
- 拆分 ratelimit.go → ratelimit.go + ratelimit_core.go + ratelimit_cleanup.go
- 修复 import 未使用/缺失问题

router:
- 拆分 router.go → admin.go + api.go + frontend.go + deps_core.go + deps_extra.go

feat(admin): 站点设置管理页面
- 新增 SSR 页面 /admin/site-settings(仅 Owner)
- 审核开关 Toggle 即时保存
- 通用设置展示
- 侧边栏新增站点设置入口
- 注册 UpdateBoolSetting/GetBoolSetting API 路由
This commit is contained in:
2026-05-27 15:03:04 +08:00
parent a19b1fcb51
commit 7bc2dbd970
20 changed files with 774 additions and 446 deletions

View File

@ -39,6 +39,12 @@
审核管理
</a>
{{end}}
{{if .CanManageSettings}}
<a href="/admin/site-settings" class="sidebar-item {{if eq .CurrentPath "/admin/site-settings"}}active{{end}}">
<span class="sidebar-icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="12" cy="12" r="3"/><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z"/></svg></span>
站点设置
</a>
{{end}}
</nav>
</aside>
<main class="admin-main">

View File

@ -0,0 +1,64 @@
{{template "admin/layout/base.html" .}}
<div class="page-header">
<h1>站点设置</h1>
<p class="page-desc">管理审核开关与站点全局配置</p>
</div>
<!-- 审核设置 -->
<div class="settings-section">
<div class="section-title">审核设置</div>
<div class="section-body">
<div class="setting-item">
<div class="setting-info">
<span class="setting-label">启用审核系统</span>
<span class="setting-desc">启用后,用户名、头像、签名修改将进入审核流程</span>
</div>
<label class="toggle-switch">
<input type="checkbox" id="audit-enabled" data-key="audit.enabled">
<span class="toggle-slider"></span>
</label>
</div>
<div class="setting-item">
<div class="setting-info">
<span class="setting-label">用户名审核</span>
<span class="setting-desc">更改用户名需要管理员审核</span>
</div>
<label class="toggle-switch">
<input type="checkbox" id="audit-username" data-key="audit.username_audit">
<span class="toggle-slider"></span>
</label>
</div>
<div class="setting-item">
<div class="setting-info">
<span class="setting-label">头像审核</span>
<span class="setting-desc">更改头像需要管理员审核</span>
</div>
<label class="toggle-switch">
<input type="checkbox" id="audit-avatar" data-key="audit.avatar_audit">
<span class="toggle-slider"></span>
</label>
</div>
<div class="setting-item">
<div class="setting-info">
<span class="setting-label">签名审核</span>
<span class="setting-desc">更改个人签名需要管理员审核</span>
</div>
<label class="toggle-switch">
<input type="checkbox" id="audit-bio" data-key="audit.bio_audit">
<span class="toggle-slider"></span>
</label>
</div>
</div>
</div>
<!-- 通用设置 -->
<div class="settings-section">
<div class="section-title">通用设置</div>
<div class="section-body" id="general-settings">
<div class="settings-empty" id="settings-empty">加载中...</div>
</div>
</div>
{{template "admin/layout/footer.html" .}}