balance-dsh 2.3.3 → 2.3.4
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/README.md +30 -11
- package/lib/client.js +485 -54
- package/lib/index.js +36 -12
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -16,13 +16,17 @@ DeepSeek Harness 插件:在 Web UI 中直接显示 DeepSeek 账户余额和当
|
|
|
16
16
|
- **新版(默认)**:上方一行文字信息 + 下方一条扁刻度条。
|
|
17
17
|
- 文字分两段:`今日 ¥21.42`(今天累计消耗)和 `空闲 剩 3h57m`(当前时段 + 距切换还剩多久,高峰为红色、空闲为绿色)。
|
|
18
18
|
- 刻度条整条代表**一整天**:彩色分段标出这一天里哪些时段是高峰、哪些是空闲,一个指针标出「此刻走在今天的哪个位置」,每分钟前进一格。换日或同步到新的节假日安排时,颜色分布会交叉淡入。
|
|
19
|
+
- **侧栏拖窄、一行放不下时自动切成三行**:`今日 ¥21.42` / `空闲 剩 3h57m` / 刻度条,整体居中,两行间距 3px。不会挤成省略号,也不会把设置齿轮顶歪。
|
|
20
|
+
- 「今日」的金额、以及「空闲 / 高峰」那一段都是**滑过去**的,不是瞬移:`剩 10h55m` 变成 `剩 10h54m` 时那一行横向补齐位移,看着像刻度在走。
|
|
19
21
|
- **旧版**:钱包图标 + `余额` + 金额(带货币单位)的纯文字行,右侧可带时段标签。
|
|
20
22
|
|
|
21
|
-
金额按余额状态变色:充足为主题绿、低于阈值(默认 10
|
|
23
|
+
金额按余额状态变色:充足为主题绿、低于阈值(默认 10 元)为琥珀黄、余额用完时金额胶囊整个换成红色 **「充值」** 按钮(点一下直达充值页)。金额变化时按位滚动切换(只滚变化的数位),不会整块闪一下。
|
|
22
24
|
|
|
23
25
|
### 收起态圆钮
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
侧边栏收起时,余额显示为 **60px 圆形**悬浮按钮(liquid glass 质感,圆内显示 `¥金额`,余额耗尽时显示「充值」)。直径与距左缘距离均可调。
|
|
28
|
+
|
|
29
|
+
位置钉在**左下角、底边距等于距左缘**(默认都是 44px),**不跟聊天框对齐**——窗口怎么缩放、输入框上面多一行少一行,它都待在原地不动。
|
|
26
30
|
|
|
27
31
|
### 刷新
|
|
28
32
|
|
|
@@ -40,6 +44,8 @@ DeepSeek Harness 插件:在 Web UI 中直接显示 DeepSeek 账户余额和当
|
|
|
40
44
|
- 今日 / 近 7 天 / 近 30 天、日均与峰值日
|
|
41
45
|
- 按日使用热力图
|
|
42
46
|
|
|
47
|
+
加载时是**一圈蓝色圆弧在转**(底环是暗色整圆,亮弧自己跑、弧长还会呼吸),下面跟一个每 100ms 往上跳的耗时数字——服务端一次性返回全部结果、给不出百分比,所以用「圈还在转 + 数字还在涨」表示没卡住。
|
|
48
|
+
|
|
43
49
|
点遮罩、按 `Esc`、点关闭按钮均可关闭。
|
|
44
50
|
|
|
45
51
|
### 高峰 / 空闲计费
|
|
@@ -49,15 +55,27 @@ DeepSeek Harness 插件:在 Web UI 中直接显示 DeepSeek 账户余额和当
|
|
|
49
55
|
- 节假日与调休安排从国务院公告(公开数据源)自动同步,内置当年表作离线兜底,**无需每年手动维护**;配置界面里能看到上次同步时间,也能手动触发立即同步。
|
|
50
56
|
- 消耗金额**跨时段精确计费**:高峰时段的 token 按高峰价、空闲时段按目录价,按每条消息的**事件时间**分桶计算,不会用「当前时段」笼统估算整个会话。
|
|
51
57
|
|
|
52
|
-
###
|
|
58
|
+
### 会话消耗浮窗
|
|
59
|
+
|
|
60
|
+
对话界面**右下角**一张小卡片,竖排两行:上行 `本会话消耗估算`(11px 说明文字),下行金额(14px),两行居中。没有图标,也不放 `≈`——标签本身就说清了是估算。
|
|
61
|
+
|
|
62
|
+
- **贴着输入框**:底边与输入框底边齐平、留 6px 空隙;右缘贴输入框右缘、留 16px。窗口放大到 4K 全屏时它跟着输入框走,不会被甩到屏幕最右边。
|
|
63
|
+
- **从输入框里升出来**:整页只演一次,之后切对话不再重播。
|
|
64
|
+
- **加载**:一层毛玻璃迷雾盖住金额,数据到手那一刻一道白光从左扫过、数字跟着光显现。**同一会话只演一次**,之后的实时刷新只滚数字、不重播动画。
|
|
65
|
+
- **历史过长时**:加载满 1 秒还没出数,卡片**正上方**浮起一颗「历史过长,稍候」小气泡(淡入 + 从下往上浮 5px),并且至少再留 1 秒才淡出(往下沉 5px)。所以加载 1.05 秒也不会闪一下就没。
|
|
66
|
+
- **数字按位滚动**,只滚变化的数位。
|
|
67
|
+
|
|
68
|
+
**点击**展开明细浮层:Token 用量、缓存命中率、模型、高峰 / 空闲拆分、子代理消耗、网页搜索 / 抓取次数与费用、图片张数与估算 token。
|
|
69
|
+
|
|
70
|
+
### 窗口太窄时
|
|
53
71
|
|
|
54
|
-
|
|
72
|
+
窗口宽度收窄到 **860px** 以下,左下圆钮和右下消耗浮窗会**淡出**(180ms 淡完才真正隐藏)——缩到最小附近时这两张卡都不挡字。拉回 860px 以上自动恢复。
|
|
55
73
|
|
|
56
74
|
### 智能体团队(Agent Teams)
|
|
57
75
|
|
|
58
76
|
会话里开了团队(Lead + teammate)时:
|
|
59
77
|
|
|
60
|
-
-
|
|
78
|
+
- 浮窗里多一颗 `团队 N` 小圆片,说明这颗金额是**本会话 + N 个队友**的合计(队友的钱本来就按子会话算进去了)。
|
|
61
79
|
- 明细浮层多一块「智能体团队」,按人头列出每个队友的 `名字 · 状态` 与 `≈ ¥金额`,右上角是团队合计。
|
|
62
80
|
- 队友干活时 Lead 自己的 token 不变,所以有团队时会每 15 秒补拉一次(页面不可见时跳过),团队金额不会停在旧值。
|
|
63
81
|
- `context: "fork"` 的队友会继承父会话的历史前缀,插件只算 fork 之后产生的事件,不会把父会话的钱重复算一遍。
|
|
@@ -153,7 +171,7 @@ token 数用官方文档站「图片 Token 计算器」的同一套算法估算
|
|
|
153
171
|
- 其他已知误差来源:本地 token 数与官方计费口径可能不同(系统提示、工具调用的内部算法未公开);缓存命中与否按 usage 字段判断,官方口径可能不同;官方调价后需等插件更新价表;模型靠事件里的切换点推断,同名不同版本分不清。
|
|
154
172
|
- 峰值倍率只乘一次:高峰桶乘以倍率,空闲桶原价,网页工具费不参与峰谷倍数。
|
|
155
173
|
- **图片 token 已包含在输入里**,插件不会再为它算一次钱(那会让金额翻倍)。明细里的「图片约 X tok」是各张图本身的体积之和,按官方计算器算法估算;图留在上下文里每轮都会重新计一遍输入,这部分体现在「缓存读取」中。
|
|
156
|
-
- 为避免历史会话过多拖慢 DeepSeek Harness
|
|
174
|
+
- 为避免历史会话过多拖慢 DeepSeek Harness,统计面板默认最多回看最近 **80** 个会话,今日消耗默认扫 **200** 个(今日要宽、历史要快,两个上限分别可调);统计结果缓存 5 分钟,重复打开面板不会重复请求。**这两个上限、以及刷新间隔、各类显示开关,都能在配置界面里改。**
|
|
157
175
|
- 账户余额优先读取 **DeepSeek Harness 官方账号**(登录后即可用,无需 API Key);未登录时回退到 API Key。两者都不可用时仍可查看本地 Token 与费用统计,只是余额会显示为不可用。
|
|
158
176
|
|
|
159
177
|
## 安装
|
|
@@ -214,11 +232,12 @@ dsh plugin --profile desktop add github:Rannist/balance-dsh
|
|
|
214
232
|
|---|---|
|
|
215
233
|
| 版本与更新 | 当前版本、检查更新、就地更新 |
|
|
216
234
|
| 节假日数据 | 同步状态、立即同步 |
|
|
217
|
-
| 余额 |
|
|
218
|
-
| 界面显示 | 侧边栏余额行开关、余额行样式(新版 /
|
|
219
|
-
| 收起态圆钮 |
|
|
220
|
-
| 用量统计 |
|
|
221
|
-
| 计费 |
|
|
235
|
+
| 余额 | 余额刷新间隔、低余额警示阈值、API Key |
|
|
236
|
+
| 界面显示 | 侧边栏余额行开关、余额行样式(新版 / 旧版)、侧边栏入口开关、右键刷新浪潮、会话消耗行开关、消耗行加载动效(样式1 白光擦出 / 样式2 计算中)、(仅旧版)高峰空闲标签开关 |
|
|
237
|
+
| 收起态圆钮 | 显示圆钮、直径、距左缘(同时就是距底边) |
|
|
238
|
+
| 用量统计 | 今日消耗扫描上限、扫描会话数上限、统计缓存时长 |
|
|
239
|
+
| 计费 | 高峰时段(可编辑,格式 `9-12, 14-18`)、高峰时段倍率 |
|
|
240
|
+
| 数据诊断 | 生成诊断报告、修复(查出问题时才出现)、复制 |
|
|
222
241
|
|
|
223
242
|
卡片最顶部是一条固定的范围声明:「计费仅支持 DeepSeek Harness 内的 DeepSeek 官方模型与账号;其他大模型不计入金额。」
|
|
224
243
|
|
package/lib/client.js
CHANGED
|
@@ -171,13 +171,34 @@ window.__ModuleLoader__.load({
|
|
|
171
171
|
padding 0 10px 0 8px、gap 8px、font 14px/22px、color label-primary;
|
|
172
172
|
左缘与设置按钮严格对齐,高度/颜色一致(金额 600 加粗)。
|
|
173
173
|
布局:[meta + 刻度条(竖排,居中)] [金额(最右)] */
|
|
174
|
-
.balance-footer{position:relative;isolation:isolate;box-sizing:border-box;display:flex;align-items:center;justify-content:flex-start;gap:
|
|
174
|
+
.balance-footer{position:relative;isolation:isolate;box-sizing:border-box;display:flex;align-items:center;justify-content:flex-start;gap:6px;flex:1 1 auto;min-width:0;margin:0;height:42px;margin-top:0;margin-bottom:0;margin-right:0;padding:0 0 0 8px;color:var(--dsw-alias-label-primary);font-size:14px;line-height:22px;text-decoration:none;cursor:pointer;white-space:nowrap;overflow:visible;-webkit-user-select:none;user-select:none}
|
|
175
|
+
/* ⚠️ 这里没有 width:100%(2026-11-24,issue #3),用 flex:1 1 auto:吃满可用宽度,但 basis 是
|
|
176
|
+
内容宽,不会像 flex:1 1 100% 那样在 flex-wrap 容器里独占一行(那会把「移动访问」挤到第二行,
|
|
177
|
+
两行各自居中之后看着就是「胶囊偏上」)。
|
|
178
|
+
⚠️ grow 必须保留:classic 的胶囊靠 .balance-footer__value 的 margin-left:auto 推到右缘,
|
|
179
|
+
行本身不占满整宽时 auto 外边距没有空间可推,胶囊就紧贴在「余额」二字后面(用户 2026-11-24:
|
|
180
|
+
「太靠左了」)。 */
|
|
175
181
|
/* 带 meta 行时整块变高:42px 装不下「一行 11px 文字 + 13px 轨道」,改成自适应。 */
|
|
176
182
|
.balance-footer--stacked{height:auto;min-height:42px;padding-top:5px;padding-bottom:5px}
|
|
177
183
|
/* 整行都是热区(单击统计面板 / 双击用量页 / 右键刷新;交互挂在 .balance-stats-anchor、捕获阶段)。
|
|
178
184
|
不给整行画 hover / active 底色——那圈圆角高亮框在侧边栏里太显眼,
|
|
179
185
|
且余白区也被涂上颜色很怪(2026-10-30 反馈「我不要高亮显示」)。
|
|
180
186
|
可点指示只靠右端胶囊自己的 hover 缩放。 */
|
|
187
|
+
/* ── 精简态(同排还有别的入口时自动收缩,2026-11-24)────────────────────────
|
|
188
|
+
侧栏底部那一排由宿主 footerActions 提供,是 display:flex / 不换行 —— 我们改不动它
|
|
189
|
+
(改了就是改宿主容器)。所以放不下时只能**自己变窄**:
|
|
190
|
+
收起图标、「余额」二字、时段标签,只留金额胶囊。
|
|
191
|
+
实测 ¥ 4.63 约 60px,加另一个插件入口(移动访问 ~90px)在 256px 里绰绰有余。
|
|
192
|
+
判定见 useFooterCompact():同排可见入口 > 1 就收缩,恢复成 1 个就展开。 */
|
|
193
|
+
/* ⚠️ 选择器不能带直接子级符号:sep / period-inline 是 value 胶囊的**子节点**,不是行的直接子级。
|
|
194
|
+
只写直接子级会一个都收不起来,金额胶囊仍然那么宽、照样挤。 */
|
|
195
|
+
.balance-footer--compact{flex:0 1 auto;gap:0;padding:0 2px}
|
|
196
|
+
.balance-footer--compact .balance-footer__icon,
|
|
197
|
+
.balance-footer--compact .balance-footer__label,
|
|
198
|
+
.balance-footer--compact .balance-footer__sep,
|
|
199
|
+
.balance-footer--compact .balance-footer__period-inline,
|
|
200
|
+
.balance-footer--compact .balance-footer__spacer{display:none}
|
|
201
|
+
|
|
181
202
|
.balance-footer__spacer{flex:1 1 0;min-width:0}
|
|
182
203
|
/* 右键刷新的「抹除」效果:白条从左划到右,白条**左边**的数字已经"显影"(新值),
|
|
183
204
|
右边仍被一层暗罩压着(旧值)。所以视觉上就是「只有被白条经过的地方才更新」。
|
|
@@ -204,7 +225,17 @@ window.__ModuleLoader__.load({
|
|
|
204
225
|
滚完再收(--roll-done 那条带 160ms 过渡)。宽度变化只发生在没有任何滚动的那一帧之后,
|
|
205
226
|
既不会横向互挤,也不会丢动画。
|
|
206
227
|
影子格保持 from 字符:这一格在滚动期间要维持原来的宽度。 */
|
|
207
|
-
|
|
228
|
+
/* ⚠️ 这条**不能带 animation:none**(2026-11-24 用户:「余额胶囊内如果出现小数的消失或显现时
|
|
229
|
+
动画不要消失」)。--gone 的语义是"这一格新值是空位"——余额 ≥1000 取整后小数位没了、
|
|
230
|
+
或者 999 → 1000 小数点滚走,都属于这种。它该做的事是:滚动期间保持旧字符的宽度、
|
|
231
|
+
照常走 balance-roll-out 把旧字符滚上去,滚完之后由 --roll-done 那条再把宽度收到 0。
|
|
232
|
+
原来这里写了 animation:none,等于把该格的滚动整个跳过 —— 同一个胶囊里其他格子还在滚,
|
|
233
|
+
它却"啪"一下没了,看着就是动画断了一半。
|
|
234
|
+
max-width:2ch 的职责只是**滚完之前不把邻格挤走**(宽度变化必须推迟到滚完之后,
|
|
235
|
+
否则邻格被横向推着走、新旧两串数字会叠住,这是 2026-10-31 的老坑)。
|
|
236
|
+
注意:下面 .balance-footer__timeline-meta-item--today 那条带 --today 前缀的 max-width:0
|
|
237
|
+
是「今日」金额专用的(为了让「今日」二字不要在 600ms 后二次滑动),跟余额胶囊无关,别混。 */
|
|
238
|
+
.balance-footer__dcell--gone{max-width:2ch}
|
|
208
239
|
/* ─── 滚动播完后的「定格态」(2026-10-31 方案 3 补充)─────────────────────────
|
|
209
240
|
为什么需要它:滚动动画不是 JS 触发的,而是 .balance-footer__dout / __din 上
|
|
210
241
|
常驻的 animation 声明。只要这两个节点还在、类名还在、animation 声明还在,
|
|
@@ -218,6 +249,7 @@ window.__ModuleLoader__.load({
|
|
|
218
249
|
(没有 transform = top:0),正好就是关键帧 100% 的位置。 */
|
|
219
250
|
.balance-footer__dcell--roll-done .balance-footer__dout{animation:none;display:none}
|
|
220
251
|
.balance-footer__dcell--roll-done .balance-footer__din{animation:none;transform:none}
|
|
252
|
+
|
|
221
253
|
/* 滚完之后才收宽度(滚动期间由上面的 --gone 保持原宽度)。
|
|
222
254
|
160ms 过渡:此时全串都已经静止,收窄只会让右边的格子整体平移,不存在两串数字互挤。 */
|
|
223
255
|
.balance-footer__dcell--roll-done.balance-footer__dcell--gone{animation:none;max-width:0;transition:max-width .16s linear}
|
|
@@ -504,6 +536,8 @@ window.__ModuleLoader__.load({
|
|
|
504
536
|
.balance-footer__label{flex:none;color:var(--dsw-alias-label-primary)}
|
|
505
537
|
.balance-footer__value{box-sizing:border-box;position:relative;z-index:0;isolation:isolate;display:inline-flex;align-items:center;justify-content:center;font-variant-numeric:tabular-nums;font-weight:500;font-synthesis:none;font-size:16px;line-height:1;white-space:nowrap;padding:7px 14px;border-radius:999px;corner-shape:round;margin-left:auto;margin-right:4px;text-decoration:none;cursor:pointer;transition:transform .15s var(--ds-ease-in-out,.2s),box-shadow .18s var(--ds-ease-in-out,.2s),color .42s var(--ds-ease-in-out,.2s),background .42s var(--ds-ease-in-out,.2s);flex:none;/* 宽度恒定 121px:靠「固定 px + 位数多就缩字号」两条一起实现。
|
|
506
538
|
⚠️ 开头的 box-sizing:border-box 是前提,不能省:min-width 默认算的是「内容盒」,
|
|
539
|
+
|
|
540
|
+
|
|
507
541
|
少了它 121px 会变成 121 + 左右 padding 28px = 149px 总宽,胶囊凭空胖一圈
|
|
508
542
|
(用户反馈「我的余额胶囊为什么这么长」,真实客户端实测正是 149px)。DSH 页面上
|
|
509
543
|
没有全局 border-box,刻度条 / 去充值 / FAB 都各自显式写了,只有这一处漏过。
|
|
@@ -517,6 +551,66 @@ window.__ModuleLoader__.load({
|
|
|
517
551
|
宽度照样跳。也别按「¥14.34 • 空闲」这种臆想格式去量 —— timeline 胶囊里只有
|
|
518
552
|
金额+货币码,先前按假格式算出 6.6em 恰好等于 0.00 CNY 的天然宽度,对任何值都不生效(踩过)。
|
|
519
553
|
justify-content:flex-end 让内容靠右,位数少时留白落在左边。 */min-width:112px}
|
|
554
|
+
/* ── 精简态 + timeline 形态:改成竖排,时段条挪到金额下方(2026-11-24 用户要求)──────
|
|
555
|
+
不收缩宽度的话 timeline 那块(今日 / 空闲 / 刻度条 竖排成一列)会把金额挤出去被裁
|
|
556
|
+
(用户截图:左边「今日 ¥0.7 / 空闲 剩」被裁掉一半)。
|
|
557
|
+
收缩宽度又会把「今日」「空闲」裁字,所以改成上下排:金额一行,那段时段信息整体落到下面。
|
|
558
|
+
不用拆 periodNode —— 它(.balance-footer__timeline)本来就是 meta + 刻度条 的竖排容器,
|
|
559
|
+
整块 order 到金额后面即可。行高由 --stacked 的 height:auto 自适应。
|
|
560
|
+
⚠️ 选择器末尾留一个空格(.balance-footer__timeline {):selftest 的 cssRule() 用
|
|
561
|
+
indexOf(sel + "{") 做子串匹配,紧贴会把它顶成第一条、抢掉基础规则,一串断言跟着红。 */
|
|
562
|
+
/* ── 精简竖排 = 原版的等比缩小(2026-11-24 用户:「就跟原版一样 等比例缩小」)──────
|
|
563
|
+
比例 0.8,每一项都按同一个系数走,形状和各元素之间的比例关系与原版一致:
|
|
564
|
+
胶囊 字号 16→13 内边距 7/14 → 6/11 最小宽 112→90 圆角 999px 不变
|
|
565
|
+
meta 行 字号 11→9 间距 6→5
|
|
566
|
+
时段条 高 15→12 宽 = 可用宽 × 0.8(跟着侧栏缩放,宽屏下不会拉成一根横线)
|
|
567
|
+
块间距 4→3
|
|
568
|
+
要整体再大/再小,只改这五组数、保持同一系数即可,别单独调某一项(那就不等比了)。 */
|
|
569
|
+
/* 两列:**左边**今日消耗 + 时段剩余(含刻度条),**右边**余额胶囊(用户 2026-11-24:
|
|
570
|
+
「左边显示今日消耗和时段剩余 右边显示余额胶囊」)。
|
|
571
|
+
所以回到 row,左侧 .balance-footer__timeline 吃满剩余宽(flex:1 1 auto + min-width:0),
|
|
572
|
+
胶囊固定按内容宽(flex:0 0 auto)贴在右端。
|
|
573
|
+
⚠️ .balance-footer__timeline 的 align-items 必须显式写 flex-start —— 基础规则是 center,
|
|
574
|
+
只在外层写 align-self 管不到它内部,meta 和刻度条会各自居中、跟左侧边缘错开。 */
|
|
575
|
+
.balance-footer--compact.balance-footer--stacked{flex:1 1 100%;flex-direction:row;align-items:center;justify-content:space-between;gap:6px;padding:2px 0}
|
|
576
|
+
/* 胶囊再收一档,把宽度让给左边(用户 2026-11-24:「胶囊再小一点点就行 现在就是时段表的 m
|
|
577
|
+
显示不全」——左侧 .balance-footer__timeline 是 flex:1 1 auto,右边胶囊越宽它就压得越窄,
|
|
578
|
+
「空闲 剩 11h40m」的尾巴就被裁掉了)。
|
|
579
|
+
90→76 / 6-11→5-9 / 13→12 大约省 18px,正好够那个 m。
|
|
580
|
+
⚠️ 别再往下压字号:12px 是这套 0.8 比例里的可见下限,再小数字会糊。 */
|
|
581
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__value {order:2;flex:0 0 auto;min-width:76px;margin-left:0;margin-right:0;padding:5px 9px;font-size:12px;align-self:center}
|
|
582
|
+
/* ⚠️ 位数降档必须跟着进来(2026-11-24「现在这个胶囊能显示到万单位的吗」)。
|
|
583
|
+
基础规则按整数位数给胶囊挂 --dense / --dense2 来收宽度,但那两条只有 1 个类,
|
|
584
|
+
压不过上面那条 5 个类的 compact 规则 —— 不补的话「位数多就缩字号」在这层整个失效,
|
|
585
|
+
金额一大就把胶囊撑宽、反过来挤压左侧时段文字。补上后每一档都比基础版小 0.5px。 */
|
|
586
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__value--dense {font-size:11.5px}
|
|
587
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__value--dense2 {font-size:10.5px}/* ⚠️ 这里必须是**居中**(2026-11-24 用户第二轮定案:「今日的移动确实需要滑动效果,
|
|
588
|
+
因为今日消耗的宽度 但刚刚是bug 有异常的滑动」)。
|
|
589
|
+
滑动本身的语义没错:今日金额从 ¥2.07 变 ¥123.45 时整块居中重排,「今日」二字要被平滑推开,
|
|
590
|
+
靠的是下面 usePrePaintEffect 那 460ms 的 translateX。所以对齐必须是 center ——
|
|
591
|
+
改成 flex-start 之后金额再怎么变「今日」都钉死在缩进点,滑动就没了。
|
|
592
|
+
上一版之所以出现"异常滑动",根因是 --today 被改成了 flex:0 1 auto(和「空闲 剩」同一行):
|
|
593
|
+
那样 meta 宽度会跟着「空闲 剩 11h33m」的字数一起变,居中重排时「今日」的 left 也跟着漂,
|
|
594
|
+
而 effect 只在 todayText 变化时才跑、prev 记的位置早已过期 → 下次一跑 shift 巨大 → 猛滑一下。
|
|
595
|
+
现在恢复 --today 独占一整行(flex:0 0 100%),它的 left 只由「自己这一行居中 + 金额宽度」
|
|
596
|
+
决定,「空闲 剩」的字数变化只影响下一行、推不动它 —— 真滑动保留,假滑动消失。 */
|
|
597
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__timeline {order:1;flex:1 1 auto;min-width:0;align-self:center;align-items:center;gap:3px}
|
|
598
|
+
/* 「今日」独占一整行、内部居中 —— 这是滑动效果的前提(left 只由自己的金额宽度决定)。
|
|
599
|
+
曾经收成 flex:0 1 auto 让它和「空闲 剩」同行,结果 meta 宽度跟着「空闲」的字数变,
|
|
600
|
+
居中重排把「今日」也带着漂,才出现"不该滑的时候滑"。别再收。 */
|
|
601
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__timeline-meta-item--today {flex:0 0 100%;justify-content:center;text-align:center}
|
|
602
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__timeline-meta {
|
|
603
|
+
justify-content:center;
|
|
604
|
+
/* 两行之间用 row-gap,别再用一条 gap 同时管两个方向:
|
|
605
|
+
写 gap:5px 时 row-gap 也被抬到 5px,比下面「空闲 → 色带」那 3px 还松,
|
|
606
|
+
9px 字号下等于半个行高,看着就是一块空档(2026-11-24 用户对着截图问
|
|
607
|
+
「是不是空隙有点大了」)。实测「今日↔空闲」5.00px、「空闲↔色带」3.00px。
|
|
608
|
+
现在行距对齐成 3px,和色带那一档一致。 */
|
|
609
|
+
column-gap:5px;
|
|
610
|
+
row-gap:3px;
|
|
611
|
+
font-size:9px;
|
|
612
|
+
text-align:center}
|
|
613
|
+
.balance-footer--compact.balance-footer--stacked .balance-footer__timeline-track {height:12px;width:100%;max-width:110px;margin-left:auto;margin-right:auto}
|
|
520
614
|
/* 余额位数多时降档,配合上面的固定宽度,让长金额也收在 121px 内 */
|
|
521
615
|
.balance-footer__value--dense{font-size:13px}
|
|
522
616
|
.balance-footer__value--dense2{font-size:11.5px}
|
|
@@ -544,7 +638,15 @@ window.__ModuleLoader__.load({
|
|
|
544
638
|
.balance-footer__value--low:hover{background:rgba(217,119,6,.22)}
|
|
545
639
|
/* 旧版布局:胶囊靠右 —— 这是备份 v1.3.1 里的原始写法(margin-left:auto)。
|
|
546
640
|
不能放到基础规则上,新版 timeline 用 margin:0 auto 居中,会和它打架。 */
|
|
547
|
-
|
|
641
|
+
/* 旧版样式的胶囊比旁边「移动访问」的文字基线高 1~2px(用户 2026-11-24 两次反馈「有点偏上」
|
|
642
|
+
→「还是有一点」→「怎么感觉还是偏上」)。那个按钮是 dsh-mobile 的,尺寸与内边距不归我们管,只能在自己的行上补。
|
|
643
|
+
⚠️ 这是按截图目测的补偿值,不是布局修正:真正的垂直基准由 footerActions 的 align-items:center
|
|
644
|
+
决定,两边都居中了,差的是「胶囊有背景块、按钮只有文字」带来的视觉基线错觉。 */
|
|
645
|
+
.balance-footer--classic{top:4px}
|
|
646
|
+
/* 胶囊不要贴死右端,往左挪一点(用户 2026-11-24:「能不能往左边的中间一点」)。
|
|
647
|
+
margin-left:auto 负责把它从「余额」二字后面推到右边,margin-right 再从右端让出一段,
|
|
648
|
+
落点就在右侧偏左的位置。这个数值就是让出的距离,想再靠左就加大、想贴回去就写 0。 */
|
|
649
|
+
.balance-footer--classic .balance-footer__value{margin-left:auto;margin-right:14px}
|
|
548
650
|
.balance-footer__value--healthy{color:var(--dsw-alias-state-success-primary);background:rgba(34,197,94,.15)}
|
|
549
651
|
/* 余额耗尽时只把金额胶囊换成充值按钮(2026-11-13 用户:「余额用完 只替换余额处为充值按钮」)。
|
|
550
652
|
盒子完全沿用 .balance-footer__value(min-width / padding / 圆角 / 居中),只换配色与文字,
|
|
@@ -1035,6 +1137,27 @@ window.__ModuleLoader__.load({
|
|
|
1035
1137
|
dghost + dout + din 三件套的滚格子),只要它们量出来差 1px,卡片就长高 1px、上移 1px。
|
|
1036
1138
|
钉死这一行之后,里面换成什么都不会影响卡片总高(多出来的部分被行高裁掉/居中吸收)。 */
|
|
1037
1139
|
.balance-float__value-row{display:inline-flex;align-items:center;justify-content:center;gap:6px;min-width:0;height:1lh;transition:opacity .2s linear}
|
|
1140
|
+
/* 慢加载提示 —— **独立的一颗小气泡**,贴在主卡片正上方(2026-11-24 用户:
|
|
1141
|
+
「可以单独显示一个小浮窗」)。
|
|
1142
|
+
为什么不塞进卡片:卡片是 bottom 钉在输入卡片底边上的,内部多一行会让它整体长高、
|
|
1143
|
+
上面两行跟着上跳;而且那是"内容变多",不是"另给一个提示"。
|
|
1144
|
+
放在正上方而不是下方 —— 下方就是输入框,压上去比往上飘更难受。
|
|
1145
|
+
定位靠 .balance-float 自己(position:fixed 即包含块)的 bottom:100% + 6px,
|
|
1146
|
+
完全跟随主卡片的移动,不需要再算一遍坐标。
|
|
1147
|
+
⚠️ 外层铺满卡片宽度只为了居中,真正的胶囊在内层 <b> 上(宽度按文字自适应,
|
|
1148
|
+
提示才 73.5px,比卡片窄,看着才像"另一个小浮窗")。
|
|
1149
|
+
⚠️ 绝不用 transform 做居中/位移:小字号走 GPU 纹理会发虚(2026-10-31 的教训)。 */
|
|
1150
|
+
/* 进出场:淡入 + 从下往上浮 5px(消失时反向沉下去)。
|
|
1151
|
+
2026-11-24 用户:「提示消失没有动画了 并且添加消失和显现来明示用户」。
|
|
1152
|
+
⚠️ 消失本来是有过渡的,坏在文字被一起清空了 —— opacity 刚开始降、字已经没了,
|
|
1153
|
+
看着就是硬切。所以文字必须**常驻**,只靠这个类开关透明度。
|
|
1154
|
+
⚠️ 静止态刻意写 transform:none 而不是 translateY(0):translateY(0) 也算 transform,
|
|
1155
|
+
会让这块独立成合成层,10.5px 中文在 GPU 纹理里会发虚(2026-10-31 的老坑)。
|
|
1156
|
+
none ↔ translateY 之间浏览器按 identity 插值,过渡照样成立。
|
|
1157
|
+
⚠️ 水平居中靠 flex(justify-content:center),不许用 translateX 硬拽。 */
|
|
1158
|
+
.balance-float__slow-tip{position:absolute;bottom:100%;left:0;right:0;margin-bottom:6px;display:flex;justify-content:center;opacity:0;transform:translateY(5px);pointer-events:none;transition:opacity .2s ease,transform .24s cubic-bezier(.22,.72,.28,1)}
|
|
1159
|
+
.balance-float--slow .balance-float__slow-tip{opacity:1;transform:none}
|
|
1160
|
+
.balance-float__slow-tip>b{display:block;padding:3px 9px;border-radius:999px;font-size:10.5px;line-height:13px;font-weight:400;color:var(--dsw-alias-label-tertiary);white-space:nowrap;background:var(--dsw-specific-sidebar-fill,rgba(27,27,28,.92));box-shadow:0 4px 12px rgba(0,0,0,.34),inset 0 0 0 1px rgba(255,255,255,.05)}
|
|
1038
1161
|
/* 金额那一格:预留 **9ch** 兜住等待态那颗加载胶囊(2026-11-02 用户:「是不是可以让加载胶囊长一点了」)。
|
|
1039
1162
|
实测 14px 字下 1ch ≈ 8.21px → 6.4ch 只有 52.5px,在 101px 宽的卡片里显得又短又胖;
|
|
1040
1163
|
9ch ≈ 73.9px,正好和上面那行「本会话消耗估算」(77px)等宽对齐 ——
|
|
@@ -1374,7 +1497,26 @@ window.__ModuleLoader__.load({
|
|
|
1374
1497
|
.balance-stats-close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:28px;height:28px;border:0;border-radius:8px;color:var(--dsw-alias-label-secondary);background:transparent;font-size:22px;line-height:1;cursor:pointer}
|
|
1375
1498
|
.balance-stats-close:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
|
|
1376
1499
|
.balance-stats-error{padding:12px;border-radius:10px;color:var(--dsw-alias-state-error-primary,#e5484d);background:rgba(229,72,77,.10)}
|
|
1377
|
-
|
|
1500
|
+
/* 加载态:一条**实时推进**的进度条 + 已用时(2026-11-24 用户:「加载时添加一个实时的加载条」)。
|
|
1501
|
+
统计面板打开时要扫上百个会话的 zstd,几秒内只有一行「正在汇总会话记录…」,没有任何
|
|
1502
|
+
"还在动"的证据 —— 用户分不清是卡住还是真在算。这里两层反馈:
|
|
1503
|
+
① 轨道上一条**不确定态**的跑马灯(服务端一次请求返回、拿不到百分比,所以不能用真实进度);
|
|
1504
|
+
用两段亮块交错推进,比单块更有"在持续干活"的观感。
|
|
1505
|
+
② 下方按秒累加的耗时数字,只要它还在涨,就说明这一拍没死。
|
|
1506
|
+
动画跟其它动效一样**不受 prefers-reduced-motion 影响**(它是可读状态而不是装饰),
|
|
1507
|
+
但幅度压得很小(横向平移 + 透明度),不会有明显闪烁。 */
|
|
1508
|
+
/* 圆形转圈(2026-11-24 用户:「说错了 是进度条 可以用圆形的」)。
|
|
1509
|
+
底环是暗的完整圆,上面一段亮弧自己转,同时弧长从 20 → 62 → 20 呼吸,
|
|
1510
|
+
看起来是"一圈在跑"而不是"一个缺口在转"。
|
|
1511
|
+
r = 13 ⇒ 周长 2πr ≈ 81.68,stroke-dasharray 用 20 62 正好把整圈铺满。 */
|
|
1512
|
+
.balance-stats-progress{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 12px 44px;color:var(--dsw-alias-label-secondary)}
|
|
1513
|
+
.balance-stats-spinner{display:block;width:30px;height:30px;animation:balance-stats-spin .95s linear infinite}
|
|
1514
|
+
.balance-stats-spinner__track{fill:none;stroke:var(--dsw-alias-border-l2,rgba(127,127,127,.22));stroke-width:2.5}
|
|
1515
|
+
.balance-stats-spinner__arc{fill:none;stroke:#4d6bfe;stroke-width:2.5;stroke-linecap:round;animation:balance-stats-arc 1.9s ease-in-out infinite}
|
|
1516
|
+
@keyframes balance-stats-spin{to{transform:rotate(360deg)}}
|
|
1517
|
+
@keyframes balance-stats-arc{0%{stroke-dasharray:20 62}50%{stroke-dasharray:62 20}100%{stroke-dasharray:20 62}}
|
|
1518
|
+
.balance-stats-progress__text{font-size:12px;line-height:1;font-variant-numeric:tabular-nums}
|
|
1519
|
+
.balance-stats-progress__elapsed{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary));font-size:11px;line-height:1}
|
|
1378
1520
|
.balance-stats-top{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-bottom:8px}
|
|
1379
1521
|
.balance-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:8px}
|
|
1380
1522
|
/* 分组数为奇数时(「按模型」「时段拆分」条件渲染可能缺席),最后一个横跨整行,避免半空行 */
|
|
@@ -1428,13 +1570,21 @@ window.__ModuleLoader__.load({
|
|
|
1428
1570
|
/* ── 展开态底部一行:[设置齿轮][余额胶囊],余额在设置右边 ──
|
|
1429
1571
|
全部使用稳定锚点,不依赖 CSS Modules hash 类名(DSH 升级后仍有效):
|
|
1430
1572
|
- wide 态特征:底部存在 .balance-footer / .balance-topup(收起态渲染 position:fixed 的 .balance-fab,不影响)
|
|
1431
|
-
- footArea 改 row
|
|
1432
|
-
- [data-slot] = slot 出口契约(display:contents)
|
|
1573
|
+
- footArea 改 row(宿主默认是 column,上下两行);footerActions 按内容宽靠右排列
|
|
1574
|
+
- [data-slot] = slot 出口契约(display:contents)
|
|
1575
|
+
⚠️ 2026-11-24(issue #3):**绝不许再改宿主自己的控件**。
|
|
1576
|
+
这里只改 footArea 的排列方向这一条容器属性 —— 不改 sidebar.settings 的 order、
|
|
1577
|
+
尺寸、圆角,也不隐藏它的文字。老实现那三条(order:-1 / 32×32 圆形 / span 隐藏)
|
|
1578
|
+
对**所有**装了本插件的用户生效,是明确的反模式;入口排不下的问题改由
|
|
1579
|
+
排不下的问题交给 footerActions 的 flex-wrap + .balance-footer 的 flex:1 1 100%:
|
|
1580
|
+
自己占满一整行,别的入口被挤到下一行,两边都不裁字。 */
|
|
1433
1581
|
:has(> :has(> [data-slot="sidebar.footer.action"])):has(.balance-footer, .balance-topup){flex-direction:row;align-items:center;gap:4px}
|
|
1434
|
-
:has(> :has(> [data-slot="sidebar.footer.action"])):has(.balance-footer, .balance-topup) > :has(> [data-slot="sidebar.footer.action"]){flex:1 1
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1582
|
+
:has(> :has(> [data-slot="sidebar.footer.action"])):has(.balance-footer, .balance-topup) > :has(> [data-slot="sidebar.footer.action"]){order:1;flex:1 1 auto;min-width:0;display:flex;flex-direction:row;flex-wrap:wrap;justify-content:flex-end;align-items:center;gap:4px}
|
|
1583
|
+
/* settingsArea 宿主自带 flex:none + width:100%(那是 column 布局下的写法)。footArea 改成 row 之后
|
|
1584
|
+
它会独占整行、把 footerActions 挤成 0,所以这里必须把它收成「按内容宽」。
|
|
1585
|
+
⚠️ 只动**容器**的伸缩与宽度,按钮的尺寸 / 圆角 / 是否显示文字一律不碰(issue #3 的核心诉求)。
|
|
1586
|
+
顺序由上面 footerActions 的 order:1 解决:设置区默认 order 0 排在前,余额落在它的右边。 */
|
|
1587
|
+
:has(> :has(> [data-slot="sidebar.footer.action"])):has(.balance-footer, .balance-topup) > :has(> [data-slot="sidebar.settings"]){flex:0 0 auto;width:auto;min-width:0}
|
|
1438
1588
|
/* ── 插件配置卡片:DSH「插件」页 → balance-dsh 详情页(slot plugins.bundle.config) ──
|
|
1439
1589
|
用插件自己的稳定类名(不依赖 DSH 的 CSS Modules hash);主题变量一律带回退值,
|
|
1440
1590
|
变量缺失时仍然可读,不会变成透明文字。开关/按钮的真圆角要显式 corner-shape:round,
|
|
@@ -2382,6 +2532,14 @@ let floatRemeasureHook = null;
|
|
|
2382
2532
|
* ⚠️ 只按「会话切换」起算,流式刷新绝不重播(那样很割裂,2026-10-31 定过)。
|
|
2383
2533
|
* 300ms 是下限不是固定等待:请求更慢时雾跟着更久,跟以前一样。 */
|
|
2384
2534
|
const COST_FOG_FLOOR_MS = 420;
|
|
2535
|
+
/** 「加载超过 1 秒就给个说法」(2026-11-24 用户:「当对话估算加载超过1秒 就在下方显示
|
|
2536
|
+
* 提示对话历史过长需要时间 给用户」)。大会话冷启动要解压几十 MB 的 zstd,
|
|
2537
|
+
* 光看那团雾分不出「还在算」和「卡住了」。1 秒以下不打扰 —— 正常会话都在这个区间。 */
|
|
2538
|
+
const COST_SLOW_HINT_MS = 1000;
|
|
2539
|
+
/** 气泡一旦亮起,**至少留这么久**才允许收(2026-11-24 用户:「有的对话可能刚好1秒多一点
|
|
2540
|
+
* 导致提示就闪了一下 所以添加提示显示保底1秒」)。1.05 秒的加载会让气泡只存在 50ms,
|
|
2541
|
+
* 加上 200ms 的淡出还没走完就没了,看着像闪了一下故障。 */
|
|
2542
|
+
const COST_SLOW_HINT_MIN_MS = 1000;
|
|
2385
2543
|
// 滚动播完后给 roll 打 done 标记(2026-10-31 方案 3 补充)。
|
|
2386
2544
|
// 为什么必须做:`dout`/`din` 上的 animation 是常驻声明,只要它还在,
|
|
2387
2545
|
// 元素经历 display:none → 有盒子时浏览器会取消并重建动画,从 0 秒重播。
|
|
@@ -2883,6 +3041,31 @@ const CN_CALENDAR_SOURCES = [
|
|
|
2883
3041
|
if (intPart.length >= 3) return " balance-footer__value--dense";
|
|
2884
3042
|
return "";
|
|
2885
3043
|
}
|
|
3044
|
+
// 余额的**显示**文本(2026-11-24 用户:「当余额超过 1000 时 就不要显示小数了」)。
|
|
3045
|
+
// ≥1000 取整、<1000 保持服务端给的两们小数。只影响显示:计费、阈值判断、
|
|
3046
|
+
// 低余额告警一律仍用原始 total_balance,所以 999.99 → 1000 那一刻不会因为四舍五入
|
|
3047
|
+
// 反过来影响「是否低于阈值」的判定。
|
|
3048
|
+
// 顺便让 `amountDensity` 吃的是取整后的串 —— 位数变少,降档也跟着更准。
|
|
3049
|
+
function formatTotalDisplay(raw) {
|
|
3050
|
+
const text = String(raw ?? "");
|
|
3051
|
+
const n = Number.parseFloat(text);
|
|
3052
|
+
if (Number.isFinite(n) && Math.abs(n) >= 1000) return String(Math.round(n));
|
|
3053
|
+
return text;
|
|
3054
|
+
}
|
|
3055
|
+
// ⚠️⚠️ **临时预览值**(2026-11-24 用户「帮我给余额先暂时改成 99999 给我看一下」)。
|
|
3056
|
+
// 测完把 return 那句改回 `return null;`。返回值是 null 时一切走真实余额,零影响。
|
|
3057
|
+
// 提成模块级函数是因为「滚动 effect」也要看到它:预览值从 3 位跳到 5 位时,
|
|
3058
|
+
// 逐位滚动会把旧值和新值叠在同一格上(buildRollCells 已按位数补齐,但动画没跑完时两串都在),
|
|
3059
|
+
// 屏幕上就是 `99999.00CNY` 和 `12.98CNY` 糊成一坨 —— 预览只为了量宽度,不要动画。
|
|
3060
|
+
function balancePreviewValue() {
|
|
3061
|
+
try {
|
|
3062
|
+
const q = new URLSearchParams(window.location.search).get("mock");
|
|
3063
|
+
if (q !== null && /^\d+(?:\.\d+)?$/.test(q)) return Number(q).toFixed(2);
|
|
3064
|
+
} catch {
|
|
3065
|
+
/* 拿不到 location 就落到下面的默认值 */
|
|
3066
|
+
}
|
|
3067
|
+
return null;
|
|
3068
|
+
}
|
|
2886
3069
|
// ─── 时段刻度条:色带固定 = 一整天,指针随时刻从左走到右 ────────────────
|
|
2887
3070
|
// 轨道铺满当天 00:00 → 次日 00:00 的时段色带(不滚动),指针位置 = 现在时刻在当天的比例。
|
|
2888
3071
|
// 指针每秒前进一次(pointerNow 独立节拍),CSS transition:left 1s linear 补成连续滑动;
|
|
@@ -4000,12 +4183,30 @@ const CN_CALENDAR_SOURCES = [
|
|
|
4000
4183
|
function UsageStatsPanel({ onClose, panelRef, closing }) {
|
|
4001
4184
|
const liveBalance = useBalance();
|
|
4002
4185
|
const [heatmapTooltip, setHeatmapTooltip] = react.useState(null);
|
|
4186
|
+
// 加载进度条的「已用 X.Xs」—— 服务端一次返回、给不出百分比,但一个还在涨的数字
|
|
4187
|
+
// 就是"它没卡住"的直接证据(用户 2026-11-24:「加载时添加一个实时的加载条」)。
|
|
4188
|
+
const [statsElapsedMs, setStatsElapsedMs] = react.useState(0);
|
|
4003
4189
|
const [state, setState] = react.useState(() => {
|
|
4004
4190
|
const cached = getCachedUsageStats();
|
|
4005
4191
|
return cached
|
|
4006
4192
|
? { loading: false, data: cached, error: "" }
|
|
4007
4193
|
: { loading: true, data: null, error: "" };
|
|
4008
4194
|
});
|
|
4195
|
+
const statsLoading = state.loading;
|
|
4196
|
+
react.useEffect(() => {
|
|
4197
|
+
if (!statsLoading) return undefined;
|
|
4198
|
+
const startedAt = Date.now();
|
|
4199
|
+
setStatsElapsedMs(0);
|
|
4200
|
+
// 100ms 一拍:数字"在跳"的感觉比每秒一次明显,代价可忽略(只是 setState 一个数值)。
|
|
4201
|
+
// 用 setTimeout 递归而不是 rAF —— DSH 渲染进程里 rAF 会被窗口可见性挂起。
|
|
4202
|
+
let timer = 0;
|
|
4203
|
+
const tick = () => {
|
|
4204
|
+
setStatsElapsedMs(Date.now() - startedAt);
|
|
4205
|
+
timer = setTimeout(tick, 100);
|
|
4206
|
+
};
|
|
4207
|
+
timer = setTimeout(tick, 100);
|
|
4208
|
+
return () => clearTimeout(timer);
|
|
4209
|
+
}, [statsLoading]);
|
|
4009
4210
|
react.useEffect(() => {
|
|
4010
4211
|
let disposed = false;
|
|
4011
4212
|
fetchUsageStats().then(
|
|
@@ -4139,7 +4340,25 @@ const CN_CALENDAR_SOURCES = [
|
|
|
4139
4340
|
const rangeDays = Number(stats && stats.rangeDays) || 90;
|
|
4140
4341
|
|
|
4141
4342
|
const body = state.loading
|
|
4142
|
-
? jsx.
|
|
4343
|
+
? jsx.jsxs("div", {
|
|
4344
|
+
className: "balance-stats-progress",
|
|
4345
|
+
children: [
|
|
4346
|
+
// 圆形转圈:底环 + 亮弧,亮弧自己转、弧长呼吸(见 CSS 那两条 keyframes)
|
|
4347
|
+
jsx.jsx("svg", {
|
|
4348
|
+
className: "balance-stats-spinner",
|
|
4349
|
+
viewBox: "0 0 32 32",
|
|
4350
|
+
"aria-hidden": "true",
|
|
4351
|
+
children: [
|
|
4352
|
+
jsx.jsx("circle", { className: "balance-stats-spinner__track", cx: 16, cy: 16, r: 13 }),
|
|
4353
|
+
jsx.jsx("circle", { className: "balance-stats-spinner__arc", cx: 16, cy: 16, r: 13 }),
|
|
4354
|
+
],
|
|
4355
|
+
}),
|
|
4356
|
+
jsx.jsx("div", { className: "balance-stats-progress__text", children: "正在汇总会话记录…" }),
|
|
4357
|
+
statsElapsedMs > 0
|
|
4358
|
+
? jsx.jsx("div", { className: "balance-stats-progress__elapsed", children: "已用 " + (statsElapsedMs / 1000).toFixed(1) + "s" })
|
|
4359
|
+
: null,
|
|
4360
|
+
],
|
|
4361
|
+
})
|
|
4143
4362
|
: state.error
|
|
4144
4363
|
? jsx.jsx("div", { className: "balance-stats-error", children: state.error })
|
|
4145
4364
|
: jsx.jsxs(jsx.Fragment, {
|
|
@@ -4570,7 +4789,87 @@ function makeTodayFlowStyle() {
|
|
|
4570
4789
|
};
|
|
4571
4790
|
}
|
|
4572
4791
|
|
|
4792
|
+
// ── 侧栏底部同排入口数(2026-11-24)────────────────────────────────────────
|
|
4793
|
+
//
|
|
4794
|
+
// 宿主把那一条放在 footerActions 里(display:flex、row、不换行)。我们只读、不改它:
|
|
4795
|
+
// 数一下同一排有几个可见入口,超过 1 个就把自己收缩成「只留金额」的精简态。
|
|
4796
|
+
//
|
|
4797
|
+
// ⚠️ 测量纪律(AGENTS 记过一整版的坑):
|
|
4798
|
+
// [data-slot="sidebar.footer.action"] 是 SlotOutlet 的出口容器,display:contents
|
|
4799
|
+
// —— 不生成盒子,getBoundingClientRect() 全 0。所以数的是它的**子元素**(真元素),
|
|
4800
|
+
// 而且每个注册项各有一个 outlet,必须遍历 row 下**所有** outlet 才数得全
|
|
4801
|
+
// (只 querySelector 一个会漏掉 dsh-mobile 的「移动访问」)。
|
|
4802
|
+
function measureFooterCrowd() {
|
|
4803
|
+
try {
|
|
4804
|
+
if (typeof document === "undefined") return 1;
|
|
4805
|
+
const outlet = document.querySelector('[data-slot="sidebar.footer.action"]');
|
|
4806
|
+
const row = outlet?.parentElement ?? null;
|
|
4807
|
+
if (row === null) return 1;
|
|
4808
|
+
const shown = (n) => n !== null && n !== void 0
|
|
4809
|
+
&& typeof n.getClientRects === "function" && n.getClientRects().length > 0;
|
|
4810
|
+
let count = 0;
|
|
4811
|
+
for (const node of Array.from(row.children)) {
|
|
4812
|
+
if (node?.getAttribute?.("data-slot") === "sidebar.footer.action") {
|
|
4813
|
+
for (const inner of Array.from(node.children)) if (shown(inner)) count += 1;
|
|
4814
|
+
} else if (shown(node)) {
|
|
4815
|
+
count += 1;
|
|
4816
|
+
}
|
|
4817
|
+
}
|
|
4818
|
+
return count;
|
|
4819
|
+
} catch {
|
|
4820
|
+
return 1;
|
|
4821
|
+
}
|
|
4822
|
+
}
|
|
4823
|
+
/** 同排是否还有别的入口(有就收缩成只留金额)。 */
|
|
4824
|
+
function useFooterCompact() {
|
|
4825
|
+
const [crowded, setCrowded] = react.useState(false);
|
|
4826
|
+
react.useEffect(() => {
|
|
4827
|
+
let disposed = false;
|
|
4828
|
+
const sync = () => {
|
|
4829
|
+
if (disposed) return;
|
|
4830
|
+
const next = measureFooterCrowd() > 1;
|
|
4831
|
+
setCrowded((prev) => (prev === next ? prev : next));
|
|
4832
|
+
};
|
|
4833
|
+
sync();
|
|
4834
|
+
const onResize = () => sync();
|
|
4835
|
+
if (typeof window !== "undefined") window.addEventListener("resize", onResize);
|
|
4836
|
+
let ro = null;
|
|
4837
|
+
let mo = null;
|
|
4838
|
+
try {
|
|
4839
|
+
const outlet = document.querySelector('[data-slot="sidebar.footer.action"]');
|
|
4840
|
+
const row = outlet?.parentElement ?? null;
|
|
4841
|
+
const footArea = row?.parentElement ?? null;
|
|
4842
|
+
if (typeof ResizeObserver === "function") {
|
|
4843
|
+
ro = new ResizeObserver(sync);
|
|
4844
|
+
if (footArea !== null) ro.observe(footArea);
|
|
4845
|
+
if (row !== null) ro.observe(row);
|
|
4846
|
+
}
|
|
4847
|
+
// 别的插件挂载/卸载发生在**别的** outlet 上,所以要盯整棵子树
|
|
4848
|
+
if (typeof MutationObserver === "function" && row !== null) {
|
|
4849
|
+
mo = new MutationObserver(sync);
|
|
4850
|
+
mo.observe(row, { childList: true, subtree: true });
|
|
4851
|
+
}
|
|
4852
|
+
} catch {
|
|
4853
|
+
// 观察器不可用就只靠 resize
|
|
4854
|
+
}
|
|
4855
|
+
const t1 = setTimeout(sync, 60);
|
|
4856
|
+
const t2 = setTimeout(sync, 260);
|
|
4857
|
+
return () => {
|
|
4858
|
+
disposed = true;
|
|
4859
|
+
clearTimeout(t1);
|
|
4860
|
+
clearTimeout(t2);
|
|
4861
|
+
if (typeof window !== "undefined") window.removeEventListener("resize", onResize);
|
|
4862
|
+
if (ro !== null) ro.disconnect();
|
|
4863
|
+
if (mo !== null) mo.disconnect();
|
|
4864
|
+
};
|
|
4865
|
+
}, []);
|
|
4866
|
+
return crowded;
|
|
4867
|
+
}
|
|
4868
|
+
|
|
4573
4869
|
function BalanceFooter({ wide }) {
|
|
4870
|
+
// 同排还有别的入口时收缩成「只留金额」(见 useFooterCompact 那段注释)
|
|
4871
|
+
const crowded = useFooterCompact();
|
|
4872
|
+
const crowdClass = crowded ? ' balance-footer--compact' : '';
|
|
4574
4873
|
const state = useBalance();
|
|
4575
4874
|
const settings = useSettings();
|
|
4576
4875
|
const today = useToday();
|
|
@@ -4828,6 +5127,15 @@ function makeTodayFlowStyle() {
|
|
|
4828
5127
|
// 「手动更新时擦除样式的 然后滚动就不要了 分清楚了」)。
|
|
4829
5128
|
// 这条判据精确到请求,不再有"时间窗猜错"的可能。
|
|
4830
5129
|
const manual = state.manual === true;
|
|
5130
|
+
// ⚠️ 预览值生效时**一律不滚**,直接把 roll 定成静态(2026-11-24)。
|
|
5131
|
+
// 预览是从真实余额一步跳到 99999.00,整数位从 2 位变 5 位:buildRollCells 会把旧值
|
|
5132
|
+
// 左侧补空位对齐,可动画只有 420ms,两串数字在中途同框;预览页刷新频率高、动画还没走完
|
|
5133
|
+
// 就重渲染,屏幕上就成了 `99999.00CNY` 压着 `12.98CNY` 的乱码。
|
|
5134
|
+
// 预览本来只为量宽度,不要动画。
|
|
5135
|
+
if (balancePreviewValue() !== null) {
|
|
5136
|
+
setRoll(null);
|
|
5137
|
+
return;
|
|
5138
|
+
}
|
|
4831
5139
|
if (rollText === null || prev === null || prev === rollText) return;
|
|
4832
5140
|
if (manual) {
|
|
4833
5141
|
// 手动刷新期间不滚(擦除已经给足反馈),但**必须把 roll 同步到当前值**。
|
|
@@ -4935,62 +5243,92 @@ function makeTodayFlowStyle() {
|
|
|
4935
5243
|
// 上一段到点把 transform 清成 "",正好把新一段的过渡打断在半路 —— 滑到一半定住。
|
|
4936
5244
|
// 现在改成:**先清 transform 再量**(永远拿到布局位置,与动画无关),两个定时器都
|
|
4937
5245
|
// 进 ref 且新一段开始前全部取消;正在滑的时候从「当前视觉位置」接着走,不瞬移。
|
|
4938
|
-
|
|
4939
|
-
|
|
4940
|
-
|
|
4941
|
-
|
|
4942
|
-
|
|
5246
|
+
// ⚠️ 这段位移平滑现在由**三处共用**:「今日」二字、时段词「空闲」、时段词「高峰」。
|
|
5247
|
+
// 三者的 left 都是 flex 居中推出来的(居中 = (行宽 − 内容宽)/2),
|
|
5248
|
+
// 任何一处内容宽度一变,位置就跳,而纯 CSS 过渡不了一个由布局算出来的位置。
|
|
5249
|
+
// 2026-11-24 用户:「忘记给当前时段添加左右滑动的效果了 因为如果从剩10h到
|
|
5250
|
+
// 剩9h59m的话 当前空闲或高峰二字会直接瞬移」—— 就是这一处漏掉了时段词。
|
|
5251
|
+
// 连「剩」前缀一起存:滚动要对齐补的是数字段,前缀是非数字段、保持不动。
|
|
5252
|
+
const remainText = spanNow === null ? null : "剩 " + formatRemain(spanNow.remainMs);
|
|
5253
|
+
const glideLeft = react.useRef(Object.create(null)); // key → 上一次布局 left
|
|
5254
|
+
const glideTimers = react.useRef(Object.create(null)); // key → 进行中的定时器
|
|
5255
|
+
const clearGlideTimers = () => {
|
|
5256
|
+
for (const key of Object.keys(glideTimers.current)) {
|
|
5257
|
+
for (const timer of glideTimers.current[key] ?? []) clearTimeout(timer);
|
|
5258
|
+
glideTimers.current[key] = [];
|
|
5259
|
+
}
|
|
4943
5260
|
};
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
|
|
4947
|
-
|
|
4948
|
-
|
|
5261
|
+
// 把 el 从「旧位置」平滑推到现在的位置。逻辑与原先只服务「今日」那版完全一致。
|
|
5262
|
+
const glideTo = (el, key) => {
|
|
5263
|
+
// ⚠️ 元素不在场(换时段后另一个词根本不存在)就把它记的位置**作废**。
|
|
5264
|
+
// 否则下次它出现时 prev 还是几小时前的坐标,shift 几十像素,一进场就猛滑一下
|
|
5265
|
+
// —— 正是 AGENTS 里记的「prev 过期 → shift 巨大」那个坑。
|
|
5266
|
+
if (!el) {
|
|
5267
|
+
glideLeft.current[key] = null;
|
|
5268
|
+
return;
|
|
5269
|
+
}
|
|
5270
|
+
// ⚠️ 元素没有盒子时(切到设置页,DSH 会给祖先挂 display:none)rect 全是 0。
|
|
5271
|
+
// 这时量出来的「位置」是假的,记下来就污染了基准,切回来那一刻 shift 足有 50px、
|
|
5272
|
+
// 整块猛滑一下。getClientRects() 对 display:none 返回空列表,是唯一可靠的判断
|
|
5273
|
+
// (用 rect.width/left 判 0 会误伤真的贴在左边缘的元素;visibility:hidden 仍返回 rect,
|
|
5274
|
+
// 那时位置是对的,照常处理)。
|
|
5275
|
+
if (el.getClientRects().length === 0) {
|
|
5276
|
+
glideLeft.current[key] = null;
|
|
5277
|
+
el.style.transition = "";
|
|
5278
|
+
return;
|
|
5279
|
+
}
|
|
5280
|
+
const prev = glideLeft.current[key] ?? null;
|
|
4949
5281
|
// 正在滑的时候先记下当前视觉位置:新的一段要接着这里走,否则会瞬移回布局位置。
|
|
4950
|
-
const gliding =
|
|
4951
|
-
const visualNow = gliding ?
|
|
4952
|
-
clearTodayTimers();
|
|
5282
|
+
const gliding = el.style.transform !== "";
|
|
5283
|
+
const visualNow = gliding ? el.getBoundingClientRect().left : 0;
|
|
4953
5284
|
// ⚠️ 必须先清 transform 再量 —— 否则量到的是「布局位置 + 上一段残留位移」。
|
|
4954
5285
|
// 这一步在 paint 之前,而且紧接着就把 translateX 补回去,所以不会闪。
|
|
4955
|
-
|
|
4956
|
-
|
|
4957
|
-
const left =
|
|
4958
|
-
|
|
5286
|
+
el.style.transition = "none";
|
|
5287
|
+
el.style.transform = "";
|
|
5288
|
+
const left = el.getBoundingClientRect().left;
|
|
5289
|
+
glideLeft.current[key] = left;
|
|
4959
5290
|
// 首次挂载没有参照,只记位置不滑动。
|
|
4960
5291
|
if (prev === null) {
|
|
4961
|
-
|
|
5292
|
+
el.style.transition = "";
|
|
4962
5293
|
return;
|
|
4963
5294
|
}
|
|
4964
5295
|
// 静止时:新位置比旧位置左了多少,就先右移多少回到旧位置,再过渡回 0。
|
|
4965
5296
|
// 正在滑时:从当前视觉位置接着走(不再叠「上一段本该补的距离」,否则会越补越歪)。
|
|
4966
5297
|
const shift = gliding ? visualNow - left : prev - left;
|
|
4967
5298
|
if (Math.abs(shift) < 0.5) {
|
|
4968
|
-
|
|
5299
|
+
el.style.transition = "";
|
|
4969
5300
|
return;
|
|
4970
5301
|
}
|
|
4971
|
-
|
|
5302
|
+
el.style.transform = "translateX(" + shift.toFixed(2) + "px)";
|
|
4972
5303
|
// 下一帧才放开过渡。这里用 setTimeout 而不是 rAF —— DSH 渲染进程里
|
|
4973
5304
|
// rAF 会被窗口可见性挂起,回调可能永远不来(见 AGENTS「UI 易错点」)。
|
|
4974
5305
|
const id = setTimeout(() => {
|
|
4975
5306
|
// 460ms 不是随手写的:启动那一刻的位移只有 2.2px,320ms 滑完肉眼看不出在动、
|
|
4976
5307
|
// 只觉得"顿了一下";拉到 460ms 才读得出是平滑挪过去的(2026-10-31 反馈)。
|
|
4977
|
-
|
|
4978
|
-
|
|
5308
|
+
el.style.transition = "transform .46s cubic-bezier(.22,.72,.28,1)";
|
|
5309
|
+
el.style.transform = "translateX(0px)";
|
|
4979
5310
|
const done = setTimeout(() => {
|
|
4980
5311
|
// 清干净:transition 留着会影响后续任何位移,
|
|
4981
5312
|
// transform 留着更糟 —— 残留的 translateX(0px) 会让这块独立成合成层,
|
|
4982
5313
|
// 小字号中文在 GPU 纹理里渲染直接发虚(用户 2026-10-31:「数字变糊了」)。
|
|
4983
|
-
|
|
4984
|
-
|
|
4985
|
-
|
|
5314
|
+
el.style.transition = "";
|
|
5315
|
+
el.style.transform = "";
|
|
5316
|
+
glideTimers.current[key] = [];
|
|
4986
5317
|
}, 500);
|
|
4987
|
-
|
|
5318
|
+
glideTimers.current[key] = [done];
|
|
4988
5319
|
}, 16);
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
|
|
4993
|
-
|
|
5320
|
+
glideTimers.current[key] = [id];
|
|
5321
|
+
};
|
|
5322
|
+
usePrePaintEffect(() => {
|
|
5323
|
+
if (typeof document === "undefined" || typeof document.querySelector !== "function") return;
|
|
5324
|
+
clearGlideTimers();
|
|
5325
|
+
glideTo(document.querySelector(".balance-footer__timeline-meta-item--today .balance-footer__today-label"), "today");
|
|
5326
|
+
// 时段词两种形态各查一次:同一时刻只有一个在 DOM 里,
|
|
5327
|
+
// 另一个拿到 null 直接跳过(换时段时会从空闲切到高峰,位置同样要滑过去)。
|
|
5328
|
+
glideTo(document.querySelector(".balance-footer__timeline-meta-item--peak"), "peak");
|
|
5329
|
+
glideTo(document.querySelector(".balance-footer__timeline-meta-item--offpeak"), "offpeak");
|
|
5330
|
+
return clearGlideTimers;
|
|
5331
|
+
}, [todayText, remainText]);
|
|
4994
5332
|
const remainPrevRef = react.useRef(null);
|
|
4995
5333
|
const [remainRoll, setRemainRoll] = react.useState(null);
|
|
4996
5334
|
usePrePaintEffect(() => {
|
|
@@ -5378,7 +5716,8 @@ function makeTodayFlowStyle() {
|
|
|
5378
5716
|
// (2026-10-31 实测截图)。币种在收起态没有横向空间,展开态才显示。
|
|
5379
5717
|
// 滚动起点同样要把 `roll.from` 里的币种剥掉,否则 from 含 CNY、to 不含,
|
|
5380
5718
|
// 逐位比对会整串错位。
|
|
5381
|
-
|
|
5719
|
+
// ≥1000 取整(与侧栏胶囊同一口径,见 formatTotalDisplay)
|
|
5720
|
+
const rectNum = formatTotalDisplay(b.total_balance);
|
|
5382
5721
|
const stripCurrency = (s) => String(s == null ? "" : s).replace(/\s*[A-Z]{3}\s*$/, "");
|
|
5383
5722
|
const rectRoll = roll === null ? null : { from: stripCurrency(roll.from), at: roll.at, done: roll.done };
|
|
5384
5723
|
// ⚠️ 余额耗尽时整卡的跳转目标换成充值页(2026-11-13):卡片里那一行「充值」
|
|
@@ -5557,7 +5896,7 @@ function makeTodayFlowStyle() {
|
|
|
5557
5896
|
|
|
5558
5897
|
if (state.status === "error") {
|
|
5559
5898
|
return withPanel(jsx.jsxs("div", {
|
|
5560
|
-
className: "balance-footer" + footerEnterClass, id: "balance-footer-root",
|
|
5899
|
+
className: "balance-footer" + footerEnterClass + crowdClass, id: "balance-footer-root",
|
|
5561
5900
|
...interactions,
|
|
5562
5901
|
children: [
|
|
5563
5902
|
// 失败原因统一走主题化浮层,避免把长错误塞进 42px 的余额行
|
|
@@ -5581,7 +5920,15 @@ function makeTodayFlowStyle() {
|
|
|
5581
5920
|
}
|
|
5582
5921
|
|
|
5583
5922
|
const b = state.balance;
|
|
5584
|
-
|
|
5923
|
+
// ⚠️ 临时预览开关(2026-11-24 用户:「帮我给余额先暂时改成 99999 给我看一下」):
|
|
5924
|
+
// 地址栏加 `?mock=99999` 就能把主数字换成指定值,用来在真实的侧栏宽度下看
|
|
5925
|
+
// 万位金额会不会撑破胶囊 / 挤掉左边的时段文字。不加这个参数时**一个字节都不影响**,
|
|
5926
|
+
// 完全走真实余额。要用的时候重新加载页面并带上参数即可,不用改代码。
|
|
5927
|
+
const totalsPreview = balancePreviewValue();
|
|
5928
|
+
const totalRaw = totalsPreview ?? b.total_balance;
|
|
5929
|
+
// 显示用(≥1000 取整),计算与阈值判断仍用原值。
|
|
5930
|
+
const totalText0 = formatTotalDisplay(totalRaw);
|
|
5931
|
+
const total = Number.parseFloat(totalRaw ?? "0");
|
|
5585
5932
|
// 「余额不足」必须听服务端的 is_available,**不能**用 total <= 0 推断
|
|
5586
5933
|
// (2026-10-31 审查):`total_balance` 只是**充值余额**,赠送钱包单列在 granted_balance 里
|
|
5587
5934
|
// (见 AGENTS「主数字只等于充值余额」)。所以「充值花光但赠送还有」时 total 是 0、
|
|
@@ -5591,11 +5938,11 @@ function makeTodayFlowStyle() {
|
|
|
5591
5938
|
? b.is_available === false
|
|
5592
5939
|
: (!Number.isFinite(total) || total <= 0);
|
|
5593
5940
|
const currency = b.currency || "CNY";
|
|
5594
|
-
const totalText =
|
|
5941
|
+
const totalText = totalText0 + " " + currency;
|
|
5595
5942
|
// 位数多就降字号:一旦整数位到 4 位,16px 的胶囊会宽过 121px 的固定宽度
|
|
5596
5943
|
// (1234.56 CNY 131.3px / 12345.67 CNY 141.1px),把自己撑出容器右缘。
|
|
5597
5944
|
// 降一档字号就能收回来,宽度重新恒定 —— 配合 .balance-footer__value 的 min-width。
|
|
5598
|
-
const valueDensity = amountDensity(
|
|
5945
|
+
const valueDensity = amountDensity(totalText0);
|
|
5599
5946
|
// ⚠️ 余额耗尽**不再整行早退**(2026-11-13 用户:「在新版样式情况下 余额用完
|
|
5600
5947
|
// 只替换余额处为充值按钮」)。原来这里直接 return 一个「spacer + 去充值」,于是
|
|
5601
5948
|
// 新版样式底下「今日消耗 / 时段词 / 剩余时间 / 色带指针」**整块消失** ——
|
|
@@ -5848,7 +6195,7 @@ function makeTodayFlowStyle() {
|
|
|
5848
6195
|
children: period === "peak" ? "高峰" : "空闲",
|
|
5849
6196
|
});
|
|
5850
6197
|
return withPanel(jsx.jsxs("div", {
|
|
5851
|
-
className: "balance-footer balance-footer--classic" + footerEnterClass, id: "balance-footer-root",
|
|
6198
|
+
className: "balance-footer balance-footer--classic" + footerEnterClass + crowdClass, id: "balance-footer-root",
|
|
5852
6199
|
children: [
|
|
5853
6200
|
jsx.jsx("span", { className: "balance-footer__icon", children: jsx.jsx(WalletIcon, {}) }),
|
|
5854
6201
|
jsx.jsx("span", { className: "balance-footer__label", children: "余额" }),
|
|
@@ -5866,7 +6213,7 @@ function makeTodayFlowStyle() {
|
|
|
5866
6213
|
}), undefined, undefined, rowInteractions);
|
|
5867
6214
|
}
|
|
5868
6215
|
return withPanel(jsx.jsxs("div", {
|
|
5869
|
-
className: "balance-footer balance-footer--stacked" + footerEnterClass, id: "balance-footer-root",
|
|
6216
|
+
className: "balance-footer balance-footer--stacked" + footerEnterClass + crowdClass, id: "balance-footer-root",
|
|
5870
6217
|
children: [
|
|
5871
6218
|
// 抹除层覆盖整块显示区(today 行 + meta 行 + 时段条):白条经过哪里,哪里才显影
|
|
5872
6219
|
waveNode,
|
|
@@ -5890,9 +6237,15 @@ function makeTodayFlowStyle() {
|
|
|
5890
6237
|
key: "reveal-" + revealSeq,
|
|
5891
6238
|
children: [
|
|
5892
6239
|
// 底层(常显):光条没扫到的区域就是它,所以内容不会先消失再长出来。
|
|
6240
|
+
// ⚠️ 预览值生效时**底层直接写新值**(2026-11-24):ref 是上一轮渲染留下的旧值,
|
|
6241
|
+
// 而上面 sweep 层拿的是新值,没挂 --animate(revealSeq 为 0)时 clip-path 是 none、
|
|
6242
|
+
// 两层都画出来 → `99999.00CNY` 压着 `12.98CNY`。正常刷新两层内容相同,看不出来;
|
|
6243
|
+
// 预览一步从 3 位跳到 5 位才暴露。预览只要宽度,底层跟新值就好。
|
|
5893
6244
|
jsx.jsx("span", {
|
|
5894
6245
|
className: "balance-footer__reveal-base",
|
|
5895
|
-
children:
|
|
6246
|
+
children: totalsPreview !== null
|
|
6247
|
+
? totalText
|
|
6248
|
+
: (revealBaseRef.current !== null ? revealBaseRef.current : totalText),
|
|
5896
6249
|
}, "base"),
|
|
5897
6250
|
// 上层:被 clip-path 从左边擦开的那一层,光条走到哪,哪才盖住底层。
|
|
5898
6251
|
jsx.jsx("span", {
|
|
@@ -5994,6 +6347,13 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
5994
6347
|
usePrePaintEffect(() => {
|
|
5995
6348
|
if (typeof document === "undefined" || typeof document.querySelector !== "function") return undefined;
|
|
5996
6349
|
let disposed = false;
|
|
6350
|
+
// ⚠️ 重挂载(切会话 / 切视图)后的**第一拍测量**不许挂滑动过渡(2026-11-24:
|
|
6351
|
+
// 「切换对话时 对话消耗浮窗会有从左往右的动画」)。
|
|
6352
|
+
// 原因:floatBoxMemo 里存的是**上一个会话**的位置,新会话的输入卡片宽度不同 →
|
|
6353
|
+
// cardRect.right 不同 → 锚左缘算出来的 left 不同 → 首拍 movedPx 轻松过 12px →
|
|
6354
|
+
// 被判成「内部布局在动」而 slideOn(),屏幕上看就是卡片从旧位置滑到新位置。
|
|
6355
|
+
// 那不是布局在动,是换了内容。首拍直接落位,之后的真实位移照旧走过渡。
|
|
6356
|
+
let firstMeasure = floatBoxMemo !== null; // 冷启动 memo 是 null,本来就没过渡可挂
|
|
5997
6357
|
// ⚠️ 前置两个占位(measure 里要用,而它们真正定义在 measure 之后 —— 用 const 直接引用
|
|
5998
6358
|
// 会在首次 measure() 时撞上 TDZ)。
|
|
5999
6359
|
// · sync:把观察者补挂到**当前**这棵 DOM 上。收起/展开侧边栏时 DSH 会重建 composer 子树,
|
|
@@ -6259,7 +6619,9 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
6259
6619
|
: Math.max(Math.abs(floatBoxMemo.left - styleLeft), Math.abs(floatBoxMemo.bottom - styleBottom));
|
|
6260
6620
|
// 大跳变 + 视口没变 → 内部布局在动(收起/展开侧边栏),挂滑动过渡并保持一段;
|
|
6261
6621
|
// 视口变了 → 用户在拖窗口边缘,立刻摘掉过渡,卡片必须紧跟窗口(否则像被橡皮筋拽着)。
|
|
6262
|
-
|
|
6622
|
+
const isFirst = firstMeasure;
|
|
6623
|
+
firstMeasure = false;
|
|
6624
|
+
if (isFirst || vwChanged || cbMoved) measureCtl.slideOff();
|
|
6263
6625
|
else if (movedPx >= FLOAT_SLIDE_MIN_PX) measureCtl.slideOn();
|
|
6264
6626
|
// 布局还在动(侧边栏展开/收起带动输入卡片变宽)→ 顺手把观察者补挂到当前 DOM 上,
|
|
6265
6627
|
// 并再跟几拍。少了这两句,元素一被重建就退回「等兜底轮询」的老路 = 位置刷新慢半拍。
|
|
@@ -6267,7 +6629,8 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
6267
6629
|
// ⚠️ 包含块自己在动时(侧栏展开/收起的 width 过渡)**不排补拍**:
|
|
6268
6630
|
// 那段里 ResizeObserver 每帧都会回调 measure,本来就不缺触发源;
|
|
6269
6631
|
// 每帧再排 8 个定时器(0/16/40/…/400ms)纯属自己给自己加戏,是掉帧的一半来源。
|
|
6270
|
-
|
|
6632
|
+
// 首拍同样不排补拍:刚重挂载时位置已经用 memo 落对了,排八拍纯属白烧
|
|
6633
|
+
if (!isFirst && movedPx > FLOAT_JITTER_PX && !cbMoved) measureCtl.settle();
|
|
6271
6634
|
// 写 state 的同时记进模块级 memo:下一帧/下一次重挂载的首帧都用这个值,
|
|
6272
6635
|
// 不再等测量(否则切会话会闪一帧 CSS 兜底的 16/16)。
|
|
6273
6636
|
setFloatBox((prev) => {
|
|
@@ -7052,6 +7415,53 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
7052
7415
|
// 只是靠请求慢才看得见雾)。它只按「换会话 / 入场完成」起算,流式刷新期间不会重播。
|
|
7053
7416
|
const showCostLoading = (staleUsage || costPending || costFogFloor || !costResolved)
|
|
7054
7417
|
&& floatEntered && (!sessionReady || costFogFloor) && !costStuck;
|
|
7418
|
+
// 「这次加载已经超过 1 秒了」(2026-11-24 用户:「当对话估算加载超过1秒
|
|
7419
|
+
// 就在下方显示 提示对话历史过长需要时间 给用户」→ 又改成「可以单独显示一个小浮窗」)。
|
|
7420
|
+
// 两个方向都要有下限:
|
|
7421
|
+
// 亮 —— 连续加载满 COST_SLOW_HINT_MS 才亮(1 秒以下不打扰,正常会话都在这个区间);
|
|
7422
|
+
// 收 —— 亮了之后至少留 COST_SLOW_HINT_MIN_MS 才允许收(2026-11-24 用户:
|
|
7423
|
+
// 「有的对话可能刚好1秒多一点 导致提示就闪了一下 所以添加提示显示保底1秒」)。
|
|
7424
|
+
// 只加亮的下限的话,1.05 秒的加载会让气泡只活 50ms,连 200ms 的淡出都走不完。
|
|
7425
|
+
// ⚠️ 依赖里必须有 costSlowHint:收的那一支要靠它判断「这次是真亮过还是没亮过」。
|
|
7426
|
+
// 亮了以后 effect 会再跑一遍,但第一支的 `if (costSlowHint) return` 会挡住重排,
|
|
7427
|
+
// 不会自己重启定时器,也不会死循环。
|
|
7428
|
+
// ⚠️ 记「亮起时刻」用 ref 不用 state:它不参与渲染,写它不该触发重渲染。
|
|
7429
|
+
// ⚠️ 显示的判据是 costSlowHint **自己**,绝不能再串一个 showCostLoading ——
|
|
7430
|
+
// showCostLoading 在「加载结束」那一帧就变 false,串上它等于保底时长作废:
|
|
7431
|
+
// 1.05 秒的加载依旧只亮 50ms(2026-11-24 自查出来的 bug,用户本来就是在报这个「闪一下」)。
|
|
7432
|
+
// costSlowHint 只在 showCostLoading 期间才被置 true,收起有保底,本身就是完整判据。
|
|
7433
|
+
const [costSlowHint, setCostSlowHint] = react.useState(false);
|
|
7434
|
+
const slowHintShowAt = react.useRef(0);
|
|
7435
|
+
const slowHintSession = react.useRef(sessionId);
|
|
7436
|
+
react.useEffect(() => {
|
|
7437
|
+
// 换会话 = 全新一轮:上一个会话的亮起状态不许带过来,
|
|
7438
|
+
// 否则切到一个慢会话时会「刚进来就显示历史过长」,其实它还没加载满 1 秒。
|
|
7439
|
+
let hintOn = costSlowHint;
|
|
7440
|
+
if (slowHintSession.current !== sessionId) {
|
|
7441
|
+
slowHintSession.current = sessionId;
|
|
7442
|
+
slowHintShowAt.current = 0;
|
|
7443
|
+
hintOn = false;
|
|
7444
|
+
if (costSlowHint) setCostSlowHint(false);
|
|
7445
|
+
}
|
|
7446
|
+
if (showCostLoading) {
|
|
7447
|
+
if (hintOn) return undefined; // 已经亮着,别重排
|
|
7448
|
+
const id = setTimeout(() => {
|
|
7449
|
+
slowHintShowAt.current = Date.now();
|
|
7450
|
+
setCostSlowHint(true);
|
|
7451
|
+
}, COST_SLOW_HINT_MS);
|
|
7452
|
+
return () => clearTimeout(id);
|
|
7453
|
+
}
|
|
7454
|
+
// 加载结束了:没亮过就什么都不用做(大多数情况)
|
|
7455
|
+
if (!hintOn) return undefined;
|
|
7456
|
+
// 亮过就补足保底时长,剩余多少等多少
|
|
7457
|
+
const left = COST_SLOW_HINT_MIN_MS - (Date.now() - slowHintShowAt.current);
|
|
7458
|
+
if (left <= 0) {
|
|
7459
|
+
setCostSlowHint(false);
|
|
7460
|
+
return undefined;
|
|
7461
|
+
}
|
|
7462
|
+
const id = setTimeout(() => setCostSlowHint(false), left);
|
|
7463
|
+
return () => clearTimeout(id);
|
|
7464
|
+
}, [showCostLoading, costSlowHint, sessionId]);
|
|
7055
7465
|
// 等待兜底:4 秒还没等到(请求一直不返回 / 服务端卡住),停止等、退回缓存值。
|
|
7056
7466
|
// ⚠️ 依赖只留这三个(2026-10-31 第二十二轮审计):早先 `showCostLoading` 也在依赖里,
|
|
7057
7467
|
// 而它含 staleUsage / costPending,流式期间每变一次就 cleanup 重排 → 计时器被无限顺延,
|
|
@@ -7648,7 +8058,8 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
7648
8058
|
// (订阅/离场判定都在用 document.querySelector 找它),`.balance-float` 才是浮窗外观。
|
|
7649
8059
|
className: "balance-usage-line balance-float"
|
|
7650
8060
|
+ (floatEnter ? " balance-float--enter" : "")
|
|
7651
|
-
+ (floatSlide ? " balance-float--slide" : "")
|
|
8061
|
+
+ (floatSlide ? " balance-float--slide" : "")
|
|
8062
|
+
+ (costSlowHint ? " balance-float--slow" : ""),
|
|
7652
8063
|
"aria-haspopup": "dialog",
|
|
7653
8064
|
"aria-expanded": detailsOpen,
|
|
7654
8065
|
"aria-label": "本会话消耗明细",
|
|
@@ -7670,7 +8081,25 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
7670
8081
|
// 2026-11-02 第十一轮:用户「只显示本会话的消耗 不要今日消耗 然后调小一点 太大了
|
|
7671
8082
|
// 我要的是第一列显示本会话消耗估算的字样 第二列显示消耗数字 保留动画」——
|
|
7672
8083
|
// 所以今日那一整行(连带它的雾/擦出/滚 & 图标)都撤掉了,卡片回到 20px 高。
|
|
7673
|
-
|
|
8084
|
+
// 两行常驻内容 + 卡片外那颗慢加载气泡,用展开写法拼成一个数组
|
|
8085
|
+
// (原来是对象简写 `children,`,加第三个节点必须改成展开,否则语法不成立)。
|
|
8086
|
+
children: [
|
|
8087
|
+
...children,
|
|
8088
|
+
// 慢加载气泡(2026-11-24 用户:「当对话估算加载超过1秒 就在下方显示
|
|
8089
|
+
// 提示对话历史过长需要时间 给用户」→ 又改口「可以单独显示一个小浮窗」)。
|
|
8090
|
+
// 挂在卡片底部之外、靠 bottom:100% 定位到正上方,所以**不影响卡片高度**
|
|
8091
|
+
// (卡片始终 42px,不再有"长高 13px"的抖动)。
|
|
8092
|
+
// 常驻节点 + 只切 opacity:条件渲染没有过渡,会出现/消失得很硬。
|
|
8093
|
+
jsx.jsx("span", {
|
|
8094
|
+
key: "slow",
|
|
8095
|
+
className: "balance-float__slow-tip",
|
|
8096
|
+
"aria-hidden": costSlowHint ? void 0 : "true",
|
|
8097
|
+
// ⚠️ 文字**不许**跟着 costSlowHint 一起清空:一清空,opacity 的淡出
|
|
8098
|
+
// 就没有内容可看,视觉上是硬切(2026-11-24 用户:「提示消失没有动画了」)。
|
|
8099
|
+
// 常驻 + 只切 aria-hidden/透明度,进出场才都看得见。
|
|
8100
|
+
children: jsx.jsx("b", { children: "历史过长,稍候" }),
|
|
8101
|
+
}),
|
|
8102
|
+
],
|
|
7674
8103
|
}),
|
|
7675
8104
|
detailsOpen
|
|
7676
8105
|
? createPortal(
|
|
@@ -9281,6 +9710,8 @@ function UsageCostLine({ useProjection, sessionId }) {
|
|
|
9281
9710
|
// ctx.get() 不会因未声明注入而抛错,服务不存在时返回 undefined。
|
|
9282
9711
|
sessionsFace = typeof ctx.get === "function" ? ctx.get("sessions") : void 0;
|
|
9283
9712
|
// 余额显示:展开态底部胶囊(order 20 排在市场 10 之后、紧挨设置);收起态悬浮 FAB
|
|
9713
|
+
// 布局:footerActions 开了 flex-wrap,.balance-footer 占满一整行(flex:1 1 100%),
|
|
9714
|
+
// 所以别的插件也占这一行时会被挤到下一行,两边都不裁字(见 .balance-footer 那段注释)。
|
|
9284
9715
|
ctx.slots.inject("sidebar.footer.action", () =>
|
|
9285
9716
|
ctx.slots.register(
|
|
9286
9717
|
{
|
package/lib/index.js
CHANGED
|
@@ -80,13 +80,30 @@ const SESSION_STAMP_TTL_MS = 5 * 1000; // 指纹来源(会话列表)
|
|
|
80
80
|
// 指纹必然每次都变;不节流就是「每个 chunk 一轮 800 ms 同步解压」。
|
|
81
81
|
// 4 秒的滞后在这个场景里感知不到(余额轮询本身 60 秒一轮)。
|
|
82
82
|
const SESSION_REREAD_MIN_MS = 4 * 1000;
|
|
83
|
-
//
|
|
84
|
-
//
|
|
85
|
-
//
|
|
86
|
-
//
|
|
87
|
-
|
|
88
|
-
//
|
|
89
|
-
|
|
83
|
+
// 自适应冷却的上下限(2026-11-24):按「这个会话上一次真读盘花了多久」现算。
|
|
84
|
+
// 会话大小差好几个数量级 —— 新开的会话解压 20 ms,这个 27 MB / 85 MB 解压后的会话要 560 ms。
|
|
85
|
+
// 写死一个数必然两头不讨好:小会话被拖慢、大会话还是卡。
|
|
86
|
+
// 目标:让「真读盘」始终只占约 1/12 的墙钟时间,剩下 11/12 留给 DSH 自己。
|
|
87
|
+
const SESSION_REREAD_MAX_MS = 15 * 1000;
|
|
88
|
+
// 每个会话上一次**真正解压**的耗时(ms)。只由成功路径写,失败不参与(失败本来就没解出东西)。
|
|
89
|
+
// ⚠️ 必须 capSessionMap 限长,否则跨月累积上千个会话 id 永不回收。
|
|
90
|
+
const sessionReadCost = new Map();
|
|
91
|
+
|
|
92
|
+
/** 这个会话该冷却多久才允许再读盘。测过就按耗时现算,没测过用默认值。 */
|
|
93
|
+
function sessionRereadMinMs(sessionId) {
|
|
94
|
+
const measured = sessionReadCost.get(sessionId);
|
|
95
|
+
if (typeof measured !== "number" || !Number.isFinite(measured) || measured <= 0) {
|
|
96
|
+
return SESSION_REREAD_MIN_MS;
|
|
97
|
+
}
|
|
98
|
+
// ×12 = 「读盘占 1/12」。夹在 [MIN, MAX] 之间:
|
|
99
|
+
// 小会话被抬到 4 秒下限(再快也没意义,客户端本来就 600ms 问一次);
|
|
100
|
+
// 大会话最高 15 秒封顶(再长用户会觉得金额卡死了)。
|
|
101
|
+
return Math.min(SESSION_REREAD_MAX_MS, Math.max(SESSION_REREAD_MIN_MS, Math.round(measured * 12)));
|
|
102
|
+
}
|
|
103
|
+
// 子会话的重读间隔已并入 sessionRereadMinMs(2026-11-24):原来写死 15 秒,
|
|
104
|
+
// 但 fork 队友的日志是父会话全量副本、体量从小到几百 MB 都有,写死一样两头不讨好。
|
|
105
|
+
// 现在和父会话走同一套「按上次解压耗时现算 + [4s, 15s] 夹值」。
|
|
106
|
+
// 注意子会话数字只是**补充信息**(团队补拉本来就 15 秒一轮),所以上限 15 秒对它是够的。
|
|
90
107
|
// 子代理整体结果的短期备忘(同 rootKey + 配置)。`?session=` 一次请求里
|
|
91
108
|
// 会连着问好几处(消耗行 / 团队补拉 / 今日增量),1.5 秒内复用同一份,
|
|
92
109
|
// 端到端把这段从 36~97 ms 压到 0。子会话本身有 15 秒节流,这里不会让数字更旧。
|
|
@@ -542,7 +559,12 @@ async function inspectPersistedCached(ctx, sessionId, minIntervalMs = 0, opts =
|
|
|
542
559
|
|
|
543
560
|
const task = (async () => {
|
|
544
561
|
try {
|
|
562
|
+
const readStartedAt = Date.now();
|
|
545
563
|
const value = await inspectPersistedSession(ctx, sessionId);
|
|
564
|
+
// 记这次解压花了多久 —— 下一拍 sessionRereadMinMs() 靠它决定冷却时长。
|
|
565
|
+
// 放在 value 拿到之后:抛异常说明没解出东西,不能拿半截耗时去缩短/拉长节流。
|
|
566
|
+
sessionReadCost.set(sessionId, Date.now() - readStartedAt);
|
|
567
|
+
capSessionMap(sessionReadCost);
|
|
546
568
|
// 覆盖同一会话时先把旧那份的字节数扣掉,否则总量只增不减。
|
|
547
569
|
if (persistCache.has(sessionId)) dropEntry(sessionId);
|
|
548
570
|
const size = estimateBytes(value);
|
|
@@ -1140,7 +1162,7 @@ function formatBalance(balance) {
|
|
|
1140
1162
|
// | { status:"failed" } (网络失败;官方明确“失败绝不变成 0 余额”)
|
|
1141
1163
|
// client 是 AccountClientMetadata(version / locale / timezoneOffsetSeconds),
|
|
1142
1164
|
// 缺字段会在平台侧组装请求头时抛错,所以三个字段都要给。
|
|
1143
|
-
const PLUGIN_VERSION = "2.3.
|
|
1165
|
+
const PLUGIN_VERSION = "2.3.4";
|
|
1144
1166
|
|
|
1145
1167
|
/** 斜杠命令名(2026-10-31 定案:用带作者后缀的全名,避免和别的余额插件撞车,也不设备用名)。
|
|
1146
1168
|
* ⚠️ DSH 的 COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u —— **只允许小写**。
|
|
@@ -3308,7 +3330,7 @@ async function buildTodayCost(ctx, config, reuse = null, dayStartOverride = null
|
|
|
3308
3330
|
// 替刚离开的那个大会话重新解压 65 MB 纯属白烧 CPU,还会把用户正看的那个对话拖住。
|
|
3309
3331
|
// ⚠️ 跳过得记账(`skipped += 1`),否则这个会话的今日贡献会变成「0 且看起来正常」——
|
|
3310
3332
|
// 那正是 2.1.9 修过的假 0,`suspiciousEmpty` / 不落盘全靠这个计数兜住。
|
|
3311
|
-
const inspected = await inspectPersistedCached(ctx, sessionId,
|
|
3333
|
+
const inspected = await inspectPersistedCached(ctx, sessionId, sessionRereadMinMs(sessionId), {
|
|
3312
3334
|
yieldWhenStale: true,
|
|
3313
3335
|
});
|
|
3314
3336
|
if (inspected === PERSIST_STALE_SKIPPED) {
|
|
@@ -4040,7 +4062,9 @@ async function sumSubagentUsageUncached(ctx, sessionId, config) {
|
|
|
4040
4062
|
const stamp = String(childStamps.get(id) ?? childStamps.get(`session-${id}`) ?? "");
|
|
4041
4063
|
let u = (getAggCache(id, stamp, config) ?? null)?.usage ?? null;
|
|
4042
4064
|
if (u === null) {
|
|
4043
|
-
|
|
4065
|
+
// 子会话(队友 / 子代理)同样按体量自适应:fork 出来的队友日志就是父会话全量副本,
|
|
4066
|
+
// 常常比父会话还大。用同一个 sessionRereadMinMs 走同一套上下限。
|
|
4067
|
+
const inspected = await inspectPersistedCached(ctx, id, sessionRereadMinMs(id));
|
|
4044
4068
|
const events = Array.isArray(inspected?.events) ? inspected.events : [];
|
|
4045
4069
|
// ⚠️ fork 出来的子会话(智能体团队的 context:"fork" 队友、subagent_fork)**整段继承
|
|
4046
4070
|
// 了父会话的事件前缀**(buildForkSeed 直接把源事件 slice 复制进新日志),
|
|
@@ -5213,9 +5237,9 @@ let statsInFlight = null;
|
|
|
5213
5237
|
throw SESSION_FOCUS_DROPPED;
|
|
5214
5238
|
}
|
|
5215
5239
|
if (sessionDiag !== null) sessionDiag.focusDropped = false;
|
|
5216
|
-
let persisted = await inspectPersistedCached(ctx, persistedId,
|
|
5240
|
+
let persisted = await inspectPersistedCached(ctx, persistedId, sessionRereadMinMs(persistedId));
|
|
5217
5241
|
if ((persisted == null || !Array.isArray(persisted.events) || persisted.events.length === 0) && persistedId !== sessionParam) {
|
|
5218
|
-
persisted = await inspectPersistedCached(ctx, sessionParam,
|
|
5242
|
+
persisted = await inspectPersistedCached(ctx, sessionParam, sessionRereadMinMs(sessionParam));
|
|
5219
5243
|
}
|
|
5220
5244
|
if (sessionDiag !== null) {
|
|
5221
5245
|
sessionDiag.persisted = {
|