Files
ipass__ipass/www/me.html
T
admin d56dd52c3e fix(me): 24h 图表改滚动窗口(左 23h 前 → 右 现在)
之前 hour_24 数组按 hour-of-day 桶索引(h = (now_h - age_h + 24) % 24),
导致 11 点打开面板看到「今天 0-11 + 昨天 12-23」混在一起,x 轴
「0-23」语义跟时间顺序对不上,看着像「显示的是昨天的 24 小时」。

改 llm_audit.rs:
  * 索引语义换成「hours ago」:hour_24[0] = 23h 前,hour_24[23] = 现在
  * 24h 边界(age_h == 24)clamp 到 0 桶;老逻辑会把边界调用错归到
    当前小时桶,是同一个 bug 的另一种表现
  * 响应里加 hour_24h_labels 数组,前端不用再算时间

改 www/assets/me.js:
  * renderHourly 接收 server 返回的 labels,老 server 缺字段时降级到索引

改 www/me.html:
  * 描述文字「按本地自然小时分桶」→「滚动 24 小时(左 23h 前 → 右 现在)」
    ——避免后续用户再问

hourly.html 的热力图(slot × 24 小时)按 hour-of-day 是设计如此,
不动。
2026-09-16 12:07:47 +08:00

119 lines
4.3 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/admin/">
<title>我的用量 · 尚数网 山海关</title>
<link rel="stylesheet" href="assets/admin.css">
</head>
<body>
<div id="topbar"></div>
<div class="wrap">
<!-- 输 Key 卡片(首次进入时显示) -->
<div id="keyCard" class="panel" style="max-width:560px;margin:60px auto 0">
<div class="panel-head">
<div>
<h2>用 API Key 看我的用量</h2>
<div class="desc">
输入账号的 <code>sk_xxx</code> 即可查询本账号的最近调用、消耗、能用的上游/代理等数据。
<b>Key 只在浏览器 sessionStorage</b>,关页面即清,<b>不会落盘也不会上传</b>。
</div>
</div>
</div>
<form id="keyForm" class="login-card" style="box-shadow:none;padding:8px 0">
<div class="field">
<label for="apiKey">API Key</label>
<input id="apiKey" type="password" autocomplete="off" placeholder="sk_xxxxxxxxxxxxxxxxxxxxxxxxxx" required>
</div>
<div class="muted" id="keyHint" style="font-size:12.5px;margin:4px 0 12px">
忘记 Key?联系管理员重置。
</div>
<div class="row-actions">
<button class="btn-sm btn-ok" type="submit" id="keySubmit">查 询</button>
<a class="btn-sm" href="login.html">管理员登录</a>
</div>
</form>
</div>
<!-- 面板(鉴权后显示) -->
<div id="dashCard" hidden>
<div class="stats">
<div class="stat"><div class="k">用户名</div><div class="v" id="dUser" style="font-size:18px">-</div></div>
<div class="stat"><div class="k">24h 调用</div><div class="v" id="dCalls24">-</div></div>
<div class="stat"><div class="k">7d 调用</div><div class="v" id="dCalls7">-</div></div>
<div class="stat"><div class="k">24h 入 token</div><div class="v" id="dTin24">-</div></div>
<div class="stat"><div class="k">24h 出 token</div><div class="v" id="dTout24">-</div></div>
<div class="stat"><div class="k">上次调用</div><div class="v" id="dLast" style="font-size:14px">-</div></div>
</div>
<div class="panel">
<div class="panel-head">
<div>
<h2>24h 调用分布</h2>
<div class="desc">滚动 24 小时(左 23h 前 → 右 现在);含被拒的 401/404 之类——审计全量视角。</div>
</div>
<div class="row-actions">
<button class="btn-sm" id="refreshBtn">刷新</button>
</div>
</div>
<div class="chart" id="dHourChart" style="min-height:160px"></div>
</div>
<div class="panel">
<div class="panel-head">
<div>
<h2>近 7 天按上游 slot</h2>
<div class="desc">按 calls_7d 降序。last_status 是最近一次调用的 HTTP 状态码。</div>
</div>
</div>
<table>
<thead><tr>
<th>slot</th><th>24h</th><th>7d</th><th>7d 入 token</th><th>7d 出 token</th><th>最近状态</th>
</tr></thead>
<tbody id="dSlotBody"></tbody>
</table>
</div>
<div class="panel">
<div class="panel-head">
<div>
<h2>我能调的 LLM 上游</h2>
<div class="desc">
按白名单过滤后的可用 slot;点 <b>OpenAI</b> / <b>Anthropic</b> 按钮复制纯 URL(<b>不带尾巴</b>——直接贴到 Claude Code / WorkBuddy 客户端)。
</div>
</div>
</div>
<div id="dUpstream" class="muted" style="font-size:13px"></div>
</div>
<div class="panel">
<div class="panel-head">
<div>
<h2>我能调的 API 代理</h2>
<div class="desc">仅列 enabled 代理;每条带示例调用方式(<code>GET /apix/&lt;slug&gt;?...</code> 或 <code>POST /apixp/&lt;slug&gt;/&lt;tail&gt;</code>)。</div>
</div>
</div>
<div id="dApix"></div>
</div>
<div class="panel">
<div class="panel-head">
<div>
<h2>我的域名</h2>
<div class="desc">本账号申请并被审批通过的子域名列表。</div>
</div>
</div>
<div id="dDomains"></div>
</div>
</div>
</div>
<div id="toast"></div>
<script src="assets/core.js"></script>
<script src="assets/chart.js"></script>
<script src="assets/me.js"></script>
</body>
</html>