Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified assets/dashboard/overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions docs/guide/dashboard.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ http://127.0.0.1:3392/dashboard

「供应商请求分布」与「订阅状态」并排一行,并排与堆叠的断点见[订阅状态](#订阅状态);三张趋势图共用一个图位的三个页签,页签行右端标明当前时间区间。

| 图表 | 说明 |
| ---------------------- | ---------------------------------------- |
| 供应商请求分布 | 所选时间区间内各供应商请求占比的甜甜圈图 |
| 请求量 | 按天的请求量 |
| Token(按供应商) | 各供应商按天的 Token 消耗 |
| Token(Vendor / 模型) | 模型级 Token 消耗 |
| 图表 | 说明 |
| -------------- | ---------------------------------------- |
| 供应商请求分布 | 所选时间区间内各供应商请求占比的甜甜圈图 |
| Requests | 按天的请求量 |
| Token / Vendor | 各供应商按天的 Token 消耗 |
| Token / Model | 模型级 Token 消耗 |

三张趋势图都是堆叠面积图,每条线填充到上一条堆叠线;所选区间没有数据时,图位显示「暂无数据」。图形读屏读不到,每张图的 canvas 带 `role=img` 与一句文字摘要(区间、合计、单日最高;分布图是各供应商占比)。分布图的图例默认在右侧;并排右列放不下最长的标签(视口约 1210px 以下)时移到图下方自动换行,避免标签被画布右缘裁掉。

Expand Down
8 changes: 5 additions & 3 deletions src/coding/proxy/server/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,6 +541,8 @@ def file_response(self, *args: Any, **kwargs: Any) -> Response:
border-bottom: 2px solid transparent;
padding: 8px 12px 10px;
font-family: inherit; font-size: 13px; font-weight: 500;
/* 行高钉死:normal 下含汉字的标签行盒 18px、纯拉丁 16px,页签行高与同排区间说明的基线不能随文案语言变 */
line-height: 18px;
color: var(--text-secondary);
white-space: nowrap; cursor: pointer;
transition: color .15s ease, border-color .15s ease;
Expand Down Expand Up @@ -1178,9 +1180,9 @@ def file_response(self, *args: Any, **kwargs: Any) -> Response:
<section class="card timeline-card" aria-label="趋势">
<div class="trend-head">
<div class="trend-tabs" role="tablist" aria-label="趋势图">
<button type="button" class="trend-tab" id="trend-tab-requests" role="tab" aria-selected="true" aria-controls="trend-panel-requests" tabindex="0" data-trend="requests">请求量</button>
<button type="button" class="trend-tab" id="trend-tab-tokens" role="tab" aria-selected="false" aria-controls="trend-panel-tokens" tabindex="-1" data-trend="tokens">Token(按供应商)</button>
<button type="button" class="trend-tab" id="trend-tab-models" role="tab" aria-selected="false" aria-controls="trend-panel-models" tabindex="-1" data-trend="models">Token(Vendor / 模型)</button>
<button type="button" class="trend-tab" id="trend-tab-requests" role="tab" aria-selected="true" aria-controls="trend-panel-requests" tabindex="0" data-trend="requests">Requests</button>
<button type="button" class="trend-tab" id="trend-tab-tokens" role="tab" aria-selected="false" aria-controls="trend-panel-tokens" tabindex="-1" data-trend="tokens">Token / Vendor</button>
<button type="button" class="trend-tab" id="trend-tab-models" role="tab" aria-selected="false" aria-controls="trend-panel-models" tabindex="-1" data-trend="models">Token / Model</button>
</div>
<span class="trend-range" id="trend-range">近 7 天</span>
</div>
Expand Down
8 changes: 5 additions & 3 deletions tests/test_dashboard_overview.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
("lat", "今日平均延迟", "kpi-card"),
)
_TREND_TABS = (
("requests", "请求量", "chart-timeline"),
("tokens", "Token(按供应商)", "chart-token-timeline"),
("models", "Token(Vendor / 模型)", "chart-model-token-timeline"),
("requests", "Requests", "chart-timeline"),
("tokens", "Token / Vendor", "chart-token-timeline"),
("models", "Token / Model", "chart-model-token-timeline"),
)


Expand Down Expand Up @@ -163,6 +163,8 @@ def test_overview_css_constraints(client: TestClient):
)
# 负下边距:选中页签的下划线盖住头部 hairline;负左边距:首个页签的文字与其它卡片标题左对齐
assert "margin: 0 0 -1px -12px;" in _rule(html, ".trend-tabs")
# 页签行高钉死:标签换成纯拉丁文案后行盒从 18px 缩到 16px,页签行矮 2px、与区间说明的基线错开 1px
assert "line-height: 18px;" in _rule(html, ".trend-tab")
# 区间标签只有「近 N 天」:标签与说明都不需要任意断行
assert "white-space: nowrap;" in _rule(html, ".trend-range")
assert "white-space: nowrap;" in _rule(html, ".kpi-sub-label, .kpi-sub-val")
Expand Down
Loading