Files
ipass__ipass/www/upstreams.html
T
admin c426789734 feat(admin): 用量图表(趋势/token/按人/按 API 组)+ 管理台单页拆分多页
后端
- 新增日桶 ud:/udu:/uds:(键名带日窗 id,TTL 90 天),record 记请求、
  add_tokens 记 token,两者写同一批键、字段互补;forget 同步清 udu:
- 新增 GET /api/admin/trend?days=N(默认 14、上限 90),返回图表可直接吃的
  {labels,total,users,slots},每条含 requests/in/out 三条等长数组
- util::fmt_day 供 x 轴用(%m-%d)

前端(原 www/admin.html 1100+ 行单文件)
- 拆为 login.html + overview/review/domains/users/upstreams/usage.html
- 抽出 assets/:admin.css + core.js(请求/登录守卫/外壳)+ chart.js(自绘 SVG)
- 每页 <base href="/admin/">;nginx 侧 /admin 仍进总览,/admin/ alias 到 www/
- 图表零第三方依赖(CDN 会让内网部署白屏,本地副本要塞几百 KB 进镜像)

验收
- 回归 227 条全绿(网关 102 + LLM 125)
- agent.sh verify 新增「趋势接口返回 7 天序列」作为镜像换新证据
2026-09-13 00:42:13 +08:00

49 lines
2.5 KiB
HTML
Raw 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>LLM 上游 · 尚数网 山海关</title>
<link rel="stylesheet" href="assets/admin.css">
</head>
<body>
<div id="shell"></div>
<div class="wrap">
<div class="panel">
<h2>新建 / 更新 LLM 上游</h2>
<div class="desc">slot 即 URL 前缀:客户端把 base_url 指向 <code>https://lm.mayishangshu.cn/&lt;slot&gt;/v1</code> 并携带其账号 API Key,网关把 Key 换成本处配置的上游密钥后转发。一家厂商通常挂很多模型,把模型名登记在这里,客户端就能通过 <code>GET /v1/models</code> 或 <code>GET /api/v1/models</code> 先列出可用模型再调用。保存后立即生效,无需重启。密钥/模型列表留空表示不修改已有值。</div>
<form id="upsertUpstreamForm" class="grid-form up-form">
<div><label for="upSlot">slot(URL 前缀)</label><input id="upSlot" type="text" placeholder="openai" required></div>
<div><label for="upNote">备注</label><input id="upNote" type="text" placeholder="可选"></div>
<div class="span-all"><label for="upBase">上游地址(含路径段,如 <code>/v1</code>)</label><input id="upBase" class="field-mono" type="text" placeholder="https://api.deepseek.com/v1" required></div>
<div class="span-all"><label for="upAuth">上游密钥(新建必填,更新可留空)</label><input id="upAuth" class="field-mono" type="text" placeholder="sk-..." autocomplete="off"></div>
<div class="span-all">
<label for="upModels">该上游挂载的模型(逗号 / 换行分隔,可留空)</label>
<textarea id="upModels" rows="3" placeholder="deepseek-chat, deepseek-reasoner"
style="resize:vertical;font-family:ui-monospace,Menlo,Consolas,monospace;font-size:12.5px"></textarea>
</div>
<div><button class="btn-primary btn-block" type="submit">保存上游</button></div>
</form>
</div>
<div class="panel">
<h2>上游列表</h2>
<div class="desc">停用的上游对客户端表现为 404;删除不可恢复,指向它的调用会立即失败。</div>
<table>
<thead><tr>
<th>slot</th><th>上游地址</th><th>密钥</th><th>模型</th><th>备注</th><th>状态</th><th>创建时间</th><th>操作</th>
</tr></thead>
<tbody id="upstreamsBody"></tbody>
</table>
</div>
</div>
<div id="toast"></div>
<script src="assets/core.js"></script>
<script src="assets/upstreams.js"></script>
</body>
</html>