diff --git a/tests/gateway/e2e.sh b/tests/gateway/e2e.sh
index 86eafef..10154f5 100755
--- a/tests/gateway/e2e.sh
+++ b/tests/gateway/e2e.sh
@@ -292,6 +292,7 @@ ck "账号页 → 200" 200 "$(code -b "$JAR" $ADMIN/admin/users.html)"
ck "上游页 → 200" 200 "$(code -b "$JAR" $ADMIN/admin/upstreams.html)"
ck "用量页 → 200" 200 "$(code -b "$JAR" $ADMIN/admin/usage.html)"
ck "24h 热力页 → 200(1.0.27 直接读 meta.jsonl 聚合)" 200 "$(code -b "$JAR" $ADMIN/admin/hourly.html)"
+ck "我的用量页 → 200(1.0.30 账号态面板)" 200 "$(code $ADMIN/admin/me.html)"
ck "登录页 → 200" 200 "$(code $ADMIN/admin/login.html)"
ck "共享样式 → 200" 200 "$(code $ADMIN/admin/assets/admin.css)"
ck "共享内核 → 200" 200 "$(code $ADMIN/admin/assets/core.js)"
diff --git a/www/assets/core.js b/www/assets/core.js
index 5a9ab49..443c0e2 100644
--- a/www/assets/core.js
+++ b/www/assets/core.js
@@ -20,7 +20,8 @@ window.IP = (function () {
{ key: "upstreams", name: "LLM 上游", href: "upstreams.html" },
{ key: "apix", name: "API 代理", href: "apix.html" },
{ key: "usage", name: "用量统计", href: "usage.html" },
- { key: "hourly", name: "24h 热力", href: "hourly.html" }
+ { key: "hourly", name: "24h 热力", href: "hourly.html" },
+ { key: "me", name: "我的用量", href: "me.html" }
];
var state = {
diff --git a/www/assets/me.js b/www/assets/me.js
new file mode 100644
index 0000000..e22669e
--- /dev/null
+++ b/www/assets/me.js
@@ -0,0 +1,231 @@
+/* 账号态「我的用量」面板(1.0.30)
+ 输入 API Key → 调 /api/v1/me → 渲染概览 / 24h 小时分布 / 按 slot 拆分 /
+ 我能调的上游 + apix + 我的域名。
+ Key 只在 sessionStorage,关页面即清。
+*/
+(function () {
+ "use strict";
+ var KEY_STORE = "ipass.me.key";
+ var $ = IP.$;
+
+ function esc(s) { return IP.esc(s); }
+
+ function setKey(k) {
+ if (k) sessionStorage.setItem(KEY_STORE, k);
+ else sessionStorage.removeItem(KEY_STORE);
+ }
+
+ function getKey() {
+ return sessionStorage.getItem(KEY_STORE) || "";
+ }
+
+ /** 走 X-API-Key 头,调 API。不能用 IP.api(那个走 cookie)。
+ * 401 直接 throw 让 UI 显出重新输入 Key。 */
+ function meApi(method, path, body) {
+ var key = getKey();
+ if (!key) return Promise.reject(new Error("未设置 API Key"));
+ var opt = { method: method, headers: { "X-API-Key": key } };
+ if (body) {
+ opt.headers["Content-Type"] = "application/json";
+ opt.body = JSON.stringify(body);
+ }
+ return fetch(path, opt).then(function (res) {
+ return res.json().catch(function () { return { code: res.status, msg: "响应解析失败" }; })
+ .then(function (data) {
+ if (!res.ok) throw new Error(data.msg || ("请求失败 HTTP " + res.status));
+ return data;
+ });
+ });
+ }
+
+ function showKeyCard() {
+ $("keyCard").hidden = false;
+ $("dashCard").hidden = true;
+ $("apiKey").focus();
+ }
+
+ function showDash() {
+ $("keyCard").hidden = true;
+ $("dashCard").hidden = false;
+ }
+
+ function renderTopbar(me) {
+ $("topbar").innerHTML =
+ '
' +
+ '
尚数网 山海关个人用量面板
' +
+ '
' +
+ '' + esc(me.username) + " · " +
+ (me.role === "admin" ? "管理员" : "账号") + "" +
+ '' +
+ '' +
+ "
" +
+ "
";
+ if (me.role === "admin") {
+ $("topbarAdminBtn").addEventListener("click", function () {
+ // 跳 admin login(cookie 鉴权不走 me Key)
+ location.href = "login.html";
+ });
+ }
+ $("topbarLogoutBtn").addEventListener("click", function () {
+ setKey("");
+ showKeyCard();
+ $("apiKey").value = "";
+ });
+ }
+
+ function renderHourly(hour24) {
+ var el = $("dHourChart");
+ IP.chart.bars(el, {
+ labels: hour24.map(function (_, i) { return i; }),
+ items: [{ name: "调用数", values: hour24.map(function (v) { return Number(v) || 0; }) }],
+ emptyText: "过去 24 小时没有调用记录"
+ });
+ }
+
+ function renderSlots(bySlot) {
+ var body = $("dSlotBody");
+ if (!bySlot || !bySlot.length) {
+ body.innerHTML = '| 过去 7 天没有调用记录 |
';
+ return;
+ }
+ body.innerHTML = bySlot.map(function (s) {
+ var lastStatus = s.last_status || 0;
+ var badgeClass = lastStatus >= 200 && lastStatus < 300 ? "b-ok"
+ : lastStatus >= 400 && lastStatus < 500 ? "b-warn"
+ : lastStatus >= 500 ? "b-bad" : "b-gray";
+ return '' +
+ '| ' + esc(s.slot) + ' | ' +
+ '' + (s.calls_24h || 0) + ' | ' +
+ '' + (s.calls_7d || 0) + ' | ' +
+ '' + IP.chart.fmtNum(s.tin_7d || 0) + ' | ' +
+ '' + IP.chart.fmtNum(s.tout_7d || 0) + ' | ' +
+ '' + lastStatus + ' | ' +
+ '
';
+ }).join("");
+ }
+
+ function renderUpstreams(upstreams) {
+ var el = $("dUpstream");
+ if (!upstreams || !upstreams.length) {
+ el.innerHTML = '当前账号无可用上游(可能白名单为空,或全部 slot 被停用)';
+ return;
+ }
+ el.innerHTML = '| slot | base_url | models |
' +
+ upstreams.map(function (u) {
+ return '' +
+ '| ' + esc(u.slot || "") + ' | ' +
+ '' + esc(u.base_url || "") + ' | ' +
+ '' + ((u.models || []).map(esc).join("、") || "—") + ' | ' +
+ '
';
+ }).join("") + '
';
+ }
+
+ function renderApix(apix) {
+ var el = $("dApix");
+ if (!apix || !apix.length) {
+ el.innerHTML = '当前账号无可用 API 代理';
+ return;
+ }
+ el.innerHTML = '' +
+ '| slug | 用途 | 调用方式 | 说明 | ' +
+ '
' +
+ apix.map(function (a) {
+ var mode = a.mode || "vendor";
+ var call = mode === "passthrough"
+ ? 'POST /apixp/' + esc(a.slug) + '/<tail>'
+ : 'GET /apix/' + esc(a.slug) + '?参数=值';
+ return '' +
+ '| ' + esc(a.slug || "") + ' | ' +
+ '' + esc(a.display_name || a.url || "—") + ' | ' +
+ '' + call + ' | ' +
+ '' + esc((a.desc || a.usage_hint || "").slice(0, 80)) + ' | ' +
+ '
';
+ }).join("") + '
';
+ }
+
+ function renderDomains(domains) {
+ var el = $("dDomains");
+ if (!domains || !domains.length) {
+ el.innerHTML = '当前账号没有域名(需要去"全部域名"页申请)';
+ return;
+ }
+ el.innerHTML = '' +
+ '| 子域名 | 后端 | 状态 | 创建时间 | ' +
+ '
' +
+ domains.map(function (d) {
+ return '' +
+ '| ' + esc(d.full || d.subdomain || "—") + ' | ' +
+ '' + esc(d.backend || "—") + ' | ' +
+ '' +
+ (d.enabled ? "启用" : "停用") + ' | ' +
+ '' + esc(d.created_at_text || "") + ' | ' +
+ '
';
+ }).join("") + '
';
+ }
+
+ function renderDash(me) {
+ renderTopbar(me);
+ $("dUser").textContent = me.username || "-";
+ var r = me.recent || {};
+ $("dCalls24").textContent = r.calls_24h || 0;
+ $("dCalls7").textContent = r.calls_7d || 0;
+ $("dTin24").textContent = IP.chart.fmtNum(r.tin_24h || 0);
+ $("dTout24").textContent = IP.chart.fmtNum(r.tout_24h || 0);
+ $("dLast").textContent = r.last_at
+ ? esc(r.last_at + " · " + (r.last_slot || "-"))
+ : "—";
+ renderHourly(r.hour_24h || []);
+ renderSlots(r.by_slot || []);
+ renderUpstreams(me.upstreams || []);
+ renderApix(me.apix || []);
+ renderDomains(me.domains || []);
+ }
+
+ function loadDash() {
+ IP.toast("加载中…");
+ meApi("GET", "/api/v1/me").then(function (resp) {
+ var me = resp.data || {};
+ if (!me.username) {
+ IP.toast("接口返回异常:缺 username", true);
+ showKeyCard();
+ return;
+ }
+ renderDash(me);
+ showDash();
+ IP.toast("已加载");
+ }).catch(function (err) {
+ if (err.message && err.message.indexOf("HTTP 401") >= 0) {
+ setKey("");
+ IP.toast("Key 无效或已过期,请重新输入", true);
+ showKeyCard();
+ $("apiKey").value = "";
+ $("apiKey").focus();
+ } else {
+ IP.toast("加载失败:" + (err.message || err), true);
+ }
+ });
+ }
+
+ function bind() {
+ $("keyForm").addEventListener("submit", function (e) {
+ e.preventDefault();
+ var k = $("apiKey").value.trim();
+ if (!k) { IP.toast("请输入 API Key", true); return; }
+ setKey(k);
+ loadDash();
+ });
+ $("refreshBtn").addEventListener("click", loadDash);
+ }
+
+ function boot() {
+ bind();
+ if (getKey()) loadDash();
+ else showKeyCard();
+ }
+
+ if (document.readyState === "loading") {
+ document.addEventListener("DOMContentLoaded", boot);
+ } else {
+ boot();
+ }
+})();
\ No newline at end of file
diff --git a/www/me.html b/www/me.html
new file mode 100644
index 0000000..55fcb68
--- /dev/null
+++ b/www/me.html
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+我的用量 · 尚数网 山海关
+
+
+
+
+
+
+
+
+
+
+
用 API Key 看我的用量
+
+ 输入账号的 sk_xxx 即可查询本账号的最近调用、消耗、能用的上游/代理等数据。
+ Key 只在浏览器 sessionStorage,关页面即清,不会落盘也不会上传。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
24h 调用分布
+
按本地自然小时分桶;含被拒的 401/404 之类——审计全量视角。
+
+
+
+
+
+
+
+
+
+
+
+
+
近 7 天按上游 slot
+
按 calls_7d 降序。last_status 是最近一次调用的 HTTP 状态码。
+
+
+
+
+ | slot | 24h | 7d | 7d 入 token | 7d 出 token | 最近状态 |
+
+
+
+
+
+
+
+
+
我能调的 LLM 上游
+
+ 按白名单过滤后的可用 slot;base_url 是
调用方视角的完整 URL,客户端可直接配。
+
+
+
+
+
+
+
+
+
+
我能调的 API 代理
+
仅列 enabled 代理;每条带示例调用方式(GET /apix/<slug>?... 或 POST /apixp/<slug>/<tail>)。
+
+
+
+
+
+
+
+
+
我的域名
+
本账号申请并被审批通过的子域名列表。
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file