- Go + Gin + html/template 服务端渲染 - 主页:Google 风格搜索框 + 导航卡片 - 后台:卡片 CRUD、搜索引擎配置、主页背景/标题配置 - 图片上传:支持 jpg/jpeg/png/gif,自动压缩,缩略图参数 ?thumb=1 - 安全:登录日志、修改密码、IP 自动封禁、IP 白名单 - 访问统计:主页访问/卡片点击/搜索追踪、实时流量、IP 统计 - SQLite 存储(modernc.org/sqlite,纯 Go) - 内存 Session + bcrypt 密码哈希
86 lines
3.7 KiB
HTML
86 lines
3.7 KiB
HTML
{{define "admin/ip_whitelist.html"}}
|
||
{{template "header" .}}
|
||
<div class="admin-layout">
|
||
<nav class="admin-nav">
|
||
<div class="admin-nav-brand">Portal 管理</div>
|
||
<div class="admin-nav-links">
|
||
<a href="/admin" class="admin-nav-link">首页</a>
|
||
<a href="/admin/cards" class="admin-nav-link">卡片管理</a>
|
||
<a href="/admin/access-logs" class="admin-nav-link">访问日志</a>
|
||
<a href="/admin/logs" class="admin-nav-link">登录日志</a>
|
||
<a href="/admin/ip-whitelist" class="admin-nav-link active">IP白名单</a>
|
||
<a href="/admin/settings" class="admin-nav-link">设置</a>
|
||
<a href="/admin/password" class="admin-nav-link">修改密码</a>
|
||
</div>
|
||
<div class="admin-nav-user">
|
||
<span>{{.Username}}</span>
|
||
<form method="POST" action="/admin/logout" style="display:inline">
|
||
<button type="submit" class="btn btn-sm btn-secondary">退出</button>
|
||
</form>
|
||
</div>
|
||
</nav>
|
||
<main class="admin-main">
|
||
<h1>IP 白名单管理</h1>
|
||
|
||
{{if .HasWhitelist}}
|
||
<div class="whitelist-notice">
|
||
<strong>⚠️ 白名单模式已启用</strong>:当前仅白名单中的IP可以访问后台管理页面,非白名单IP将被拒绝访问。
|
||
</div>
|
||
{{else}}
|
||
<div class="whitelist-notice notice-info">
|
||
<strong>ℹ️ 白名单模式未启用</strong>:白名单为空时,不限制任何IP访问后台。添加至少一条记录即可启用白名单模式。
|
||
</div>
|
||
{{end}}
|
||
|
||
{{if .Error}}<div class="form-error">{{.Error}}</div>{{end}}
|
||
{{if .Message}}<div class="form-success">{{.Message}}</div>{{end}}
|
||
|
||
<h2 class="form-section-title">添加白名单</h2>
|
||
<form method="POST" action="/admin/ip-whitelist/add" class="admin-form">
|
||
<div class="form-group">
|
||
<label for="ip">IP 地址 <span class="required">*</span></label>
|
||
<input type="text" id="ip" name="ip" required placeholder="例如: 192.168.1.100">
|
||
</div>
|
||
<div class="form-group">
|
||
<label for="comment">备注</label>
|
||
<input type="text" id="comment" name="comment" placeholder="例如: 办公室网络">
|
||
</div>
|
||
<div class="form-actions">
|
||
<button type="submit" class="btn btn-primary">添加</button>
|
||
</div>
|
||
</form>
|
||
|
||
<h2 class="form-section-title">当前白名单</h2>
|
||
{{if .Whitelist}}
|
||
<table class="admin-table">
|
||
<thead>
|
||
<tr>
|
||
<th>IP 地址</th>
|
||
<th>备注</th>
|
||
<th>添加时间</th>
|
||
<th>操作</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
{{range .Whitelist}}
|
||
<tr>
|
||
<td><code>{{.IP}}</code></td>
|
||
<td>{{if .Comment}}{{.Comment}}{{else}}—{{end}}</td>
|
||
<td>{{.CreatedAt.Format "2006-01-02 15:04:05"}}</td>
|
||
<td>
|
||
<form method="POST" action="/admin/ip-whitelist/{{.ID}}/delete" style="display:inline" onsubmit="return confirm('确定要删除此白名单记录吗?删除后该IP将无法访问后台。')">
|
||
<button type="submit" class="btn btn-sm btn-danger">删除</button>
|
||
</form>
|
||
</td>
|
||
</tr>
|
||
{{end}}
|
||
</tbody>
|
||
</table>
|
||
{{else}}
|
||
<p style="color:#999;">暂无白名单记录。添加记录后,将仅允许白名单IP访问后台。</p>
|
||
{{end}}
|
||
</main>
|
||
</div>
|
||
{{template "footer" .}}
|
||
{{end}}
|