From 1352f092a36c291e1a2ffda4513c413742776cb0 Mon Sep 17 00:00:00 2001 From: caoqianming Date: Fri, 26 Jun 2026 14:21:40 +0800 Subject: [PATCH] =?UTF-8?q?feat(web):=20admin=20=E8=BF=917=E5=A4=A9?= =?UTF-8?q?=E7=94=A8=E9=87=8F=E8=A1=A8=E5=8A=A0=E5=90=88=E8=AE=A1=E8=A1=8C?= =?UTF-8?q?(bump=200.31.1)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit renderByDay 在 by_day_7d 表底加 tfoot 合计行,汇总 7 天 cost_cny/tokens_in/tokens_out;无数据时不渲染。后端无改动。 Co-Authored-By: Claude Opus 4.8 (1M context) --- PROGRESS.md | 6 +++++- core/__init__.py | 2 +- web/static/admin.html | 1 + web/static/js/admin.js | 14 +++++++++++++- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/PROGRESS.md b/PROGRESS.md index a23ef14..f19501e 100644 --- a/PROGRESS.md +++ b/PROGRESS.md @@ -2,7 +2,7 @@ > 配合 `DESIGN.md`。本文件只记 phase 状态、决策偏差、文件量、下一步。每条 1-2 句:做了啥 + 关键判断;细节查 `git log` / `git diff` / `DESIGN §7.9`。 -最后更新:2026-06-26(定时任务执行历史列表(分页)+ bump 0.29.0) +最后更新:2026-06-26(admin 近7天用量表加合计行 + bump 0.31.1) --- @@ -21,6 +21,10 @@ ## 已完成关键能力 +### 2026-06-26 / admin 近7天用量表加合计行(bump 0.31.1) + +- 纯前端展示:`renderByDay`(`web/static/js/admin.js`)在 `by_day_7d` 表底加 `` 合计行,对 7 天 cost_cny/tokens_in/tokens_out 求和;`tfoot .total-row` 样式(粗体 + 上分隔线)在 `admin.html`。无数据时不渲染合计行。后端数据已有(`_usage_section`),无改动。 + ### 2026-06-26 / per-account 模型访问控制(档位制,复用 plan 列)(bump 0.31.0) - 需求:管理后台按账户控制可调用哪些模型。deepseek flash/pro + seedream/seedance + 内网 local 对所有人开放,doubao/glm 按账户分配。 diff --git a/core/__init__.py b/core/__init__.py index 1904194..110e847 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1,3 +1,3 @@ # zcbot 版本号单一事实源:web/app.py 的 FastAPI version、/healthz 返回、前端展示都引这里。 # 改版本只动这一行。 -__version__ = "0.31.0" +__version__ = "0.31.1" diff --git a/web/static/admin.html b/web/static/admin.html index 8e876cc..bb4d61d 100644 --- a/web/static/admin.html +++ b/web/static/admin.html @@ -98,6 +98,7 @@ td.num { font-family: var(--mono); } td.email { font-family: var(--mono); max-width: 220px; overflow: hidden; text-overflow: ellipsis; } .bar-cell { position: relative; } + tfoot .total-row td { border-top: 2px solid var(--border); border-bottom: none; font-weight: 700; } .scroll-x { overflow-x: auto; } .empty { color: var(--muted); padding: 8px; text-align: center; } diff --git a/web/static/js/admin.js b/web/static/js/admin.js index 01e222d..a732a4c 100644 --- a/web/static/js/admin.js +++ b/web/static/js/admin.js @@ -135,9 +135,21 @@ function renderByDay(rows) { + `${fmtTokens(r.tokens_in)}` + `${fmtTokens(r.tokens_out)}` + ``).join("") || `无数据`; + const sum = rows.reduce((a, r) => { + a.cost_cny += r.cost_cny || 0; + a.tokens_in += r.tokens_in || 0; + a.tokens_out += r.tokens_out || 0; + return a; + }, { cost_cny: 0, tokens_in: 0, tokens_out: 0 }); + const foot = rows.length ? `` + + `合计` + + `${fmtCNY(sum.cost_cny)}` + + `${fmtTokens(sum.tokens_in)}` + + `${fmtTokens(sum.tokens_out)}` + + `` : ""; return `

近 7 天用量(按天)

` + `` - + `${body}
日期成本输入输出
`; + + `${body}${foot}`; } // 按模型(时间筛选 + 排序)。d = {range, sort, rows}