dsh-spend-ledger 1.2.0 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,59 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.2
4
+
5
+ 浅色模式下热力图的方块默认是黑的——只修这一处,深色模式保持不变。
6
+
7
+ ### 每日热力图
8
+
9
+ - **原因**:每一格的颜色写在内联 `style` 里(`BLUE_RAMP`,深色主题的深灰蓝,
10
+ 空格子是 `#252a31`)。宿主切主题靠 `body[data-ds-dark-theme]`,内联样式压在
11
+ 这层之上,换到浅色时深色值原样留在白卡上,看起来就是一片黑。
12
+ - **改法**:颜色只写在 CSS 里、按主题分两层——`.ts-cell-paint` 及其 `-l1..4`
13
+ 是深色(原值逐字节照搬),`body:not([data-ds-dark-theme])` 覆盖成浅色。
14
+ JS 只负责「级别 → 类名」,不再产出任何颜色值;图例色块同步走同一套类名。
15
+ - **浅色五档**:空格子 `#eef1f6` 贴近卡片白底,`l1`–`l4` 由浅蓝加深到 `#1d5fd1`。
16
+ 相邻两档至少差 `1.22:1`、最深一档对白底 `5.8:1`——四档能一眼分开,
17
+ 又不会深到像个洞。
18
+ - **深色**:逐档取像素核对,五档与改动前完全一致。
19
+
20
+ ### 选中描边(两个主题都改了)
21
+
22
+ - 选中环原来取 `currentColor`,也就是 `--dsw-alias-label-primary`——浅色主题下它
23
+ 接近纯黑,压在蓝块上就是一圈黑边。
24
+ - 固定颜色本来就不可能对:环要压在 5 档底色上,而底色从近白跨到实蓝、从深灰跨到
25
+ 亮蓝。纯黑在浅色 `l4` 只剩 3.3:1,纯白在浅色 `l0` 只有 1.1:1;深色里纯白环压在
26
+ `l0` 上是 14:1,就是那道扎眼的硬白边。
27
+ - 改为按档位各自解一个目标反差(`--ts-ring`):深色统一 5.2:1、浅色浅档 4.5:1。
28
+ 越浅的底给越深的环、越深的底给越亮的环,整排看过去力度一致。
29
+ - 深色:`#999b9f` → `#abadb2` → `#d0d6dc` → `#fefefe` → `#ffffff`
30
+ - 浅色:`#546ea2` → `#40609e` → `#224990` → `#ffffff` → `#ffffff`
31
+ - 键盘聚焦仍是 2px 品牌色,与鼠标选中的 1.5px 区分开。
32
+
33
+ ## 1.2.1
34
+
35
+ 只改「此刻」与「选中」的画法,其余不动。
36
+
37
+ ### 侧栏 24 小时峰谷条
38
+
39
+ - 当前小时不再描边:7–9px 高的格子上,1px 描边会吃掉自己的圆角、挨到邻格,
40
+ 整条会多出一个突兀的方框,还会把红绿的连续形状切断。改为**这一格提亮一档 +
41
+ 条下正对它落一个 3px 圆点**(紧凑模式 2.5px)。边界时刻(00 时、23 时)圆点
42
+ 仍居中于格内。
43
+
44
+ ### 每日热力图
45
+
46
+ - 选中日不再用 `outline`:outline 画在色块外面、自带矩形圆角,和色块自己的
47
+ 7px 圆角对不齐,读起来像"斜贴的相框",并把这一格的量级切断。改为 `::after`
48
+ 上的 `inset` 内描边,`border-radius: inherit` 贴着色块圆角走;颜色用
49
+ `currentColor` 跟随主题,键盘聚焦时加粗并改用品牌色。
50
+
51
+ ### 文档
52
+
53
+ - README、`package.json`、`locale/*.json` 里"价格条 / 对数价"的说法已过期
54
+ (实际是官方价目表),一并改正;README 配置表补上 `foldCachePath` 与
55
+ `warmupIntervalMs`。
56
+
3
57
  ## 1.2.0
4
58
 
5
59
  侧栏余额与官方峰谷状态、低余额提醒,加上账页的预算条与三层缓存;包名统一为
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
 
11
11
  - **余额**:充值余额、赠金余额(>0 时),读宿主账号服务已有的快照;可见时每 10 分钟、窗口重新聚焦时(60 秒节流)重读一次,失败保留上次值并标注"可能不是最新"。**没有账号插件时这一行只剩峰谷,其余照常。**
12
12
  - **峰谷状态**:按 DeepSeek 官方规则实时判断此刻是「高峰」还是「低谷」,只报**距离下一次切换还有多久**(如「预计 2 小时后转低谷」),不报钟点。
13
- - **24 小时峰谷条**:左 00:00、右 24:00,暖色块是高峰、其余是低谷,当前小时加一圈高亮;周末与法定节假日整天没有高峰。
14
- - **价格条**:每个模型三条(输入·命中 / 输入·未命中 / 输出),**条长 = 对数价**(价格跨三个数量级,线性长度看不出差别),颜色跟随当前时段;精确数字在悬停浮窗里。
13
+ - **24 小时峰谷条**:左 00:00、右 24:00,暖色块是高峰、其余是低谷;**此刻那一格提亮一档,条下正对它落一个圆点**——不描边,所以整条始终是一条连续的带子。周末与法定节假日整天没有高峰。
14
+ - **价目表**:每个模型一行(输入·命中 / 输入·未命中 / 输出),**当前时段那一侧加粗、另一侧淡显**,高峰列用红字;精确数字直接给,不做条形近似。
15
15
  - 所有悬停说明走同一只插件浮窗(顶层 Popover,不受侧栏窄列裁剪),**不使用原生 `title`**。
16
16
  - **低余额提醒**:花费页设一个「最低余额」(0 表示关闭);余额低于它时卡片里出现提醒条,条上只有一颗「充值」,点它把官方充值页放进卡片那一格,金额与支付方式都在那一页里选。
17
17
 
@@ -20,7 +20,7 @@
20
20
  - **全部用量**:输入 + 缓存读取 + 缓存写入 + 输出(等于服务商的 `totalTokens`,不是只看 input+output)。
21
21
  - **今日 / 昨日**:顶部给出今日用量与环比。
22
22
  - **用量构成**:四类 token 的占比条。
23
- - **14 天趋势 + 每日热力图**:按本地日历日分桶,点色块看当天明细。
23
+ - **14 天趋势 + 每日热力图**:按本地日历日分桶,点色块看当天明细。色阶与选中环都跟随主题:浅色是近白到实蓝、深色是深灰到亮蓝,选中环按档位各自取色(底色越浅环越深),所以两套主题下都能一眼分出四档、也不会出现黑框或硬白框。
24
24
  - **当天明细**:当天每个会话、每个模型各花了多少,以及缓存命中率。
25
25
  - **预算条**:日预算。没配 `budgetTokens` 时按历史最忙一天 ×1.25 取整推出来,只作参照。
26
26
  - **已删除会话仍计入**:删掉会话不会让历史花费凭空缩水,页面会单列这部分占比。
@@ -76,7 +76,7 @@ HTTP 202 # WAF 挑战页,不是 401 —— 请求根本没到业务
76
76
  ## 兼容性与降级
77
77
 
78
78
  - 侧栏槽位是宿主正式槽位 `sidebar.footer.action`(`order: 30`,排在 Qoder 额度卡之后、账号行之前),不依赖任何 DOM 层叠或内联样式。
79
- - 余额依赖宿主账号插件提供的 `accountUi` 服务;服务缺席时只隐藏余额部分,峰谷与价格条照常,用量页不受影响。
79
+ - 余额依赖宿主账号插件提供的 `accountUi` 服务;服务缺席时只隐藏余额部分,峰谷与价目表照常,用量页不受影响。
80
80
  - 账号读取失败显示"前往开放平台查看",**不把失败当成 0 余额**。
81
81
 
82
82
  ## 打开速度
@@ -93,7 +93,7 @@ HTTP 202 # WAF 挑战页,不是 401 —— 请求根本没到业务
93
93
  回归测试(不随包发布):
94
94
 
95
95
  ```
96
- node tests/pricing.test.mjs # 峰谷 / 金额 / 价条 / 浮窗落点
96
+ node tests/pricing.test.mjs # 峰谷 / 金额 / 价目表 / 浮窗落点
97
97
  node tests/foldcache.test.mjs # 折叠缓存的读写、重启恢复、损坏兜底
98
98
  ```
99
99
 
@@ -131,7 +131,7 @@ node tests/foldcache.test.mjs # 折叠缓存的读写、重启恢复、损坏
131
131
  | `cordis.patch.yml` | 插入 `spend-ledger` Loader 行(`dsh-spend-ledger`)。 |
132
132
  | `locale/en.json`、`locale/zh.json` | 插件管理器和设置页显示的元数据。 |
133
133
  | `CHANGELOG.md` | 版本记录。 |
134
- | `tests/pricing.test.mjs` | 峰谷/金额/价条的纯函数回归(不随包发布):`node tests/pricing.test.mjs`。 |
134
+ | `tests/pricing.test.mjs` | 峰谷/金额/价目表的纯函数回归(不随包发布):`node tests/pricing.test.mjs`。 |
135
135
  | `tests/foldcache.test.mjs` | 折叠缓存的读写、重启恢复、损坏兜底:`node tests/foldcache.test.mjs`。 |
136
136
  | `icon.svg` | 原始线条图标。 |
137
137
 
@@ -143,6 +143,8 @@ node tests/foldcache.test.mjs # 折叠缓存的读写、重启恢复、损坏
143
143
  | `cacheTtlMs` | `30000` | 内存缓存时长 |
144
144
  | `retainDeleted` | `true` | 保留已删除会话的用量 |
145
145
  | `ledgerPath` | `<DSH_HOME>/storages/token-spend/ledger.json` | 账本路径 |
146
+ | `foldCachePath` | `<DSH_HOME>/storages/token-spend/fold-cache.json` | 折叠结果落盘路径 |
147
+ | `warmupIntervalMs` | `600000` | 后台暖算间隔(最小 1 分钟) |
146
148
 
147
149
  ## 安装
148
150
 
package/client.js CHANGED
@@ -250,11 +250,107 @@ window.__ModuleLoader__.load({
250
250
  .ts-weekdays { display: grid; grid-template-rows: repeat(7, minmax(0, 1fr)); gap: 4px; font-size: 10px; color: var(--dsw-alias-label-tertiary); align-items: center; }
251
251
  .ts-grid { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; }
252
252
  .ts-col { display: grid; grid-template-rows: repeat(7, auto); gap: 4px; }
253
- .ts-cell { width: 100%; aspect-ratio: 1 / 1; border-radius: 7px; border: 1px solid transparent; padding: 0; cursor: pointer; transition: transform 140ms cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 140ms ease, filter 140ms ease; will-change: transform; }
253
+ .ts-cell { position: relative; color: var(--dsw-alias-label-primary); width: 100%; aspect-ratio: 1 / 1; border-radius: 7px; border: 1px solid transparent; padding: 0; cursor: pointer; transition: transform 140ms cubic-bezier(0.25, 0.1, 0.25, 1), box-shadow 140ms ease, filter 140ms ease; will-change: transform; }
254
254
  .ts-cell:hover:not(:disabled) { transform: translateY(-1px) scale(1.05); filter: brightness(1.08); z-index: 2; }
255
255
  .ts-cell:active:not(:disabled) { transform: translateY(0) scale(0.97); }
256
256
  .ts-cell:disabled { cursor: default; }
257
- .ts-cell-selected { outline: 2px solid var(--dsw-alias-brand-primary); outline-offset: 2px; }
257
+
258
+ /* ---------- 热力图涂装:颜色只在这里,按主题分两层 ----------
259
+ 宿主的主题开关是 body[data-ds-dark-theme]:浅色走 body 默认值,深色才挂这个属性。
260
+ 所以「深色 = 不带属性的那一层」写不了,只能反过来:先在 .ts-cell-paint 上写
261
+ **深色**(原值逐字节照搬),再用 body:not([data-ds-dark-theme]) 覆盖成浅色。
262
+ 这样深色模式与改动前完全一致,浅色不再出现黑方块。 */
263
+ .ts-cell-paint { background: var(--ts-heat-fill); border-color: var(--ts-heat-edge); box-shadow: var(--ts-heat-shadow); }
264
+
265
+ /* 深色(默认 = 无属性时也要对),故两层都显式给出: */
266
+ .ts-cell-paint,
267
+ body[data-ds-dark-theme] .ts-cell-paint {
268
+ --ts-heat-fill: #252a31;
269
+ --ts-heat-edge: rgba(185, 205, 224, 0.09);
270
+ --ts-heat-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.035), inset 0 -1px 0 rgba(0, 0, 0, 0.28);
271
+ }
272
+ .ts-cell-paint-l1, body[data-ds-dark-theme] .ts-cell-paint-l1 {
273
+ --ts-heat-fill: #323943; --ts-heat-edge: rgba(194, 214, 232, 0.08);
274
+ --ts-heat-shadow: inset 0 1px 0 rgba(194, 214, 232, 0.08), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 0, 0, 0.24);
275
+ }
276
+ .ts-cell-paint-l2, body[data-ds-dark-theme] .ts-cell-paint-l2 {
277
+ --ts-heat-fill: #3c566f; --ts-heat-edge: rgba(164, 210, 239, 0.16);
278
+ --ts-heat-shadow: inset 0 1px 0 rgba(164, 210, 239, 0.16), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 28, 56, 0.30);
279
+ }
280
+ .ts-cell-paint-l3, body[data-ds-dark-theme] .ts-cell-paint-l3 {
281
+ --ts-heat-fill: #3d7197; --ts-heat-edge: rgba(162, 222, 246, 0.23);
282
+ --ts-heat-shadow: inset 0 1px 0 rgba(162, 222, 246, 0.23), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 30, 68, 0.36);
283
+ }
284
+ .ts-cell-paint-l4, body[data-ds-dark-theme] .ts-cell-paint-l4 {
285
+ --ts-heat-fill: #3c82b8; --ts-heat-edge: rgba(177, 228, 246, 0.28);
286
+ --ts-heat-shadow: inset 0 1px 0 rgba(177, 228, 246, 0.28), inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 3px rgba(0, 32, 84, 0.42);
287
+ }
288
+
289
+ /* 浅色:同一套蓝,方向反过来——空格子贴近卡片白底,有量的从浅蓝加深到实蓝。
290
+ 档位取值按反差挑过:相邻两档至少差 1.22:1,最深一档对白底 5.8:1,
291
+ 既能一眼分出四档,又不会深到在浅底上像个洞。
292
+ 边缘用半透明深蓝,内阴影只在顶部留一道极淡高光。 */
293
+ body:not([data-ds-dark-theme]) .ts-cell-paint {
294
+ --ts-heat-fill: #eef1f6;
295
+ --ts-heat-edge: rgba(15, 23, 42, 0.07);
296
+ --ts-heat-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), inset 0 -1px 0 rgba(15, 23, 42, 0.05);
297
+ }
298
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l1 {
299
+ --ts-heat-fill: #c7ddfb; --ts-heat-edge: rgba(29, 95, 209, 0.18);
300
+ --ts-heat-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 1px 2px rgba(29, 95, 209, 0.10);
301
+ }
302
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l2 {
303
+ --ts-heat-fill: #8ebef8; --ts-heat-edge: rgba(29, 95, 209, 0.24);
304
+ --ts-heat-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 1px 2px rgba(29, 95, 209, 0.14);
305
+ }
306
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l3 {
307
+ --ts-heat-fill: #4a8ee8; --ts-heat-edge: rgba(23, 78, 173, 0.32);
308
+ --ts-heat-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42), 0 1px 3px rgba(29, 95, 209, 0.20);
309
+ }
310
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l4 {
311
+ --ts-heat-fill: #1d5fd1; --ts-heat-edge: rgba(16, 56, 128, 0.40);
312
+ --ts-heat-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 1px 4px rgba(23, 78, 173, 0.28);
313
+ }
314
+ /* 选中不套外框:outline 画在色块外面,自带一套矩形圆角,和色块自己的 7px 圆角
315
+ 对不齐,于是读起来像"斜贴了一个相框",还把这一格的量级切断了。
316
+ 改成贴着色块自己的圆角画一圈内描边:形状不变,只是这一格的边界更清楚。
317
+
318
+ 描边颜色不能是一个固定值:它压在 5 档底色上,档位从近白跨到实蓝、从深灰跨到亮蓝。
319
+ 一个颜色必然在某一档上翻车——纯黑在浅色 l4 只剩 3.3:1,纯白在浅色 l0 只有 1.1:1;
320
+ 深色主题里纯白压在 l0 上是 14:1,就是那道扎眼的硬白边。
321
+ 所以按档位各自解一个目标反差:深色统一 5.2:1、浅色浅档 4.5:1,
322
+ 越浅的底给越深的环、越深的底给越亮的环,整排看过去力度才是一致的。 */
323
+ .ts-cell-selected { outline: none; }
324
+ .ts-cell-selected::after {
325
+ content: '';
326
+ position: absolute;
327
+ inset: 0;
328
+ border-radius: inherit;
329
+ box-shadow: inset 0 0 0 1.5px var(--ts-ring);
330
+ pointer-events: none;
331
+ }
332
+ /* 深色:每档都对自己底色约 5.2:1。深档收在近白而不是纯白,避免硬边。 */
333
+ .ts-cell-selected,
334
+ body[data-ds-dark-theme] .ts-cell-selected { --ts-ring: #999b9f; }
335
+ .ts-cell-paint-l1.ts-cell-selected,
336
+ body[data-ds-dark-theme] .ts-cell-paint-l1.ts-cell-selected { --ts-ring: #abadb2; }
337
+ .ts-cell-paint-l2.ts-cell-selected,
338
+ body[data-ds-dark-theme] .ts-cell-paint-l2.ts-cell-selected { --ts-ring: #d0d6dc; }
339
+ .ts-cell-paint-l3.ts-cell-selected,
340
+ body[data-ds-dark-theme] .ts-cell-paint-l3.ts-cell-selected { --ts-ring: #fefefe; }
341
+ .ts-cell-paint-l4.ts-cell-selected,
342
+ body[data-ds-dark-theme] .ts-cell-paint-l4.ts-cell-selected { --ts-ring: #ffffff; }
343
+
344
+ /* 浅色:浅档给深蓝(约 4.5:1),深档给白(3.3–5.8:1)。 */
345
+ body:not([data-ds-dark-theme]) .ts-cell-selected { --ts-ring: #546ea2; }
346
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l1.ts-cell-selected { --ts-ring: #40609e; }
347
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l2.ts-cell-selected { --ts-ring: #224990; }
348
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l3.ts-cell-selected { --ts-ring: #ffffff; }
349
+ body:not([data-ds-dark-theme]) .ts-cell-paint-l4.ts-cell-selected { --ts-ring: #ffffff; }
350
+ /* 键盘聚焦:加粗到 2px 并改用品牌色,与鼠标点击的选中区分开。 */
351
+ .ts-cell-selected:focus-visible::after {
352
+ box-shadow: inset 0 0 0 2px var(--dsw-alias-brand-primary);
353
+ }
258
354
  /* Matte nylon-blue: depth comes from restrained edges and shadows, without a gloss layer over every tile. */
259
355
  /* Hover readout: replaces the unthemeable native title tooltip. JS places it
260
356
  below the hovered cell and moves it above / clamps it when an edge would clip
@@ -390,16 +486,25 @@ window.__ModuleLoader__.load({
390
486
  .tsb-railText { font-size: 9.5px; color: var(--dsw-alias-label-secondary); }
391
487
  .tsb-error { font-size: 10px; line-height: 1.5; color: var(--dsw-alias-state-error-primary); word-break: break-word; }
392
488
 
393
- /* 24 小时峰谷格子图:每小时一格,高峰红、其余绿,当前小时加亮边。
489
+ /* 24 小时峰谷格子图:每小时一格,高峰红、其余绿。
394
490
  用网格排版而不是一根连续长条——格子位置由布局决定,不依赖像素取整,
395
- 所以对齐天生是齐的,也不会有色块交界的混合像素。 */
491
+ 所以对齐天生是齐的,也不会有色块交界的混合像素。
492
+ 「此刻」不画框:7–9px 高的格子上,任何描边都会吃掉自己的圆角、挨到邻格,
493
+ 整条就多出一个突兀的方框,红绿的形状还被切断。改成一个圆点落在条下方,
494
+ 正对着当前这一格,同时那一格比其余亮一档——指示清楚,形状不变。 */
396
495
  .ts-tl { position: relative; width: 100%; padding-top: 3px; }
397
496
  .ts-tl-cells { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 1px; height: 9px; }
398
497
  .ts-tl-compact .ts-tl-cells { height: 7px; }
399
- .ts-tl-cell { border-radius: 1.5px; min-width: 0; }
498
+ .ts-tl-cell { border-radius: 2px; min-width: 0; transition: filter 180ms ease; }
400
499
  .ts-tl-cell-off { background: var(--dsw-alias-state-success-primary); }
401
500
  .ts-tl-cell-peak { background: var(--dsw-alias-state-error-primary); }
402
- .ts-tl-cell-now { box-shadow: 0 0 0 1px var(--dsw-alias-label-primary); }
501
+ /* 此刻:满色再提亮一档,靠对比被看见,不靠描边。 */
502
+ .ts-tl-cell-now { filter: brightness(1.22) saturate(1.06); }
503
+ /* 指示点:与格列同宽的网格,未选中的格子占位但不可见,点子居中于当前格。 */
504
+ .ts-tl-marks { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 1px; height: 3px; margin-top: 2px; }
505
+ .ts-tl-compact .ts-tl-marks { height: 2.5px; margin-top: 2px; }
506
+ .ts-tl-mark { justify-self: center; align-self: center; width: 3px; height: 3px; border-radius: 50%; background: var(--dsw-alias-label-primary); }
507
+ .ts-tl-compact .ts-tl-mark { width: 2.5px; height: 2.5px; }
403
508
  .ts-tl-hours { display: flex; justify-content: space-between; margin-top: 3px; font-size: 8.5px; line-height: 1.2; color: var(--dsw-alias-label-tertiary); font-variant-numeric: tabular-nums; }
404
509
  .ts-bal-timeline { padding: 4px 20px 10px; }
405
510
 
@@ -444,9 +549,6 @@ window.__ModuleLoader__.load({
444
549
  .ts-bal-table-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 6px; }
445
550
  .ts-bal-table-title { font-size: 11.5px; color: var(--dsw-alias-label-secondary); }
446
551
  .ts-bal-foot { padding: 8px 20px 12px; border-top: 1px solid var(--dsw-alias-border-l1); font-size: 10.5px; color: var(--dsw-alias-label-tertiary); line-height: 1.5; }
447
- @media (max-width: 720px) {
448
- .ts-pt-row { grid-template-columns: minmax(72px, 1.2fr) repeat(2, minmax(58px, 1fr)); font-size: 11px; }
449
- }
450
552
  `;
451
553
 
452
554
  function apiUrl(routePath) {
@@ -672,7 +774,7 @@ window.__ModuleLoader__.load({
672
774
  || t('peakWindowsHint');
673
775
  }
674
776
 
675
- /** 价条上的模型短名:`deepseek-` 与版本前缀都去掉,只留 flash / pro。 */
777
+ /** 价目表里的模型短名:`deepseek-` 与版本前缀都去掉,只留 flash / pro。 */
676
778
  function shortModel(id) {
677
779
  const name = typeof id === 'string' ? id : '';
678
780
  if (name.indexOf('deepseek-') !== 0) return name;
@@ -936,32 +1038,25 @@ window.__ModuleLoader__.load({
936
1038
  }
937
1039
 
938
1040
  /**
939
- * Matte nylon blue: low saturation, a cool steel base, and a compact cobalt
940
- * ramp. The depth comes from contrast between the tile and its edge, never
941
- * from a glossy gradient or neon highlight.
1041
+ * 热力图的档位:0 = 无用量,1–4 = intensity() 的四档。
1042
+ *
1043
+ * 色值只写在 CSS 里,按主题分两层:
1044
+ * .ts-cell-paint … -l4 深色(宿主默认层)
1045
+ * body:not([data-ds-dark-theme]) … 浅色
1046
+ *
1047
+ * 为什么不再由 JS 给颜色:宿主切主题靠 `body[data-ds-dark-theme]`,
1048
+ * 而内联 style 压在上面,换到浅色时深色值原样留在白底上——看起来就是一片黑。
1049
+ * 这里只负责级别 → 类名的映射,一处色值只维护一份。
942
1050
  */
943
- const BLUE_RAMP = [
944
- { fill: '#323943', edge: 'rgba(194, 214, 232, 0.08)', shadow: 'rgba(0, 0, 0, 0.24)' },
945
- { fill: '#3c566f', edge: 'rgba(164, 210, 239, 0.16)', shadow: 'rgba(0, 28, 56, 0.30)' },
946
- { fill: '#3d7197', edge: 'rgba(162, 222, 246, 0.23)', shadow: 'rgba(0, 30, 68, 0.36)' },
947
- { fill: '#3c82b8', edge: 'rgba(177, 228, 246, 0.28)', shadow: 'rgba(0, 32, 84, 0.42)' },
948
- { fill: '#4b93c8', edge: 'rgba(201, 238, 250, 0.34)', shadow: 'rgba(0, 38, 94, 0.46)' },
949
- ];
1051
+ const HEAT_LEVELS = 4;
950
1052
 
951
- function cellPaint(level) {
952
- return BLUE_RAMP[Math.max(0, Math.min(BLUE_RAMP.length - 1, level | 0))];
953
- }
954
-
955
- function cellStyle(level) {
956
- if (level <= 0) {
957
- return { background: '#252a31', borderColor: 'rgba(185, 205, 224, 0.09)', boxShadow: 'inset 0 1px 0 rgba(255, 255, 255, 0.035), inset 0 -1px 0 rgba(0, 0, 0, 0.28)' };
958
- }
959
- const step = cellPaint(level);
960
- return {
961
- background: step.fill,
962
- borderColor: step.edge,
963
- boxShadow: `inset 0 1px 0 ${step.edge}, inset 0 -1px 0 rgba(0, 0, 0, 0.25), 0 1px 3px ${step.shadow}`,
964
- };
1053
+ /**
1054
+ * 级别 → 涂装类名。0 是空格子,1–5 是五档热度。
1055
+ * 越界一律夹到两端,避免画出不存在的档。
1056
+ */
1057
+ function cellPaintClass(level) {
1058
+ const clamped = Math.max(0, Math.min(HEAT_LEVELS, level | 0));
1059
+ return `ts-cell-paint ts-cell-paint-l${clamped}`;
965
1060
  }
966
1061
 
967
1062
  function gradeTone(grade) {
@@ -1373,9 +1468,10 @@ window.__ModuleLoader__.load({
1373
1468
  }
1374
1469
 
1375
1470
  /**
1376
- * 24 小时峰谷格子图(今天,北京时间):每小时一格,高峰红、其余绿,
1377
- * 当前小时加一圈亮边。用网格排版,格子位置由布局决定,
1378
- * 不依赖像素取整,所以对齐天生是齐的。
1471
+ * 24 小时峰谷格子图(今天,北京时间):每小时一格,高峰红、其余绿。
1472
+ * 当前小时不描边——7–9px 的格子上描边会吃掉自己的圆角、挨到邻格,
1473
+ * 整条读出多出一个方框;改为这一格提亮一档、条下正对它落一个圆点。
1474
+ * 用网格排版,格子位置由布局决定,不依赖像素取整,所以对齐天生是齐的。
1379
1475
  */
1380
1476
  function PeakTimeline(props) {
1381
1477
  const t = props.t;
@@ -1401,6 +1497,9 @@ window.__ModuleLoader__.load({
1401
1497
  // 格子位置由布局决定,不依赖像素取整,所以不会有交界混色,看起来是齐的。
1402
1498
  const cells = hourCells(now);
1403
1499
  const nowHour = beijingParts(now).hour;
1500
+ // 「此刻」不描边:当前格提亮一档,条下正对它落一个圆点。
1501
+ // 整条始终是一条连续的进度带,不会多出一个打断形状的方框。
1502
+ const classOf = (hour) => `ts-tl-cell ts-tl-cell-${cells[hour].kind}${hour === nowHour ? ' ts-tl-cell-now' : ''}`;
1404
1503
  return h('div', { className: `ts-tl${props.compact ? ' ts-tl-compact' : ''}` },
1405
1504
  h('div', {
1406
1505
  className: 'ts-tl-cells',
@@ -1411,10 +1510,17 @@ window.__ModuleLoader__.load({
1411
1510
  },
1412
1511
  ...cells.map((cell) => h('span', {
1413
1512
  key: cell.hour,
1414
- className: `ts-tl-cell ts-tl-cell-${cell.kind}${cell.hour === nowHour ? ' ts-tl-cell-now' : ''}`,
1513
+ className: classOf(cell.hour),
1415
1514
  title: `${pad2(cell.hour)}:00 · ${cell.kind === 'peak' ? t('peak') : t('offPeak')}`,
1416
1515
  })),
1417
1516
  ),
1517
+ h('div', { className: 'ts-tl-marks', 'aria-hidden': 'true' },
1518
+ ...cells.map((cell) => h('span', {
1519
+ key: cell.hour,
1520
+ className: 'ts-tl-mark',
1521
+ style: { visibility: cell.hour === nowHour ? 'visible' : 'hidden' },
1522
+ })),
1523
+ ),
1418
1524
  props.compact ? null : h('div', { className: 'ts-tl-hours' },
1419
1525
  h('span', null, '00'),
1420
1526
  h('span', null, '12'),
@@ -1822,7 +1928,7 @@ window.__ModuleLoader__.load({
1822
1928
  }]
1823
1929
  : []),
1824
1930
  ];
1825
- // 价格只给图:三条价条的长度就是价,精确数字在悬停浮窗里。
1931
+ // 价格给数字:两模型 × 三项,当前时段那一侧加粗,另一侧淡显。
1826
1932
  return h('div', { className: 'ts-card' },
1827
1933
  h('div', { className: 'ts-bal-head' },
1828
1934
  h('div', null,
@@ -2143,14 +2249,15 @@ window.__ModuleLoader__.load({
2143
2249
  const counters = cellState.day === undefined ? undefined : countersOf(cellState.day);
2144
2250
  const total = counters?.total ?? 0;
2145
2251
  const level = cellState.future ? 0 : intensity(total, peak);
2146
- const className = `ts-cell${cellState.key === selected ? ' ts-cell-selected' : ''}`;
2252
+ // 颜色走类名而不是内联 style:内联会压过主题,浅色下就成了一片黑方块。
2253
+ const className = `ts-cell ${cellPaintClass(level)}${cellState.key === selected ? ' ts-cell-selected' : ''}`;
2147
2254
  // The browser's native `title` tooltip cannot be themed, so the cell
2148
2255
  // carries no title: hovering reports into the card's own tooltip.
2149
2256
  return h('button', {
2150
2257
  key: cellState.key,
2151
2258
  type: 'button',
2152
2259
  className,
2153
- style: cellState.future ? { opacity: 0.35 } : cellStyle(level),
2260
+ style: cellState.future ? { opacity: 0.35 } : undefined,
2154
2261
  disabled: cellState.future,
2155
2262
  'aria-label': `${cellState.key} · ${fmtTokens(total)} tokens`,
2156
2263
  onMouseEnter: cellState.future ? undefined : (event) => showHover(cellState, event.currentTarget),
@@ -2186,7 +2293,7 @@ window.__ModuleLoader__.load({
2186
2293
  ].map((entry) => h(
2187
2294
  'div',
2188
2295
  { key: entry.label, className: 'ts-legend-item' },
2189
- h('span', { className: 'ts-legend-swatch', style: cellStyle(entry.level) }),
2296
+ h('span', { className: `ts-legend-swatch ${cellPaintClass(entry.level)}` }),
2190
2297
  h('span', {}, entry.label),
2191
2298
  )),
2192
2299
  ),
package/locale/en.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "Spend",
4
- "description": "Shows the DeepSeek account balance and the official peak/off-peak state in the sidebar footer, above \"Signed in to DeepSeek\": a 24-hour peak strip and log-scaled price bars, the current period, and how long remains before the next switch. Adds a Spend page to Settings: real usage from every local session log counted as input + cache read + cache write + output, duplicated calls merged by message id, with a daily heatmap, usage composition, a 14-day trend and any day's detail. Usage of deleted sessions is kept in a local ledger."
4
+ "description": "Shows the DeepSeek account balance and the official peak/off-peak state in the sidebar footer, above \"Signed in to DeepSeek\": a 24-hour peak strip and the official price table, the current period, and how long remains before the next switch. Adds a Spend page to Settings: real usage from every local session log counted as input + cache read + cache write + output, duplicated calls merged by message id, with a daily heatmap, usage composition, a 14-day trend and any day's detail. Usage of deleted sessions is kept in a local ledger."
5
5
  }
6
- }
6
+ }
package/locale/zh.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "meta": {
3
3
  "title": "花费",
4
- "description": "左侧栏底部(「已登录 DeepSeek」上方)显示 DeepSeek 账号余额与官方峰谷状态:24 小时峰谷条、价格条,实时判断此刻是高峰还是低谷并给出距离下一次切换的时长。设置页新增「花费」:按输入 + 缓存读取 + 缓存写入 + 输出统计全部会话的真实用量,重复调用按消息 ID 去重,提供每日热力图、用量构成、14 天趋势与当天明细;已删除会话的用量仍保留在本地账本中。"
4
+ "description": "左侧栏底部(「已登录 DeepSeek」上方)显示 DeepSeek 账号余额与官方峰谷状态:24 小时峰谷条、官方价目表,实时判断此刻是高峰还是低谷并给出距离下一次切换的时长。设置页新增「花费」:按输入 + 缓存读取 + 缓存写入 + 输出统计全部会话的真实用量,重复调用按消息 ID 去重,提供每日热力图、用量构成、14 天趋势与当天明细;已删除会话的用量仍保留在本地账本中。"
5
5
  }
6
- }
6
+ }
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "dsh-spend-ledger",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "displayName": "花费",
5
- "description": "Token spend ledger settings page plus a sidebar footer row with the DeepSeek account balance and the official peak/off-peak state (24-hour strip and price bars): daily all-in token usage heatmap, cache efficiency, usage composition, and per-day session detail. Duplicated model calls are merged by message id, and a durable day ledger keeps recorded usage after a session is deleted.",
5
+ "description": "Token spend ledger settings page plus a sidebar footer row with the DeepSeek account balance and the official peak/off-peak state (24-hour strip and price table): daily all-in token usage heatmap, cache efficiency, usage composition, and per-day session detail. Duplicated model calls are merged by message id, and a durable day ledger keeps recorded usage after a session is deleted.",
6
6
  "type": "module",
7
7
  "icon": "./icon.svg",
8
8
  "exports": {