264 lines
12 KiB
HTML
264 lines
12 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<title>操作审计 · Console UI Demo(Halo 插件)</title>
|
||
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%234ccba0' d='M12 3l7 3v6c0 4.6-3 7.6-7 9-4-1.4-7-4.4-7-9V6z'/%3E%3C/svg%3E">
|
||
<link rel="stylesheet" href="assets/demo.css">
|
||
</head>
|
||
<body>
|
||
|
||
<!-- ======== 左侧导航(模拟 Halo Console 外壳) ======== -->
|
||
<aside class="sidebar">
|
||
<div class="logo-row">
|
||
<svg class="logo-mark" viewBox="0 0 24 24" aria-hidden="true">
|
||
<path fill="#4ccba0" d="M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20Zm0 3.2a6.8 6.8 0 0 1 4.8 11.6c-.5-1.6-2.4-2.6-4.8-2.6s-4.3 1-4.8 2.6A6.8 6.8 0 0 1 12 5.2Z"/>
|
||
<circle cx="12" cy="10.4" r="2.6" fill="#0e1731"/>
|
||
</svg>
|
||
<span class="logo-text">Halo</span>
|
||
<span class="demo-badge">UI Demo</span>
|
||
</div>
|
||
|
||
<nav class="nav-scroll">
|
||
<div class="nav-group">内容</div>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><rect x="3" y="3" width="7.5" height="9" rx="1.5"/><rect x="13.5" y="3" width="7.5" height="5" rx="1.5"/><rect x="13.5" y="11" width="7.5" height="10" rx="1.5"/><rect x="3" y="15" width="7.5" height="6" rx="1.5"/></svg>
|
||
仪表盘</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><path d="M6 3h9l4 4v14H6z"/><path d="M9 11h7M9 14.5h7M9 18h4.5"/></svg>
|
||
文章</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><path d="M7 3h7l4 4v14H7z"/><path d="M10 12h5M10 15.5h5"/></svg>
|
||
页面</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><path d="M21 11.5c0 4.1-4 7.5-9 7.5-1 0-2-.13-2.9-.37L4 20l1.3-3.4C3.9 15.3 3 13.5 3 11.5 3 7.4 7 4 12 4s9 3.4 9 7.5Z"/></svg>
|
||
评论</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><path d="M8 12.5 15.5 5a3.2 3.2 0 0 1 4.5 4.5l-8.8 8.8a5 5 0 0 1-7-7l8.3-8.3"/></svg>
|
||
附件</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><circle cx="12" cy="8" r="4"/><path d="M4.5 20c.8-3.6 3.9-5.5 7.5-5.5s6.7 1.9 7.5 5.5"/></svg>
|
||
用户</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><circle cx="12" cy="12" r="9"/><path d="M12 3a9 9 0 0 0 0 18c1.5 0 2-1 2-2s-.8-2-.8-3c0-1.2 1-2 2.6-2H19a2 2 0 0 0 2-2 9 9 0 0 0-9-9Z"/><circle cx="8" cy="10" r="1.2"/><circle cx="12" cy="7.5" r="1.2"/><circle cx="16" cy="10" r="1.2"/></svg>
|
||
主题</a>
|
||
<a class="nav-item" href="#" data-demo>
|
||
<svg viewBox="0 0 24 24"><path d="M4 7h3l2-2h6l2 2h3v12H4z"/><circle cx="12" cy="13" r="3"/></svg>
|
||
系统</a>
|
||
|
||
<div class="nav-group">插件</div>
|
||
<a class="nav-item active" href="#" id="nav-audit">
|
||
<svg viewBox="0 0 24 24"><path d="M12 3l7 3v6c0 4.6-3 7.6-7 9-4-1.4-7-4.4-7-9V6z"/><path d="m9 11.5 2.2 2.2L15.5 9.5"/></svg>
|
||
操作审计</a>
|
||
</nav>
|
||
|
||
<div class="sidebar-footer">
|
||
<div class="user-chip">
|
||
<span class="avatar c-a">G</span>
|
||
<span class="user-meta"><b>guichumo</b><small>超级管理员</small></span>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
<!-- ======== 主内容区 ======== -->
|
||
<main class="main">
|
||
<div class="page-header">
|
||
<div>
|
||
<h1>操作审计</h1>
|
||
<p class="page-sub">谁 · 在什么时候 · 对什么资源 · 做了什么操作 · 结果如何 <span class="readonly-hint">(只读,不可篡改)</span></p>
|
||
</div>
|
||
<button class="btn btn-outline" id="btn-simulate">
|
||
<svg viewBox="0 0 24 24"><path d="M6 4.5v15l12-7.5z"/></svg>
|
||
模拟一次操作
|
||
</button>
|
||
</div>
|
||
|
||
<div class="tabs" id="tabs">
|
||
<button class="tab active" data-tab="logs">审计日志</button>
|
||
<button class="tab" data-tab="settings">插件设置</button>
|
||
</div>
|
||
|
||
<div class="banner banner-warn" id="audit-off-banner" hidden>
|
||
<b>审计已关闭。</b>当前期间内发生的后台操作不会写入审计日志,重新开启后恢复记录。
|
||
</div>
|
||
|
||
<!-- ---- 审计日志 ---- -->
|
||
<section id="panel-logs">
|
||
<div class="filter-bar card">
|
||
<div class="filter-item">
|
||
<label for="f-operator">操作者</label>
|
||
<select id="f-operator"><option value="">全部</option></select>
|
||
</div>
|
||
<div class="filter-item">
|
||
<label for="f-type">资源类型</label>
|
||
<select id="f-type"><option value="">全部</option></select>
|
||
</div>
|
||
<div class="filter-item">
|
||
<label for="f-method">动作</label>
|
||
<select id="f-method"><option value="">全部</option></select>
|
||
</div>
|
||
<div class="filter-item">
|
||
<label for="f-result">结果</label>
|
||
<select id="f-result">
|
||
<option value="">全部</option>
|
||
<option value="success">成功</option>
|
||
<option value="failure">失败</option>
|
||
</select>
|
||
</div>
|
||
<div class="filter-item">
|
||
<label for="f-time">时间范围</label>
|
||
<select id="f-time">
|
||
<option value="all">全部时间</option>
|
||
<option value="24h">近 24 小时</option>
|
||
<option value="7d">近 7 天</option>
|
||
<option value="30d">近 30 天</option>
|
||
</select>
|
||
</div>
|
||
<div class="filter-item grow">
|
||
<label for="f-keyword">关键字</label>
|
||
<input id="f-keyword" type="search" placeholder="资源名称 / 路径,如 hello-halo" autocomplete="off">
|
||
</div>
|
||
<button class="btn-link" id="btn-clear" hidden>✕ 清除筛选</button>
|
||
</div>
|
||
|
||
<div class="card table-card">
|
||
<table class="audit-table">
|
||
<thead>
|
||
<tr>
|
||
<th style="width:170px">时间</th>
|
||
<th style="width:150px">操作者</th>
|
||
<th style="width:90px">动作</th>
|
||
<th>资源</th>
|
||
<th style="width:110px">结果</th>
|
||
<th style="width:140px">来源 IP</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody id="tbody"></tbody>
|
||
</table>
|
||
<div class="pagination">
|
||
<span class="pg-info" id="pg-info"></span>
|
||
<span class="pg-right">
|
||
<select id="pg-size" title="每页条数">
|
||
<option value="10">10 条/页</option>
|
||
<option value="20">20 条/页</option>
|
||
<option value="50">50 条/页</option>
|
||
</select>
|
||
<button class="icon-btn" id="pg-prev" title="上一页">‹</button>
|
||
<button class="icon-btn" id="pg-next" title="下一页">›</button>
|
||
</span>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
|
||
<!-- ---- 插件设置 ---- -->
|
||
<section id="panel-settings" hidden>
|
||
<div class="card settings-card">
|
||
<div class="card-title">基本设置</div>
|
||
<div class="setting-row">
|
||
<div class="setting-text">
|
||
<div class="s-name">审计开关</div>
|
||
<div class="s-desc">开启后,已登录用户对后台 API(/apis/**)的写操作与登录/登出事件将被记录(对应 settings.yaml,Console 自动渲染)</div>
|
||
</div>
|
||
<label class="switch">
|
||
<input type="checkbox" id="set-enabled" checked>
|
||
<span class="slider"></span>
|
||
</label>
|
||
</div>
|
||
<div class="setting-row">
|
||
<div class="setting-text">
|
||
<div class="s-name">保留天数</div>
|
||
<div class="s-desc">超过保留期的记录由每日定时任务自动清理,无需人工干预(默认 90 天,最小 7 天)</div>
|
||
</div>
|
||
<input type="number" id="set-retention" class="input num" min="7" max="365" value="90">
|
||
</div>
|
||
<div class="settings-actions">
|
||
<button class="btn btn-primary" id="btn-save-settings">保存设置</button>
|
||
<span class="hint">Demo 仅保存在当前页面内存中,刷新后恢复默认</span>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="card settings-card">
|
||
<div class="card-title">清理预览</div>
|
||
<div class="clean-stats" id="clean-stats"></div>
|
||
<button class="btn btn-outline" id="btn-clean">模拟一次清理</button>
|
||
</div>
|
||
</section>
|
||
</main>
|
||
|
||
<!-- ======== 详情抽屉(只读) ======== -->
|
||
<div class="overlay" id="drawer-overlay" hidden></div>
|
||
<aside class="drawer" id="drawer" hidden></aside>
|
||
|
||
<!-- ======== 模拟操作弹窗 ======== -->
|
||
<div class="overlay" id="modal-overlay" hidden></div>
|
||
<div class="modal" id="modal" hidden>
|
||
<div class="modal-head">
|
||
<span>模拟一次后台操作</span>
|
||
<button class="icon-btn" id="modal-close">✕</button>
|
||
</div>
|
||
<p class="modal-sub">选择操作者与方法、输入请求路径后发送,Demo 将按技术方案 D1 的捕获规则(<code>/apis/**</code> 写操作 + <code>/login</code>、<code>/logout</code>)判断是否写入审计日志。</p>
|
||
|
||
<div class="field-row">
|
||
<div class="field">
|
||
<label for="sim-user">操作者</label>
|
||
<select id="sim-user">
|
||
<option value="guichumo">guichumo</option>
|
||
<option value="editor.zhang">editor.zhang</option>
|
||
<option value="writer.li">writer.li</option>
|
||
<option value="__anon__">匿名访客</option>
|
||
</select>
|
||
</div>
|
||
<div class="field">
|
||
<label for="sim-method">HTTP 方法</label>
|
||
<select id="sim-method">
|
||
<option>GET</option>
|
||
<option>POST</option>
|
||
<option>PUT</option>
|
||
<option>DELETE</option>
|
||
<option>PATCH</option>
|
||
</select>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="field">
|
||
<label for="sim-path">请求路径</label>
|
||
<input id="sim-path" type="text" placeholder="/apis/content.halo.run/v1alpha1/posts/hello-halo" autocomplete="off" spellcheck="false">
|
||
</div>
|
||
|
||
<div class="presets">
|
||
<button class="chip" data-preset='{"user":"guichumo","method":"PUT","path":"/apis/content.halo.run/v1alpha1/posts/hello-halo","status":200}'>编辑文章</button>
|
||
<button class="chip" data-preset='{"user":"guichumo","method":"POST","path":"/apis/api.content.halo.run/v1alpha1/posts/reading-notes-11/publish","status":200}'>发布文章</button>
|
||
<button class="chip" data-preset='{"user":"editor.zhang","method":"POST","path":"/apis/api.halo.run/v1alpha1/comments/comment-8fa2c1/approve","status":200}'>审核评论</button>
|
||
<button class="chip" data-preset='{"user":"__anon__","method":"POST","path":"/login","status":401}'>登录失败</button>
|
||
<button class="chip" data-preset='{"user":"guichumo","method":"GET","path":"/apis/api.content.halo.run/v1alpha1/posts","status":200}'>查询文章列表(读)</button>
|
||
</div>
|
||
|
||
<div class="field">
|
||
<label for="sim-status">模拟响应</label>
|
||
<select id="sim-status">
|
||
<option value="200">200 成功</option>
|
||
<option value="201">201 创建成功</option>
|
||
<option value="204">204 删除成功</option>
|
||
<option value="400">400 请求错误</option>
|
||
<option value="401">401 未认证</option>
|
||
<option value="403">403 权限不足</option>
|
||
<option value="404">404 资源不存在</option>
|
||
<option value="500">500 服务端异常</option>
|
||
</select>
|
||
</div>
|
||
|
||
<div class="modal-actions">
|
||
<button class="btn btn-outline" id="sim-cancel">取消</button>
|
||
<button class="btn btn-primary" id="sim-send">发送请求</button>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="toast" id="toast"></div>
|
||
|
||
<script src="assets/audit-core.js"></script>
|
||
<script src="assets/mock-data.js"></script>
|
||
<script src="assets/app.js"></script>
|
||
</body>
|
||
</html>
|