8000 feat(release): 发布 v0.2.0,完善 Web、移动端与计价 by InfinityPacer · Pull Request #1 · InfinityPacer/meterleaf · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
47cb8b0
feat(web): add mobile app navigation and PWA layouts
InfinityPacer Sep 9, 2026
c0b74bf
fix(web): refine reference layouts and recover shrinking pages
InfinityPacer Sep 9, 2026
24a03e6
fix(web): name the mobile trend data group
InfinityPacer Sep 9, 2026
4b637ef
docs(agent): clarify product evidence and recovery
InfinityPacer Sep 9, 2026
9a4f2f3
fix(web): refine responsive trends and account layouts
InfinityPacer Sep 9, 2026
c3b0cbc
fix(web): restore appearance before the first paint
InfinityPacer Sep 9, 2026
550d52c
fix(web): tighten mobile navigation and expose table sorting
InfinityPacer Sep 9, 2026
4519fe0
fix(web): style sorting menus across responsive layouts
InfinityPacer Sep 9, 2026
7a7eca1
fix(web): clarify mobile request summaries
InfinityPacer Sep 9, 2026
fd0e559
fix(web): show available effort in mobile request rows
InfinityPacer Sep 9, 2026
3ad4f92
fix(reports): retain priced totals and align distribution shares
InfinityPacer Sep 9, 2026
8cb6115
fix(sync): distinguish expired authentication from network failures
InfinityPacer Sep 9, 2026
13fad77
refactor(web): simplify cost labels and remove pricing explanations
InfinityPacer Sep 9, 2026
d1cbc33
fix(pricing): complete image rates and align Sub2API cache allocation
InfinityPacer Sep 9, 2026
1b10486
fix(web): unify quota visibility and Meterleaf brand icons
InfinityPacer Sep 9, 2026
3708479
fix(web): center single quotas and unify alert colors
InfinityPacer Sep 9, 2026
fb2ac8f
fix(web): pair mobile quota costs with eligible estimates
InfinityPacer Sep 9, 2026
418d6e7
fix(web): retain desktop quota windows and trend panels
InfinityPacer Sep 9, 2026
3846799
docs(readme): refresh web and mobile screenshots
InfinityPacer Sep 9, 2026
124c766
fix(quota): always show desktop weekly estimates
InfinityPacer Sep 9, 2026
32f00fa
chore(release): prepare 0.2.0
InfinityPacer Sep 9, 2026
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
16 changes: 12 additions & 4 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
# Repository Guidelines

Meterleaf 是独立 AI 用量账本,只读采集上游用量并在本地计价与展示。产品入口见 [README](README.md),账务口径见 [计价说明](docs/pricing.md) 和 [使用与报表](docs/reporting.md),部署与发布分别见 [部署指南](docs/deployment.md) 和 [版本与发布](docs/releasing.md)。

恢复工作时,读取当前任务实际引用的记录及必要设计、证据。没有记录时依据当前上下文继续;新的恢复记录可保存到 `.workbench/records/`。

## 项目结构与架构

- `src/connectors` 解释上游字段;`src/domain` 定义用量和计价规则;`src/storage` 负责持久化与汇总索引。
- `src/server` 提供 API 和同步服务;`src/shared` 定义共享契约;`src/web` 实现 React 界面;`public` 存放静态 10BC8 资源。
- `tests` 存放测试,`prices` 管理版本化费率 JSON,`docs` 存放中文文档。
- 领域模型与报表不得依赖 Sub2API SQL 或列名。用量与额度快照是独立能力;未知值不得补零,缓存与推理 Tokens 不得重复累计,网关扣费与独立估值必须区分。
- 普通输入、缓存读取、缓存写入、输出是互斥计量桶;推理 Tokens 是输出子集。上游金额、网关扣费、订阅等价 USD、标准 API USD 和 Credits 保留各自依据,不能互相冒充账单或按固定比例换算。估值绑定价格表修订、有效时间与实际来源;缺少字段或费率保留未计价。
- 累计用量、筛选时段和订阅周期分别计算。API 接入类型不能推断上游是否有订阅额度;额度窗口按有效快照判断,过期或未知不能沿用旧值。

## 开发与验证命令

Expand Down Expand Up @@ -39,16 +45,18 @@
- 单元与集成测试使用 Bun,命名为 `tests/*.test.ts`;浏览器测试使用 Playwright,专项脚本通常命名为 `*.browser.ts`。
- 修复问题时覆盖对应回归场景;计价、迁移和同步变更需验证未知值、幂等与失败恢复,不以虚构覆盖率作为门槛。
- 界面改动检查桌面、移动端和减少动态效果模式;`bun run test:browser` 通过 `METERLEAF_CDP_URL` 连接任务浏览器。截图放入已忽略的 `test-results`,视觉验收由维护者确认。
- 浏览器测试使用独立任务标签;修改 localStorage 时与维护者预览页隔离 origin。CDP 连接放在有 `finally` 清理的脚本内,结束时撤销模拟并断开连接,不在长期 REPL 中遗留 Playwright 客户端;系统主题须在清理后再次刷新验证。
- 高保真参考与维护者已认可版本是视觉依据,修复前保留其可恢复位置和已知缺陷。代理预审按当前任务要求校对参考、导航和受影响状态,明确偏差先处理;预审通过与维护者最终接受分别记录。维护者接管验收时交出可访问版本和已知限制。
- 纯文档改动核对对应事实、相对链接、所改 Markdown 的 Prettier 检查与 `git diff --check`,不触发产品完整测试。

## 提交与 Pull Request

- 每次提交必须使用 `type(scope): summary`,type 和 scope 均不可省略。
- type 使用 `feat`、`fix`、`refactor`、`style`、`test`、`docs`、`build`、`chore` 等;scope 指明模块,例如 `fix(sync): preserve cursor after failed batch`。
- 一次提交围绕一个完整目的,验证后形成本地提交;不混入无关修改或改写他人工作。
- PR 说明改动、相关问题和验证结果;界面变更附截图,未验证项说明原因。创建远程仓库、推送、PR 和发布需明确授权。
- PR 说明用户可见变化、相关问题和验证结果;界面变更附截图,未验证项说明原因。

## 配置与协作边界

- 首版按 `.env.example` 通过环境变量连接一个 Sub2API 实例,不提供来源管理、内置认证或用户角色系统。
- 当前按 `.env.example` 通过环境变量连接一个 Sub2API 实例,来源管理、内置认证和用户角色系统不在当前产品范围。
- 项目采用 Apache-2.0。凭据、真实账户数据、运行数据库、机器路径及构建产物不得进入公开交付内容;真实数据失败不得静默替换为演示数据。
- 恢复工作先读取独立管理的 `.workbench` 状态与活动事项;工作台不属于产品交付内容。部署不等于发布授权,未经明确要求不得清库或修改同步设置。
- 工作台不属于产品交付内容。排查报表或同步失败先区分读取和采集阶段;清库、修改同步设置不作为默认恢复动作。
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## [未发布]

## [0.2.0] - 2026-09-10

- 重做 Web 与移动端布局,提供桌面侧栏、手机 App 底部导航和可选侧栏模式,并记住导航、主题与配色选择。
- 将总览分为累计总览和时间段用量,新增账户累计或区间指标、账户近 7 天趋势,以及可切换柱状、折线和面积图的趋势展示。
- 统一展示 5h 与 7d 额度、重置时间和周期用量,隐藏无效的 5h 窗口;Web 保留 7d 预估及金额,移动端周额度用满时隐藏 5h 和预估。
- 增强统计报表与请求明细,支持模型分布按 Tokens 或费用查看,并按模型、请求数、Tokens、费用或占比排序;移动端提供列表、搜索、排序和分页操作。
- 改进数据同步反馈,区分认证、网络、网关、源数据库和本地写入失败,支持重试、重新认证和暂停页面自动更新,并在刷新失败时保留上次成功报表。
- 扩展图像模型计价,覆盖 GPT Image 2、GPT Image 2.5 Sunburst 和 Flare 的图像输入、缓存读取与输出 Tokens,避免与文本 Tokens 重复计算。
- 费用汇总和 7d 预估保留可用金额,个别未计价记录不再使整个周期显示 `N/A`,并统一费用与占比的展示口径。
- 支持将 Meterleaf 安装为独立 PWA 窗口;断网时显示离线页,不展示旧账本或缓存的账户数据。
- 新增关于页面,统一品牌图标,更新桌面侧栏视觉和 Web、移动端截图。

## [0.1.0] - 2026-09-09

- 独立采集 Sub2API 用量,提供总览、账户额度、统计报表与请求明细。
Expand Down
25 changes: 20 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,43 @@ Meterleaf 只读采集一个 Sub2API PostgreSQL 实例,将用量保存到本

## 界面预览

### 用量总览
### Web

![历史累计、账户额度与消耗趋势](docs/images/overview.jpg)
![Web 用量总览:历史累计、账户额度与消耗趋势](docs/images/web-overview.png)

<details>
<summary>账户额度</summary>

![账户周期用量、重置时间与七天预估](docs/images/accounts.jpg)
![Web 账户额度:周期用量、重置时间与预估趋势](docs/images/web-accounts.png)

</details>

<details>
<summary>统计报表</summary>

![模型分布与分组汇总](docs/images/reports.jpg)
![Web 统计报表:模型分布与分组汇总](docs/images/web-reports.png)

</details>

<details>
<summary>请求明细</summary>

![请求来源、模型、推理强度与用量](docs/images/requests.jpg)
![Web 请求明细:模型、推理强度与用量](docs/images/web-requests.png)

</details>

### 移动端

| 用量总览 | 账户额度 |
| ------------------------------------------------------------------------------ | ------------------------------------------------------------------------------ |
| <img src="docs/images/mobile-overview.png" alt="移动端用量总览" width="300" /> | <img src="docs/images/mobile-accounts.png" alt="移动端账户额度" width="300" /> |

<details>
<summary>统计报表与请求明细</summary>

| 统计报表 | 请求明细 |
| ----------------------------------------------------------------------------- | ------------------------------------------------------------------------------ |
| <img src="docs/images/mobile-reports.png" alt="移动端统计报表" width="300" /> | <img src="docs/images/mobile-requests.png" alt="移动端请求明细" width="300" /> |

</details>

Expand Down
2 changes: 1 addition & 1 deletion THIRD_PARTY_NOTICES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Lucide

`public/favicon.svg` 的叶片图形来自 Lucide Leaf,与应用内图标保持一致,保留以下许可证原文。
应用内的操作与导航图标使用 `lucide-react`,保留以下许可证原文。

ISC License

Expand Down
2 changes: 2 additions & 0 deletions docs/deployment.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ docker compose up -d --no-build --pull never

完成后用 `docker compose ps` 检查状态,默认访问 `http://127.0.0.1:4318`。镜像以 Bun 用户运行,挂载目录必须可写;不要让多个 Meterleaf 进程共用同一账本。发布流程见[版本与发布](releasing.md)。

生产构建包含 PWA 清单、图标和离线页,浏览器可将应用安装为独立窗口,无需额外安装插件。除本机地址外,需要 HTTPS;反向代理须允许访问 `/manifest.webmanifest`、`/sw.js`、`/offline.html` 和 `/icons/*`。离线资源不缓存 API 或账户数据,断网后重新打开不会展示旧账本。

随附 Compose 仅绑定宿主机回环地址。如果反向代理在其他容器中,应加入共享 Docker 网络并访问 `meterleaf:4318`,或显式调整宿主机绑定地址。应用不内置认证,可在代理层接入 OAuth/OIDC 认证。

## 配置
Expand Down
Binary file removed docs/images/accounts.jpg
Binary file not shown.
Binary file added docs/images/mobile-accounts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/mobile-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/mobile-reports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/mobile-requests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed docs/images/overview.jpg
Binary file not shown.
Binary file removed docs/images/reports.jpg
Binary file not shown.
Binary file removed docs/images/requests.jpg
Binary file not shown.
Binary file added docs/images/web-accounts.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/web-overview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/web-reports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/web-requests.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion docs/pricing.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,20 @@ Credits 使用独立规则,不设置 `usdBasis`。两个 USD 分支与 Credits

Sol 的已公布促销价已经写入两个 USD 分支,不再额外乘以 `0.8`;`promotion.confirmedThrough` 只表示至少确认到该日期。Astra Credits 超过 272K 后按选定订阅规则继续使用标准上下文费率。

GPT-5.6 的 Credits 使用对应模型的标准 Token 费率,不套用 API 长上下文加价。

图像规则可指定 `imageRates`,分别配置图像输入、缓存读取和输出的费率。
图像 Tokens 是现有输入、缓存和输出总量的子集,计价时先拆出,再按各自费率相加,不重复累计 Tokens。

### 内置价格与缺失规则

具体金额、模型覆盖和来源链接以 [内置价格 JSON](../prices/openai-2026-09-09.json) 为准,文档不另行维护一份费率表。内置表是特定版本的观测快照,不保证与供应商未来价格实时一致。

GPT-5.4 与 Mini 使用各自规则,不相互继承长上下文档位;未配置的 Fast、Flex 或缓存写入费率不会从标准档推导。内置表的促销说明只描述该版本已采用的规则,不能据此假设促销结束后的价格。

未配置的模型不会自动别名到其他模型。网关参考价不是已核实的官方报价,也不能用于推导订阅 Credits。图像与实时模型可能需要额外媒体 Token 桶,不能用文本四桶冒充完整费用。
内置表覆盖 GPT Image 2、GPT Image 2.5 Sunburst 和 Flare,以及各自已公布的日期快照。两代图像模型配置相同的 USD 和 Credits Token 单价。

未配置的模型不会自动别名到其他模型。网关参考价不是已核实的官方报价,也不能用于推导订阅 Credits。图像与实时模型需要相应媒体 Token 分桶,不能用文本四桶冒充完整费用。

排查缺失金额时,依次核对计价模型、服务档位、币种、USD 口径、有效日期和实际使用的 Token 桶。来源缺价时的零费用不是免费的证据;Meterleaf 保留未知值。

Expand Down
6 changes: 5 additions & 1 deletion docs/reporting.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
| 统计报表 | 模型分布与小时、天、周、模型、账户分组汇总 | 按本页日期和筛选条件 |
| 请求明细 | 来源、模型、推理强度、账户、Token 数和费用;点击查看完整证据 | 按本页条件筛选并在服务端分页 |

总览中无额度快照的账户卡片展示所选时段用量,而不是历史累计。API 接入只表示接入方式;有快照时仍可展示订阅额度。
Web 总览中无额度快照的账户卡片展示所选时段用量;手机 App 首页优先展示该账户历史累计,缺少累计时才使用当前区间汇总。API 接入只表示接入方式;有快照时仍可展示订阅额度。

手机默认使用 App 模式,底部为首页、账户、统计、明细和我的。首页的时间段用量入口打开独立趋势页,微型趋势固定显示全账户近 30 天。可在“我的”中切换为侧栏模式;导航模式和主题会记住,重新打开仍然生效。

## 筛选与图表

Expand All @@ -21,6 +23,8 @@

主题、USD 估算口径和账户顺序全局共享。主题可以跟随系统,也可手动选择明暗和配色。

支持 PWA 的浏览器可使用原生安装入口,将 Meterleaf 安装为独立窗口。断网后重新打开时只显示离线提示,不显示旧账本;恢复网络后刷新页面获取当前数据。

消耗趋势支持小时、天、周粒度,可切换柱状图、折线图和面积图;饼图展示模型占比,不表示时间变化。USD、Credits 和 Tokens 使用同一份报表结果切换。

## 账户管理
Expand Down
46 changes: 45 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,53 @@
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="viewport"
content="width=device-width, initial-scale=1.0, viewport-fit=cover"
/>
<meta name="theme-color" content="#f7f8fa" />
<style>
:root {
background: #f7f8fa;
color-scheme: light;
}
:root.dark {
background: #171b20;
color-scheme: dark;
}
</style>
<script id="theme-bootstrap">
// 在样式和应用模块加载前恢复外观,避免刷新时先绘制浅色页面。
(() => {
let mode = "system";
let palette = "default";
try {
mode = localStorage.getItem("meterleaf-theme") || "system";
palette =
localStorage.getItem("meterleaf-palette") === "natural"
? "natural"
: "default";
} catch {}
const dark =
mode === "dark" ||
(mode !== "light" &&
matchMedia("(prefers-color-scheme: dark)").matches);
document.documentElement.classList.toggle("dark", dark);
document.documentElement.dataset.palette = palette;
document.querySelector('meta[name="theme-color"]').content = dark
? "#171b20"
: "#f7f8fa";
})();
</script>
<link rel="icon" type="image/svg+xml" sizes="any" href="/favicon.svg" />
<link rel="manifest" href="/manifest.webmanifest" />
<link
rel="apple-touch-icon"
sizes="180x180"
href="/icons/meterleaf-leaf-180.png"
/>
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-title" content="Meterleaf" />
<meta name="description" content="Meterleaf:独立的 AI 用量账本。" />
<title>Meterleaf</title>
</head>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "meterleaf",
"version": "0.1.0",
"version": "0.2.0",
"private": true,
"type": "module",
"license": "Apache-2.0",
Expand Down
Loading
0