dsh-spend-ledger 1.2.0 → 1.2.1

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,29 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.2.1
4
+
5
+ 只改「此刻」与「选中」的画法,其余不动。
6
+
7
+ ### 侧栏 24 小时峰谷条
8
+
9
+ - 当前小时不再描边:7–9px 高的格子上,1px 描边会吃掉自己的圆角、挨到邻格,
10
+ 整条会多出一个突兀的方框,还会把红绿的连续形状切断。改为**这一格提亮一档 +
11
+ 条下正对它落一个 3px 圆点**(紧凑模式 2.5px)。边界时刻(00 时、23 时)圆点
12
+ 仍居中于格内。
13
+
14
+ ### 每日热力图
15
+
16
+ - 选中日不再用 `outline`:outline 画在色块外面、自带矩形圆角,和色块自己的
17
+ 7px 圆角对不齐,读起来像"斜贴的相框",并把这一格的量级切断。改为 `::after`
18
+ 上的 `inset` 内描边,`border-radius: inherit` 贴着色块圆角走;颜色用
19
+ `currentColor` 跟随主题,键盘聚焦时加粗并改用品牌色。
20
+
21
+ ### 文档
22
+
23
+ - README、`package.json`、`locale/*.json` 里"价格条 / 对数价"的说法已过期
24
+ (实际是官方价目表),一并改正;README 配置表补上 `foldCachePath` 与
25
+ `warmupIntervalMs`。
26
+
3
27
  ## 1.2.0
4
28
 
5
29
  侧栏余额与官方峰谷状态、低余额提醒,加上账页的预算条与三层缓存;包名统一为
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
 
@@ -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,28 @@ 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
+ /* 选中不套外框:outline 画在色块外面,自带一套矩形圆角,和色块自己的 7px 圆角
258
+ 对不齐,于是读起来像"斜贴了一个相框",还把这一格的量级切断了。
259
+ 改成贴着色块自己的圆角画一圈内描边:形状不变,只是这一格的边界更清楚。
260
+ 颜色用 currentColor,跟随主题,浅色主题下也不会变成一圈看不见的白线。 */
261
+ .ts-cell-selected { outline: none; }
262
+ .ts-cell-selected::after {
263
+ content: '';
264
+ position: absolute;
265
+ inset: 0;
266
+ border-radius: inherit;
267
+ box-shadow: inset 0 0 0 1.5px currentColor;
268
+ opacity: 0.88;
269
+ pointer-events: none;
270
+ }
271
+ .ts-cell-selected:focus-visible::after {
272
+ box-shadow: inset 0 0 0 2px var(--dsw-alias-brand-primary);
273
+ opacity: 1;
274
+ }
258
275
  /* Matte nylon-blue: depth comes from restrained edges and shadows, without a gloss layer over every tile. */
259
276
  /* Hover readout: replaces the unthemeable native title tooltip. JS places it
260
277
  below the hovered cell and moves it above / clamps it when an edge would clip
@@ -390,16 +407,25 @@ window.__ModuleLoader__.load({
390
407
  .tsb-railText { font-size: 9.5px; color: var(--dsw-alias-label-secondary); }
391
408
  .tsb-error { font-size: 10px; line-height: 1.5; color: var(--dsw-alias-state-error-primary); word-break: break-word; }
392
409
 
393
- /* 24 小时峰谷格子图:每小时一格,高峰红、其余绿,当前小时加亮边。
410
+ /* 24 小时峰谷格子图:每小时一格,高峰红、其余绿。
394
411
  用网格排版而不是一根连续长条——格子位置由布局决定,不依赖像素取整,
395
- 所以对齐天生是齐的,也不会有色块交界的混合像素。 */
412
+ 所以对齐天生是齐的,也不会有色块交界的混合像素。
413
+ 「此刻」不画框:7–9px 高的格子上,任何描边都会吃掉自己的圆角、挨到邻格,
414
+ 整条就多出一个突兀的方框,红绿的形状还被切断。改成一个圆点落在条下方,
415
+ 正对着当前这一格,同时那一格比其余亮一档——指示清楚,形状不变。 */
396
416
  .ts-tl { position: relative; width: 100%; padding-top: 3px; }
397
417
  .ts-tl-cells { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 1px; height: 9px; }
398
418
  .ts-tl-compact .ts-tl-cells { height: 7px; }
399
- .ts-tl-cell { border-radius: 1.5px; min-width: 0; }
419
+ .ts-tl-cell { border-radius: 2px; min-width: 0; transition: filter 180ms ease; }
400
420
  .ts-tl-cell-off { background: var(--dsw-alias-state-success-primary); }
401
421
  .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); }
422
+ /* 此刻:满色再提亮一档,靠对比被看见,不靠描边。 */
423
+ .ts-tl-cell-now { filter: brightness(1.22) saturate(1.06); }
424
+ /* 指示点:与格列同宽的网格,未选中的格子占位但不可见,点子居中于当前格。 */
425
+ .ts-tl-marks { display: grid; grid-template-columns: repeat(24, minmax(0, 1fr)); gap: 1px; height: 3px; margin-top: 2px; }
426
+ .ts-tl-compact .ts-tl-marks { height: 2.5px; margin-top: 2px; }
427
+ .ts-tl-mark { justify-self: center; align-self: center; width: 3px; height: 3px; border-radius: 50%; background: var(--dsw-alias-label-primary); }
428
+ .ts-tl-compact .ts-tl-mark { width: 2.5px; height: 2.5px; }
403
429
  .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
430
  .ts-bal-timeline { padding: 4px 20px 10px; }
405
431
 
@@ -672,7 +698,7 @@ window.__ModuleLoader__.load({
672
698
  || t('peakWindowsHint');
673
699
  }
674
700
 
675
- /** 价条上的模型短名:`deepseek-` 与版本前缀都去掉,只留 flash / pro。 */
701
+ /** 价目表里的模型短名:`deepseek-` 与版本前缀都去掉,只留 flash / pro。 */
676
702
  function shortModel(id) {
677
703
  const name = typeof id === 'string' ? id : '';
678
704
  if (name.indexOf('deepseek-') !== 0) return name;
@@ -1373,9 +1399,10 @@ window.__ModuleLoader__.load({
1373
1399
  }
1374
1400
 
1375
1401
  /**
1376
- * 24 小时峰谷格子图(今天,北京时间):每小时一格,高峰红、其余绿,
1377
- * 当前小时加一圈亮边。用网格排版,格子位置由布局决定,
1378
- * 不依赖像素取整,所以对齐天生是齐的。
1402
+ * 24 小时峰谷格子图(今天,北京时间):每小时一格,高峰红、其余绿。
1403
+ * 当前小时不描边——7–9px 的格子上描边会吃掉自己的圆角、挨到邻格,
1404
+ * 整条读出多出一个方框;改为这一格提亮一档、条下正对它落一个圆点。
1405
+ * 用网格排版,格子位置由布局决定,不依赖像素取整,所以对齐天生是齐的。
1379
1406
  */
1380
1407
  function PeakTimeline(props) {
1381
1408
  const t = props.t;
@@ -1401,6 +1428,9 @@ window.__ModuleLoader__.load({
1401
1428
  // 格子位置由布局决定,不依赖像素取整,所以不会有交界混色,看起来是齐的。
1402
1429
  const cells = hourCells(now);
1403
1430
  const nowHour = beijingParts(now).hour;
1431
+ // 「此刻」不描边:当前格提亮一档,条下正对它落一个圆点。
1432
+ // 整条始终是一条连续的进度带,不会多出一个打断形状的方框。
1433
+ const classOf = (hour) => `ts-tl-cell ts-tl-cell-${cells[hour].kind}${hour === nowHour ? ' ts-tl-cell-now' : ''}`;
1404
1434
  return h('div', { className: `ts-tl${props.compact ? ' ts-tl-compact' : ''}` },
1405
1435
  h('div', {
1406
1436
  className: 'ts-tl-cells',
@@ -1411,10 +1441,17 @@ window.__ModuleLoader__.load({
1411
1441
  },
1412
1442
  ...cells.map((cell) => h('span', {
1413
1443
  key: cell.hour,
1414
- className: `ts-tl-cell ts-tl-cell-${cell.kind}${cell.hour === nowHour ? ' ts-tl-cell-now' : ''}`,
1444
+ className: classOf(cell.hour),
1415
1445
  title: `${pad2(cell.hour)}:00 · ${cell.kind === 'peak' ? t('peak') : t('offPeak')}`,
1416
1446
  })),
1417
1447
  ),
1448
+ h('div', { className: 'ts-tl-marks', 'aria-hidden': 'true' },
1449
+ ...cells.map((cell) => h('span', {
1450
+ key: cell.hour,
1451
+ className: 'ts-tl-mark',
1452
+ style: { visibility: cell.hour === nowHour ? 'visible' : 'hidden' },
1453
+ })),
1454
+ ),
1418
1455
  props.compact ? null : h('div', { className: 'ts-tl-hours' },
1419
1456
  h('span', null, '00'),
1420
1457
  h('span', null, '12'),
@@ -1822,7 +1859,7 @@ window.__ModuleLoader__.load({
1822
1859
  }]
1823
1860
  : []),
1824
1861
  ];
1825
- // 价格只给图:三条价条的长度就是价,精确数字在悬停浮窗里。
1862
+ // 价格给数字:两模型 × 三项,当前时段那一侧加粗,另一侧淡显。
1826
1863
  return h('div', { className: 'ts-card' },
1827
1864
  h('div', { className: 'ts-bal-head' },
1828
1865
  h('div', null,
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.1",
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": {