balance-dsh 2.3.4 → 2.3.6

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.
Files changed (4) hide show
  1. package/README.md +23 -28
  2. package/lib/client.js +2577 -230
  3. package/lib/index.js +2015 -103
  4. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -171,7 +171,7 @@ 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: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}
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,#e6e6e8);font-size:14px;line-height:22px;text-decoration:none;cursor:pointer;white-space:nowrap;overflow:visible;-webkit-user-select:none;user-select:none}
175
175
  /* ⚠️ 这里没有 width:100%(2026-11-24,issue #3),用 flex:1 1 auto:吃满可用宽度,但 basis 是
176
176
  内容宽,不会像 flex:1 1 100% 那样在 flex-wrap 容器里独占一行(那会把「移动访问」挤到第二行,
177
177
  两行各自居中之后看着就是「胶囊偏上」)。
@@ -532,8 +532,8 @@ window.__ModuleLoader__.load({
532
532
  /* 尊重系统的「减少动态效果」:不播,只留 --stale 的静态弱化 */
533
533
  /* 浪潮白条不受 prefers-reduced-motion 影响:它是右键刷新的签名动效,故意保留 */
534
534
  /* 旧版余额行用到的图标与「余额」二字(footerStyle === "classic" 时才渲染) */
535
- .balance-footer__icon{display:inline-flex;flex:none;color:var(--dsw-alias-label-primary)}
536
- .balance-footer__label{flex:none;color:var(--dsw-alias-label-primary)}
535
+ .balance-footer__icon{display:inline-flex;flex:none;color:var(--dsw-alias-label-primary,#e6e6e8)}
536
+ .balance-footer__label{flex:none;color:var(--dsw-alias-label-primary,#e6e6e8)}
537
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 + 位数多就缩字号」两条一起实现。
538
538
  ⚠️ 开头的 box-sizing:border-box 是前提,不能省:min-width 默认算的是「内容盒」,
539
539
 
@@ -702,20 +702,26 @@ window.__ModuleLoader__.load({
702
702
  /* 旧版金额胶囊里的分隔点:两侧各 5px,柔化到 50% 不透明,不抢金额 */
703
703
  .balance-footer__sep{flex:none;margin:0 5px;opacity:.5;font-weight:400}
704
704
  .balance-footer__period-inline{font-weight:500;white-space:nowrap}
705
- .balance-footer__period-inline--refreshing{color:var(--dsw-alias-label-secondary)}
705
+ .balance-footer__period-inline--refreshing{color:var(--dsw-alias-label-secondary,#b9b9bd)}
706
706
  .balance-footer__period-inline--peak{color:var(--dsw-alias-state-error-primary,#e5484d)}
707
707
  .balance-footer__period-inline--offpeak{color:var(--dsw-alias-state-success-primary)}
708
708
  /* 时段刻度条:色带固定 = 一整天,指针随时刻从左走到右。
709
709
  结构:[meta 行(今日/时段/剩余)] + [轨道(边框) → 裁剪层(1px 内缩 → 泛光 + 色带) + 指针]。
710
710
  轨道刻意做扁(20px 压到 13px),上方留一行给文字,整块像个"仪表盘"而不是"进度胶囊"。 */
711
- .balance-footer__timeline{position:relative;z-index:0;display:inline-flex;flex-direction:column;align-items:center;gap:4px;flex:1 1 auto;min-width:0;white-space:nowrap;margin:0;overflow:hidden}
711
+ /* 容器必须 overflow:visible:hover 的 scale + box-shadow 泛光要能溢出这块,
712
+ 原来 hidden 会把放大出来的边缘和整圈光晕裁掉(2026-11-26 用户:
713
+ 「鼠标放上去的整体放大一点 然后泛光」)。
714
+ 裁剪下沉到文字行(.balance-footer__timeline-meta)—— 真正会横向溢出的是它(可折行、
715
+ 「剩 1d20h」字数会变),这才是那条「不压到金额上」要防的东西;
716
+ 刻度条受 flex 限制本来就不会超出。色带圆角仍由内部的 .balance-footer__timeline-clip 自己裁。 */
717
+ .balance-footer__timeline{position:relative;z-index:0;display:inline-flex;flex-direction:column;align-items:center;gap:4px;flex:1 1 auto;min-width:0;white-space:nowrap;margin:0;overflow:visible}
712
718
  /* meta 行:等宽数字,三项之间用中点分隔感靠 gap 制造。
713
719
  三项都 flex:none、都 nowrap,所以这一行只会随内容变宽、永不主动收缩 ——
714
720
  「今日 ¥1234.56」比「今日 ¥14.34」宽两三个数字位,余额胶囊又同时要宽度,
715
721
  两者硬碰硬时右侧胶囊会被挤出容器裁掉(余额四位数 + 消费四位数就能复现)。
716
722
  所以给它 max-width + flex-wrap:空间不够时三项自己折行,块变高(--stacked 是
717
723
  height:auto,撑得住),而不是把胶囊顶出去。 */
718
- .balance-footer__timeline-meta{display:inline-flex;align-items:center;gap:6px;row-gap:3px;flex-wrap:wrap;justify-content:center;max-width:100%;font-size:11px;line-height:1;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary,#8a8a8a);margin:0}
724
+ .balance-footer__timeline-meta{display:inline-flex;align-items:center;gap:6px;row-gap:3px;flex-wrap:wrap;justify-content:center;max-width:100%;overflow:hidden;font-size:12px;line-height:1;font-variant-numeric:tabular-nums;color:var(--dsw-alias-label-tertiary,#8a8a8a);margin:0}
719
725
  .balance-footer__timeline-meta-item{flex:none;white-space:nowrap}
720
726
  /* 「今日 ¥x」独占第一行(flex-basis:100%)并居中,与下面「空闲 剩 3h57m」那一行左对齐成组。
721
727
  inline-flex 是为了把「今日」/「¥」/ 滚动数字排成一行(基线对齐,小数点不会上下错)。
@@ -816,7 +822,7 @@ window.__ModuleLoader__.load({
816
822
  ⚠️ 这里不再用 keyframes:5px 的假位移看着仍是"跳一下再归位",
817
823
  用户 2026-10-31 明确要「滑动过去」。真正的滑动由 JS 量出实际位移再补 ——
818
824
  见 usePrePaintEffect 里给 label 写 style 的那段(transition 由它临时加上)。 */
819
- .balance-footer__today-label{display:inline-block}
825
+ .balance-footer__today-label{display:inline-block;font-weight:500}
820
826
  /* ¥ 与数字之间的呼吸:¥ 是宽字符,紧贴数字会显得糊在一起
821
827
  (2026-10-31 用户指出「数字是不是太靠近¥了」)。2px 在 11px 字号下刚刚好,
822
828
  再多就会被读成两个独立的词。 */
@@ -918,8 +924,17 @@ window.__ModuleLoader__.load({
918
924
  会撑到内容高度,overflow 永远不触发),再配 overflow-y:auto。 */
919
925
  .balance-panel-page{box-sizing:border-box;display:flex;flex:1 1 auto;flex-direction:column;gap:14px;min-height:0;max-height:100%;width:100%;max-width:820px;margin:0 auto;padding:28px 24px 40px;overflow-y:auto;overscroll-behavior:contain;scrollbar-gutter:stable}
920
926
  .balance-panel-page__head{display:flex;flex-direction:column;gap:6px}
921
- .balance-panel-page__title{margin:0;font-size:18px;line-height:26px;font-weight:600;color:var(--dsw-alias-label-primary)}
922
- .balance-panel-page__desc{margin:0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary)}
927
+ .balance-panel-page__title{margin:0;font-size:18px;line-height:26px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8)}
928
+ .balance-panel-page__desc{margin:0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
929
+ /* 余额读取失败:原来是一行红字,在侧栏底部显得很单薄,也不占位、
930
+ 余额胶囊该在的位置空着。现在复用 .balance-footer__value 的盒子(min-width / 圆角 / 居中 /
931
+ 盒模型全部继承),只换配色;尺寸单独钉死,保证与正常余额胶囊同高、不会把整块顶一下。
932
+ 正常胶囊:font-size:16px + line-height:1 + padding:7px 上下 = 30px 高。
933
+ 错误文案 6 个字按 16px 排会到 124px 宽,所以字号降到 13px、用 height 把高度锁回 30px。 */
934
+ .balance-footer__value--error{color:var(--dsw-alias-state-error-primary,#e5484d);background:rgba(229,72,77,.15);font-size:13px;height:30px;padding:0 12px;min-width:0;cursor:default}
935
+ .balance-footer__value--error:hover{transform:none;background:rgba(229,72,77,.15)}
936
+ /* 精简竖排态:基座被覆盖成 90px / 6-11 padding / 13px 字,这里等比跟上并保持同一高度 */
937
+ .balance-footer--compact.balance-footer--stacked .balance-footer__value--error{min-width:0;height:26px;padding:0 9px;font-size:11px}
923
938
  .balance-footer__error{color:var(--dsw-alias-state-error-primary)}
924
939
  .balance-topup{box-sizing:border-box;display:flex;align-items:center;justify-content:flex-start;gap:8px;width:calc(100% + 4px);min-width:0;height:42px;margin:0 -2px;padding:0 10px 0 8px;color:var(--dsw-alias-state-error-primary,#e5484d);font-size:14px;font-weight:600;line-height:22px;text-decoration:none;cursor:pointer;white-space:nowrap;overflow:hidden}
925
940
  .balance-topup:hover{text-decoration:underline}
@@ -932,7 +947,7 @@ window.__ModuleLoader__.load({
932
947
  默认是 superellipse(1.5)——不覆盖的话 border-radius:50% 会被渲染成"圆角方形"
933
948
  (squircle),根本不是圆(2026-09-28 用户反馈「很奇怪啊」,截图是 squircle)。
934
949
  DSH 自己的 .pill 也是这么显式写 corner-shape:round 抵消的。 */
935
- .balance-fab{box-sizing:border-box;position:fixed;left:44px;bottom:44px;z-index:9998;width:60px;height:60px;padding:0;border-radius:50%;corner-shape:round;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-primary);font-size:13px;font-weight:600;line-height:1;font-variant-numeric:tabular-nums;letter-spacing:-.01em;text-decoration:none;white-space:nowrap;overflow:hidden;cursor:pointer;pointer-events:auto;background:color-mix(in srgb,var(--dsw-alias-bg-module-platform,var(--dsw-alias-bg-base,#1b1b1c)) 58%,transparent);-webkit-backdrop-filter:blur(18px) saturate(180%);backdrop-filter:blur(18px) saturate(180%);border:1px solid color-mix(in srgb,var(--dsw-alias-label-primary) 14%,transparent);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 26%,transparent),inset 0 -1px 1px color-mix(in srgb,#fff 8%,transparent),0 6px 20px rgba(0,0,0,.28);transition:transform .18s var(--ds-ease-in-out,ease-out),color .42s var(--ds-ease-in-out,ease-out),background .42s var(--ds-ease-in-out,ease-out),box-shadow .18s var(--ds-ease-in-out,ease-out),opacity .18s var(--ds-ease-in-out,ease-out)}
950
+ .balance-fab{box-sizing:border-box;position:fixed;left:44px;bottom:44px;z-index:9998;width:60px;height:60px;padding:0;border-radius:50%;corner-shape:round;display:inline-flex;align-items:center;justify-content:center;color:var(--dsw-alias-label-primary,#e6e6e8);font-size:13px;font-weight:600;line-height:1;font-variant-numeric:tabular-nums;letter-spacing:-.01em;text-decoration:none;white-space:nowrap;overflow:hidden;cursor:pointer;pointer-events:auto;background:color-mix(in srgb,var(--dsw-alias-bg-module-platform,var(--dsw-alias-bg-base,#1b1b1c)) 58%,transparent);-webkit-backdrop-filter:blur(18px) saturate(180%);backdrop-filter:blur(18px) saturate(180%);border:1px solid color-mix(in srgb,var(--dsw-alias-label-primary,#e6e6e8) 14%,transparent);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 26%,transparent),inset 0 -1px 1px color-mix(in srgb,#fff 8%,transparent),0 6px 20px rgba(0,0,0,.28);transition:transform .18s var(--ds-ease-in-out,ease-out),color .42s var(--ds-ease-in-out,ease-out),background .42s var(--ds-ease-in-out,ease-out),box-shadow .18s var(--ds-ease-in-out,ease-out),opacity .18s var(--ds-ease-in-out,ease-out)}
936
951
  .balance-fab:hover{transform:scale(1.06);background:color-mix(in srgb,var(--dsw-alias-bg-module-platform,var(--dsw-alias-bg-base,#1b1b1c)) 76%,transparent);box-shadow:inset 0 1px 0 color-mix(in srgb,#fff 34%,transparent),inset 0 -1px 1px color-mix(in srgb,#fff 10%,transparent),0 10px 26px rgba(0,0,0,.34)}
937
952
  .balance-fab:active{transform:scale(.95)}
938
953
  /* 金额偏长时(如 ¥1234.56)自动收一号字,免得 60px 圆里挤爆 */
@@ -956,7 +971,7 @@ window.__ModuleLoader__.load({
956
971
  圆钮的 inset 0 1px 0 #fff 26% 与 inset 0 -1px 1px #fff 8% 在 60px 圆里
957
972
  刚好读成玻璃高光,但拉成 81×148 的矩形后,两条 inset 会在内侧连成一整圈亮边,
958
973
  再叠上 border,看起来就是"内外两层描边"。矩形只要一条淡边 + 外投影。 */
959
- border:1px solid color-mix(in srgb,var(--dsw-alias-label-primary) 9%,transparent);
974
+ border:1px solid color-mix(in srgb,var(--dsw-alias-label-primary,#e6e6e8) 9%,transparent);
960
975
  box-shadow:0 4px 16px rgba(0,0,0,.24);
961
976
  }
962
977
  /* ⚠️ hover 也必须重写 box-shadow 和 border-color:.balance-fab:hover 里还有一整套
@@ -964,7 +979,7 @@ window.__ModuleLoader__.load({
964
979
  否则鼠标一移上去那圈内亮边又回来了。 */
965
980
  .balance-fab--rect:hover{
966
981
  transform:scale(1.03);
967
- border-color:color-mix(in srgb,var(--dsw-alias-label-primary) 14%,transparent);
982
+ border-color:color-mix(in srgb,var(--dsw-alias-label-primary,#e6e6e8) 14%,transparent);
968
983
  box-shadow:0 6px 20px rgba(0,0,0,.3);
969
984
  }
970
985
  .balance-fab--rect:active{transform:scale(.97)}
@@ -1038,9 +1053,9 @@ window.__ModuleLoader__.load({
1038
1053
  圆角是 --dsw-radius-sm(小圆角矩形),不是 999px 胶囊;也不要加
1039
1054
  corner-shape:round —— 原生 hover/展开态就是这个小圆角背景,写成胶囊对不上。 */
1040
1055
  .balance-usage-wrap{min-width:0;display:inline-flex;align-items:center}
1041
- .balance-usage-line{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);font-variant-numeric:tabular-nums;line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;background:0 0;border:none;border-radius:var(--dsw-radius-sm);align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer;height:calc(1lh + 2px)}
1056
+ .balance-usage-line{box-sizing:border-box;max-width:100%;color:var(--dsw-alias-label-tertiary,#9a9a9e);font:inherit;font-size:calc(var(--dsh-content-font-size-secondary,13px) - 1px);font-variant-numeric:tabular-nums;line-height:calc(20px + var(--dsh-content-font-delta-secondary,0px));white-space:nowrap;background:0 0;border:none;border-radius:var(--dsw-radius-sm);align-items:center;gap:6px;padding:1px 8px;display:inline-flex;cursor:pointer;height:calc(1lh + 2px)}
1042
1057
  .balance-usage-line svg{flex:none;width:14px;height:14px}
1043
- .balance-usage-line:hover,.balance-usage-line[aria-expanded="true"]{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12));color:var(--dsw-alias-label-secondary)}
1058
+ .balance-usage-line:hover,.balance-usage-line[aria-expanded="true"]{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12));color:var(--dsw-alias-label-secondary,#b9b9bd)}
1044
1059
  .balance-usage-label{text-overflow:ellipsis;min-width:0;overflow:hidden}
1045
1060
  /* 金额那一段单独成类。**宽度必须恒定**:这段一变宽变窄,composer dock 那一行就重排,
1046
1061
  输入框会被顶得上下跳(2026-10-30 用户实测反馈)。
@@ -1062,7 +1077,7 @@ window.__ModuleLoader__.load({
1062
1077
  /* 智能体团队(Agent Teams)小圆片:只在 roster 里有人时才挂。
1063
1078
  高度 16px(行高 22px,纵向放得下、不会把整行撑高),字号 11px 跟随 DSH 的次要信息档;
1064
1079
  背景用很低的白(.06)—— 比胶囊的雾淡一档,读起来是"附注"而不是第二个数字。 */
1065
- .balance-usage-team{display:inline-flex;align-items:center;flex:none;height:16px;padding:0 5px;border-radius:999px;corner-shape:round;background:rgba(255,255,255,.06);color:var(--dsw-alias-label-tertiary);font-size:11px;line-height:16px;white-space:nowrap}
1080
+ .balance-usage-team{display:inline-flex;align-items:center;flex:none;height:16px;padding:0 5px;border-radius:999px;corner-shape:round;background:rgba(255,255,255,.06);color:var(--dsw-alias-label-tertiary,#9a9a9e);font-size:11px;line-height:16px;white-space:nowrap}
1066
1081
  /* ═══ 右下角小浮窗(2026-11-02 第十轮起,第十一轮按用户三轮反馈定形)═════
1067
1082
  用户第一轮原话:「把这段改成小浮窗显示在对话界面右下角 然后分列显示 上面显示本会话消耗文本
1068
1083
  下一列为今日消耗 并保留所有动画 因为当前因为需要预留加载胶囊 导致数字离得太远了」。
@@ -1097,7 +1112,7 @@ window.__ModuleLoader__.load({
1097
1112
  max-width:none;
1098
1113
  background:var(--dsw-specific-sidebar-fill,rgba(27,27,28,.92));
1099
1114
  box-shadow:0 6px 18px rgba(0,0,0,.4),inset 0 0 0 1px rgba(255,255,255,.05);
1100
- color:var(--dsw-alias-label-tertiary);
1115
+ color:var(--dsw-alias-label-tertiary,#9a9a9e);
1101
1116
  -webkit-backdrop-filter:blur(10px) saturate(1.15);backdrop-filter:blur(10px) saturate(1.15);
1102
1117
  /* ⚠️ 内联写 transition 会把整条覆盖掉(transition 不支持合并),所以淡出用的
1103
1118
  opacity 过渡只能加在这条 CSS 里(2026-11-03 用户:「隐藏的时候淡出」)。 */
@@ -1129,7 +1144,7 @@ window.__ModuleLoader__.load({
1129
1144
  .balance-float--enter{animation:balance-float-emerge .28s cubic-bezier(.2,.85,.3,1) both;transform-origin:50% 100%}
1130
1145
  /* 第一行:说明文字。两行竖排后**不许再定宽**(定宽就会在窄金额时把卡片撑成两边留白),
1131
1146
  只保留不换行 + 超长省略 —— 卡片的宽度由两行里更宽的那一行决定。 */
1132
- .balance-float__label{flex:none;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:14px;color:var(--dsw-alias-label-tertiary)}
1147
+ .balance-float__label{flex:none;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:11px;line-height:14px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1133
1148
  /* 第二行:团队圆片 + 金额。圆片与金额之间 6px,整行在卡片里居中。
1134
1149
  ⚠️ **高度必须钉死成 1lh**(2026-11-02 第二十一轮:「切到正在运行的对话,加载完之后小浮窗轻微上移几格」)。
1135
1150
  卡片是 bottom 钉在输入卡片底边上的,**任何一行变高都会把整张卡片往上顶**:
@@ -1157,7 +1172,7 @@ window.__ModuleLoader__.load({
1157
1172
  ⚠️ 水平居中靠 flex(justify-content:center),不许用 translateX 硬拽。 */
1158
1173
  .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
1174
  .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)}
1175
+ .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,#9a9a9e);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)}
1161
1176
  /* 金额那一格:预留 **9ch** 兜住等待态那颗加载胶囊(2026-11-02 用户:「是不是可以让加载胶囊长一点了」)。
1162
1177
  实测 14px 字下 1ch ≈ 8.21px → 6.4ch 只有 52.5px,在 101px 宽的卡片里显得又短又胖;
1163
1178
  9ch ≈ 73.9px,正好和上面那行「本会话消耗估算」(77px)等宽对齐 ——
@@ -1436,16 +1451,16 @@ window.__ModuleLoader__.load({
1436
1451
  .balance-usage-approx{position:relative;top:-.12em;margin-right:.12em}
1437
1452
  @keyframes balance-calc-reveal{from{clip-path:inset(0 100% 0 0)}to{clip-path:inset(0 -4px 0 0)}}
1438
1453
  /* ── 消耗明细浮层:规格照抄 DSH 原生「会话统计」面板(.HS2XBG_panel/.title/.titleRule/.details)── */
1439
- .balance-usage-panel{box-sizing:border-box;position:fixed;z-index:1100;border:0;border-radius:var(--dsw-radius-lg,12px);background:var(--dsw-specific-menu,var(--dsw-alias-bg-module-platform,#242526));width:max-content;min-width:min(300px,100vw - 24px);max-width:min(440px,100vw - 24px);backdrop-filter:var(--dsw-menu-backdrop-filter,none);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent,0 8px 24px rgba(0,0,0,.32));color:var(--dsw-alias-label-secondary);cursor:default;padding:16px;font-size:12px;line-height:18px;animation:balance-stats-panel-in .12s var(--ds-ease-in-out,ease-out) both}
1440
- .balance-usage-panel__title{display:flex;justify-content:space-between;gap:16px;margin-bottom:8px;color:var(--dsw-alias-label-primary);font-weight:500}
1454
+ .balance-usage-panel{box-sizing:border-box;position:fixed;z-index:1100;border:0;border-radius:var(--dsw-radius-lg,12px);background:var(--dsw-specific-menu,var(--dsw-alias-bg-module-platform,#242526));width:max-content;min-width:min(300px,100vw - 24px);max-width:min(440px,100vw - 24px);backdrop-filter:var(--dsw-menu-backdrop-filter,none);--dsw-elevation-stroke-color:var(--dsw-alias-border-l1);box-shadow:var(--dsw-elevation-prominent,0 8px 24px rgba(0,0,0,.32));color:var(--dsw-alias-label-secondary,#b9b9bd);cursor:default;padding:16px;font-size:12px;line-height:18px;animation:balance-stats-panel-in .12s var(--ds-ease-in-out,ease-out) both}
1455
+ .balance-usage-panel__title{display:flex;justify-content:space-between;gap:16px;margin-bottom:8px;color:var(--dsw-alias-label-primary,#e6e6e8);font-weight:500}
1441
1456
  .balance-usage-panel__title--second{margin-top:16px}
1442
1457
  .balance-usage-panel__rule{border-top:.5px solid var(--dsw-alias-border-l2);margin-bottom:10px}
1443
1458
  .balance-usage-panel__value{font-variant-numeric:tabular-nums}
1444
1459
  .balance-usage-panel__label{display:inline-flex;align-items:center;gap:6px;min-width:0}
1445
1460
  .balance-usage-panel__label svg{flex:none;width:14px;height:14px}
1446
- .balance-usage-panel__details{display:grid;grid-template-columns:minmax(76px,auto) minmax(0,1fr);gap:6px 16px;margin:0;color:var(--dsw-alias-label-tertiary)}
1461
+ .balance-usage-panel__details{display:grid;grid-template-columns:minmax(76px,auto) minmax(0,1fr);gap:6px 16px;margin:0;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1447
1462
  .balance-usage-panel__details dt,.balance-usage-panel__details dd{min-width:0;margin:0}
1448
- .balance-usage-panel__details dd{color:var(--dsw-alias-label-secondary);font-variant-numeric:tabular-nums;text-align:right}
1463
+ .balance-usage-panel__details dd{color:var(--dsw-alias-label-secondary,#b9b9bd);font-variant-numeric:tabular-nums;text-align:right}
1449
1464
  /* ── 跨会话统计浮层(余额元素的子级,向右/向上展开) ── */
1450
1465
  .balance-stats-anchor{position:relative;display:flex;min-width:0;overflow:visible}
1451
1466
  .balance-stats-anchor--wide{width:100%}
@@ -1477,7 +1492,7 @@ window.__ModuleLoader__.load({
1477
1492
  .balance-stats-anchor--compact .balance-fab{position:fixed}
1478
1493
  .balance-stats-layer{box-sizing:border-box;position:fixed;inset:0;z-index:9999;display:flex;align-items:center;justify-content:center;padding:24px;background:var(--dsw-alias-bg-mask-1,rgba(0,0,0,.24));backdrop-filter:var(--dsw-mask-blur,blur(2px));-webkit-backdrop-filter:var(--dsw-mask-blur,blur(2px));animation:balance-stats-backdrop-in .16s var(--ds-ease-in-out,ease-out) both}
1479
1494
  .balance-stats-layer--closing{pointer-events:none;animation:balance-stats-backdrop-out .14s var(--ds-ease-in-out,ease-in) both}
1480
- .balance-stats-panel{box-sizing:border-box;position:relative;z-index:10000;width:min(800px,100%);max-height:100%;overflow-x:hidden;overflow-y:auto;scrollbar-gutter:stable;padding:0 0 24px;color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff));border:0;border-radius:24px;box-shadow:var(--dsw-elevation-prominent,0 14px 36px rgba(0,0,0,.24));transform-origin:center center;will-change:transform,opacity;contain:layout style;animation:balance-stats-panel-in .26s var(--ds-ease-in-out,ease-out) .04s both;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2,rgba(127,127,127,.35));--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2,rgba(127,127,127,.55))}
1495
+ .balance-stats-panel{box-sizing:border-box;position:relative;z-index:10000;width:min(800px,100%);max-height:100%;overflow-x:hidden;overflow-y:auto;scrollbar-gutter:stable;padding:0 0 24px;color:var(--dsw-alias-label-primary,#e6e6e8);background:var(--dsw-alias-bg-layer-2,var(--dsw-alias-bg-base,#fff));border:0;border-radius:24px;box-shadow:var(--dsw-elevation-prominent,0 14px 36px rgba(0,0,0,.24));transform-origin:center center;will-change:transform,opacity;contain:layout style;animation:balance-stats-panel-in .26s var(--ds-ease-in-out,ease-out) .04s both;--dsh-scrollbar-thumb:var(--dsw-alias-scrollbar-bg-l2,rgba(127,127,127,.35));--dsh-scrollbar-thumb-hover:var(--dsw-alias-scrollbar-hover-l2,rgba(127,127,127,.55))}
1481
1496
  /* 滚动条对齐 DSH 设置窗口:宽度 12px,滑块靠 transparent 边框内缩到 4px(永远不贴 24px 圆角),
1482
1497
  轨道上下各留 10px,颜色沿用 DSH 自己的 --dsh-scrollbar-thumb 变量。 */
1483
1498
  .balance-stats-panel::-webkit-scrollbar{width:12px;height:12px}
@@ -1493,8 +1508,8 @@ window.__ModuleLoader__.load({
1493
1508
  .balance-stats-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:22px 14px 12px 24px}
1494
1509
  .balance-stats-body{display:flex;flex-direction:column;min-width:0;padding:0 24px}
1495
1510
  .balance-stats-title{margin:0;font-size:16px;line-height:24px;font-weight:500}
1496
- .balance-stats-subtitle{margin:4px 0 0;color:var(--dsw-alias-label-secondary);font-size:12px}
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}
1511
+ .balance-stats-subtitle{margin:4px 0 0;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:12px}
1512
+ .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,#b9b9bd);background:transparent;font-size:22px;line-height:1;cursor:pointer}
1498
1513
  .balance-stats-close:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1499
1514
  .balance-stats-error{padding:12px;border-radius:10px;color:var(--dsw-alias-state-error-primary,#e5484d);background:rgba(229,72,77,.10)}
1500
1515
  /* 加载态:一条**实时推进**的进度条 + 已用时(2026-11-24 用户:「加载时添加一个实时的加载条」)。
@@ -1509,14 +1524,16 @@ window.__ModuleLoader__.load({
1509
1524
  底环是暗的完整圆,上面一段亮弧自己转,同时弧长从 20 → 62 → 20 呼吸,
1510
1525
  看起来是"一圈在跑"而不是"一个缺口在转"。
1511
1526
  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)}
1527
+ .balance-stats-progress{display:flex;flex-direction:column;align-items:center;gap:12px;padding:40px 12px 44px;color:var(--dsw-alias-label-secondary,#b9b9bd)}
1513
1528
  .balance-stats-spinner{display:block;width:30px;height:30px;animation:balance-stats-spin .95s linear infinite}
1514
1529
  .balance-stats-spinner__track{fill:none;stroke:var(--dsw-alias-border-l2,rgba(127,127,127,.22));stroke-width:2.5}
1515
1530
  .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
1531
  @keyframes balance-stats-spin{to{transform:rotate(360deg)}}
1517
1532
  @keyframes balance-stats-arc{0%{stroke-dasharray:20 62}50%{stroke-dasharray:62 20}100%{stroke-dasharray:20 62}}
1518
1533
  .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}
1534
+ .balance-stats-progress__elapsed{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary,#b9b9bd));font-size:11px;line-height:1}
1535
+ /* 左:概览卡 2×2;右:热力图(auto,宽度由格子数决定)。热力图一直在右上角,
1536
+ 2026-11-26 用户:「之前热力图不是在右上角的吗 要这么大干什么」。 */
1520
1537
  .balance-stats-top{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-bottom:8px}
1521
1538
  .balance-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:8px}
1522
1539
  /* 分组数为奇数时(「按模型」「时段拆分」条件渲染可能缺席),最后一个横跨整行,避免半空行 */
@@ -1525,13 +1542,13 @@ window.__ModuleLoader__.load({
1525
1542
  .balance-stats-card{display:flex;flex-direction:column;justify-content:center;min-width:0;padding:11px;border:1px solid var(--dsw-alias-border-l2,#d9d9df);border-radius:10px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.04));animation:balance-stats-card-in .2s var(--ds-ease-in-out,ease-out) both}
1526
1543
  .balance-stats-card:nth-child(2){animation-delay:.025s}.balance-stats-card:nth-child(3){animation-delay:.05s}.balance-stats-card:nth-child(4){animation-delay:.075s}
1527
1544
  @keyframes balance-stats-card-in{from{opacity:0;transform:translateY(5px)}to{opacity:1;transform:translateY(0)}}
1528
- .balance-stats-card__label{display:block;margin-bottom:6px;color:var(--dsw-alias-label-secondary);font-size:12px}
1529
- .balance-stats-card__value{display:block;overflow:hidden;color:var(--dsw-alias-label-primary);font-size:16px;font-weight:700;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}
1545
+ .balance-stats-card__label{display:block;margin-bottom:6px;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:12px}
1546
+ .balance-stats-card__value{display:block;overflow:hidden;color:var(--dsw-alias-label-primary,#e6e6e8);font-size:16px;font-weight:700;font-variant-numeric:tabular-nums;text-overflow:ellipsis;white-space:nowrap}
1530
1547
  .balance-stats-heatmap-card{box-sizing:border-box;min-width:0;padding:11px;border:1px solid var(--dsw-alias-border-l2,#d9d9df);border-radius:10px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.04));animation:balance-stats-card-in .22s var(--ds-ease-in-out,ease-out) .08s both}
1531
1548
  .balance-stats-section-title{display:flex;align-items:center;justify-content:space-between;gap:12px;margin:0 0 8px;font-size:12px;font-weight:600}
1532
- .balance-stats-legend{display:flex;align-items:center;gap:4px;color:var(--dsw-alias-label-secondary);font-size:11px;font-weight:400}
1533
- .balance-heatmap-wrap{min-width:0;overflow:hidden;padding:4px 2px 8px}
1534
- .balance-heatmap{display:grid;grid-template-rows:repeat(7,14px);grid-auto-flow:column;grid-auto-columns:14px;gap:4px;width:max-content;min-width:100%}
1549
+ .balance-stats-legend{display:flex;align-items:center;gap:4px;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:11px;font-weight:400}
1550
+ .balance-heatmap-wrap{display:flex;justify-content:center;min-width:0;overflow:hidden;padding:4px 2px 8px}
1551
+ .balance-heatmap{display:grid;grid-template-rows:repeat(7,14px);grid-auto-flow:column;grid-auto-columns:14px;gap:4px;width:max-content;min-width:0}
1535
1552
  .balance-heatmap-cell{display:block;box-sizing:border-box;width:14px;height:14px;padding:0;border:0;border-radius:3px;background:rgba(127,127,127,.10);appearance:none;transition:transform .12s var(--ds-ease-in-out,ease-out),filter .12s var(--ds-ease-in-out,ease-out)}
1536
1553
  .balance-heatmap-cell[aria-label]{cursor:default}
1537
1554
  .balance-heatmap-cell[aria-label]:hover{transform:scale(1.18);filter:brightness(1.14)}
@@ -1545,27 +1562,287 @@ window.__ModuleLoader__.load({
1545
1562
  .balance-heatmap-cell--3{background:rgba(34,197,94,.68)}
1546
1563
  .balance-heatmap-cell--4{background:rgba(22,163,74,.95)}
1547
1564
  .balance-heatmap-cell--blank{visibility:hidden}
1548
- .balance-stats-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:14px;color:var(--dsw-alias-label-secondary);font-size:11px}
1565
+ .balance-stats-footer{display:flex;align-items:center;justify-content:space-between;gap:12px;margin-top:14px;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:11px}
1549
1566
  /* 底部操作区:官方用量 / 去充值走原生平台视口(带平台凭据、无需网页登录);
1550
1567
  更多账号信息对齐 DSH 原生账号卡片,开平台首页(外部窗口,原生视口只认 usage / top-up) */
1551
1568
  .balance-stats-actions{display:flex;flex:none;align-items:center;gap:8px}
1552
- .balance-stats-link{padding:7px 12px;border:1px solid var(--dsw-alias-border-l2,#d9d9df);border-radius:8px;color:var(--dsw-alias-label-primary);text-decoration:none;white-space:nowrap;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.04))}
1569
+ .balance-stats-link{padding:7px 12px;border:1px solid var(--dsw-alias-border-l2,#d9d9df);border-radius:8px;color:var(--dsw-alias-label-primary,#e6e6e8);text-decoration:none;white-space:nowrap;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.04))}
1553
1570
  .balance-stats-link:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1554
- .balance-stats-link--primary{border-color:transparent;color:#fff;background:var(--dsw-alias-state-business-primary,#4d6bfe)}
1571
+ .balance-stats-link--primary{border-color:transparent;color:#fff;background:#4d6bfe;font-weight:600}
1555
1572
  /* ⚠️ hover 不要跟随 --dsw-alias-state-business-primary-hover(2026-10-31:
1556
1573
  「按钮颜色是不是搞反了 怎么鼠标放上去这么显眼」)。DSH 深色主题里那个变量是**提亮**的,
1557
1574
  hover 反而比静止更抢眼,读起来像"反了"。这里固定往黑里兑 12% 做加深,
1558
1575
  不依赖主题的 hover 语义;base 本身仍走主题变量,换主题整体色相跟着变。 */
1559
- .balance-stats-link--primary:hover{background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4d6bfe) 88%,#000)}
1576
+ .balance-stats-link--primary:hover{background:#3f5bef;color:#fff}
1560
1577
  .balance-stats-group{box-sizing:border-box;margin-bottom:0;padding:11px;border:1px solid var(--dsw-alias-border-l2,#d9d9df);border-radius:10px;background:var(--dsw-alias-bg-module-platform,rgba(127,127,127,.04));animation:balance-stats-card-in .22s var(--ds-ease-in-out,ease-out) both}
1561
- .balance-stats-group__title{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin:0 0 6px;color:var(--dsw-alias-label-secondary);font-size:12px;font-weight:600}
1562
- .balance-stats-group__hint{color:var(--dsw-alias-label-secondary);font-weight:400;font-variant-numeric:tabular-nums}
1578
+ .balance-stats-group__title{display:flex;align-items:baseline;justify-content:space-between;gap:8px;margin:0 0 6px;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:12px;font-weight:600}
1579
+ .balance-stats-group__hint{color:var(--dsw-alias-label-secondary,#b9b9bd);font-weight:400;font-variant-numeric:tabular-nums}
1563
1580
  .balance-stats-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px;min-width:0;padding:6px 0;font-size:12px}
1564
1581
  .balance-stats-row+.balance-stats-row{border-top:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.16))}
1565
- .balance-stats-row__name{min-width:0;overflow:hidden;color:var(--dsw-alias-label-primary);text-overflow:ellipsis;white-space:nowrap}
1566
- .balance-stats-row__value{flex:none;text-align:right;color:var(--dsw-alias-label-primary);font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
1582
+ .balance-stats-row__name{min-width:0;overflow:hidden;color:var(--dsw-alias-label-primary,#e6e6e8);text-overflow:ellipsis;white-space:nowrap}
1583
+ .balance-stats-row__value{flex:none;text-align:right;color:var(--dsw-alias-label-primary,#e6e6e8);font-weight:600;font-variant-numeric:tabular-nums;white-space:nowrap}
1567
1584
  @media(max-width:900px){.balance-stats-top{grid-template-columns:minmax(0,1fr)}.balance-stats-grid{grid-template-columns:minmax(0,1fr)}}
1568
1585
  @media(max-width:760px){.balance-stats-layer{padding:10px}}
1586
+ /* ── 时段条 / 今日消耗 的「上滑小窗」(2026-11-26)─────────────────────────
1587
+ 两个独立 popover,各自锚在点它的那一块上方:
1588
+ · .balance-footer__today → 今日各对话花了多少
1589
+ · .balance-footer__timeline* → 今日余额时间线
1590
+ 原来是整行一个热区(单击=统计面板),现在按 closest() 分流,见 rowInteractions。 */
1591
+ /* 可交互区域:hover 时轻微放大 + 泛光(2026-11-26 用户:「高亮有问题呢 不要高亮了
1592
+ 鼠标放上去的整体放大一点 然后泛光」)。原来那套蓝色描边胶囊(::after 圈 + :has 双向
1593
+ 联动 + 打开时常亮)整段撤掉,那圈蓝框就是这次说的「高亮」。
1594
+ · 今日 ¥x → .balance-footer__timeline-meta-item--today → 开「今日消耗明细」
1595
+ · 空闲 剩 3h57m → .balance-footer__timeline-meta-group → 开「余额时间线」
1596
+ · 刻度条 → .balance-footer__timeline-track → 开「余额时间线」 */
1597
+ /* 文字行和刻度条是两种东西,hover 反馈也要分开给(2026-11-26 用户:
1598
+ 「文字的话 就文字高亮 不要显示胶囊圈起来 很奇怪」)。
1599
+ ⚠️ 文字上绝不能加 border-radius + box-shadow —— 那会沿文字外框画出一圈胶囊光晕,
1600
+ 看着像给「空闲 剩 3h57m」套了个框。 */
1601
+ .balance-footer__timeline-meta-item--today,
1602
+ .balance-footer__timeline-meta-group{transition:color .16s ease}
1603
+ /* ⚠️ hover 时 meta 行要临时放开裁剪:刻度条 scale(1.04) 会顶出 meta 的 overflow:hidden
1604
+ (meta-group 在 meta 里面)。非 hover 时仍然 hidden —— 那才是「不压到金额上」要防的。 */
1605
+ .balance-footer__timeline:hover .balance-footer__timeline-meta,
1606
+ .balance-footer__timeline:has(.balance-footer__today--active) .balance-footer__timeline-meta,
1607
+ .balance-footer__timeline:has(.balance-footer__timeline--active) .balance-footer__timeline-meta{overflow:visible}
1608
+ /* 不放大,改成**整块一个胶囊底**(2026-11-27 用户:「算了 不要放大了 鼠标放上去显示一个整体的胶囊吧」)。
1609
+ 「今日 ¥x」「空闲 剩 8h23m」「时段条」三行现在开的是同一个面板,所以它们是一个入口,
1610
+ 鼠标落在任意一块、或面板开着时,同一层圆角底把三行一起罩住。
1611
+ ⚠️ 用 ::before 绝对定位画底,不加 padding —— 加内边距会改变这块的实际尺寸,
1612
+ 而它是 flex 里按剩余宽度伸缩的,一改就把上面的金额行挤动。
1613
+ ⚠️ z-index:-1 + isolation:isolate:底色落在内容之下、卡片之上,
1614
+ 不会盖住文字,也不会穿透到侧栏背景后面。
1615
+ ⚠️ 只有底色,没有 box-shadow 光晕 —— 沿文字外框画光会自动成一圈胶囊圈,
1616
+ 那条 2026-11-26 已经否定过一次。 */
1617
+ .balance-footer__timeline{isolation:isolate}
1618
+ .balance-footer__timeline::before{
1619
+ content:"";position:absolute;inset:-3px -4px;z-index:-1;
1620
+ border-radius:11px;background:transparent;pointer-events:none;
1621
+ transition:background-color .16s ease}
1622
+ .balance-footer__timeline:hover::before,
1623
+ .balance-footer__timeline:has(.balance-footer__today--active)::before,
1624
+ .balance-footer__timeline:has(.balance-footer__timeline--active)::before{
1625
+ background:rgba(127,127,127,.13)}
1626
+ /* 可点的光标提示 */
1627
+ .balance-footer__timeline-meta-item--today,
1628
+ .balance-footer__timeline-meta-group{cursor:pointer;outline:none}
1629
+ .balance-footer__timeline-meta-item--today:focus,
1630
+ .balance-footer__timeline-meta-item--today:focus-visible{cursor:pointer;outline:none}
1631
+ @media(prefers-reduced-motion:reduce){
1632
+ .balance-footer__timeline-meta-item--today,
1633
+ .balance-footer__timeline-meta-group{transition:none}
1634
+ .balance-footer__timeline-track{transition:none}
1635
+ .balance-footer__timeline::before{transition:none}}
1636
+ .balance-pop{box-sizing:border-box;position:fixed;z-index:10050;display:flex;flex-direction:column;
1637
+ width:min(330px,calc(100vw - 20px));
1638
+ /* 高度上限放宽(2026-11-27 用户:「可以长很多 太短显示不全」):原来是 60vh/420px,
1639
+ 时段表带图 + 明细两层,会话一多就被裁在卡里、只剩滚动条。现在放到 80vh/640px,
1640
+ 大多数情况一屏能看全;真超出还是走 body 内滚动,不会顶出视口。 */
1641
+ max-height:min(80vh,640px);overflow:hidden;padding:0;
1642
+ border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));border-radius:12px;
1643
+ background:var(--dsw-alias-bg-layer-1,#232324);box-shadow:0 14px 36px rgba(0,0,0,.45);
1644
+ animation:balance-pop-in .17s cubic-bezier(.22,.72,.28,1) both}
1645
+ @keyframes balance-pop-in{from{opacity:0;transform:translateY(9px) scale(.975)}to{opacity:1;transform:none}}
1646
+ @keyframes balance-pop-out{from{opacity:1;transform:none}to{opacity:0;transform:translateY(6px) scale(.985)}}
1647
+ .balance-pop--closing{pointer-events:none;animation:balance-pop-out .13s ease-in both}
1648
+ /* 小三角指回被点的那一块;左右位置由 JS 写进 --balance-pop-arrow */
1649
+ .balance-pop::after{content:"";position:absolute;left:var(--balance-pop-arrow,50%);bottom:-6px;width:11px;height:11px;
1650
+ margin-left:-5.5px;background:inherit;border-right:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));
1651
+ border-bottom:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));transform:rotate(45deg)}
1652
+ /* 翻到 anchor 下方时三角翻个面(改上下两条边,比旋转 180° 干净) */
1653
+ .balance-pop--below::after{bottom:auto;top:-6px;border-right:0;border-bottom:0;
1654
+ border-left:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));
1655
+ border-top:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22))}
1656
+ .balance-pop__head{display:flex;flex:none;align-items:center;justify-content:space-between;gap:10px;
1657
+ padding:11px 12px 8px 14px}
1658
+ .balance-pop__title{margin:0;font-size:12.5px;font-weight:600;line-height:16px;color:var(--dsw-alias-label-primary,#e6e6e8)}
1659
+ /* 副标题提亮一档:最新一行金额是这个浮窗最常看的数字,
1660
+ 原来和「3 个时段有消耗」同一个灰度,看不出主次。 */
1661
+ .balance-pop__sub{margin:2px 0 0;font-size:11.5px;line-height:15px;color:var(--dsw-alias-label-secondary,#b9b9bd);
1662
+ font-variant-numeric:tabular-nums}
1663
+ .balance-pop__sub-amount{font-size:12.5px;font-weight:600;letter-spacing:.1px;color:var(--dsw-alias-label-primary,#e6e6e8);font-variant-numeric:tabular-nums}
1664
+ /* 右上角控件容器:和关闭按钮平齐、靠右聚在一起 */
1665
+ .balance-pop__head-extra{flex:none;margin-left:auto;display:inline-flex;align-items:center}
1666
+ /* 尺寸放大一档(2026-11-27 用户:「太小了 改大一点」)。
1667
+ 22px 高 + 16×9 滑块在这张卡里看着像一个标点,
1668
+ 现在 26px 高 + 24×13 滑块,和右侧关闭按钮同高。 */
1669
+ .balance-pop__switch{flex:none;display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px 0 9px;
1670
+ border:0;border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary,#b9b9bd);
1671
+ font-size:11.5px;line-height:1;cursor:pointer}
1672
+ /* 悬停底色也跟着走胶囊:方框配胶囊滑块看着就是两个形状拼在一起 */
1673
+ .balance-pop__switch:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
1674
+ /* 26×14 滑块 + 12px 圆点:上下各留 1px。之前 13px 高、圆点 10px、
1675
+ 上下各 1.5px,在小尺寸下抗锯齿会把下边抹得更重,看着就像圆点偏下
1676
+ (2026-11-27 用户:「白点怎么靠下」)。现在用整数像素对齐。 */
1677
+ .balance-pop__switch-dot{position:relative;flex:none;width:26px;height:14px;border-radius:999px;
1678
+ background:rgba(127,127,127,.4);transition:background .16s ease}
1679
+ .balance-pop__switch-dot::after{content:"";position:absolute;top:1px;left:1px;width:12px;height:12px;border-radius:50%;
1680
+ background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.35);
1681
+ transition:transform .16s cubic-bezier(.4,0,.2,1)}
1682
+ .balance-pop__switch--on{color:var(--dsw-alias-label-primary,#e6e6e8)}
1683
+ .balance-pop__switch--on .balance-pop__switch-dot{background:var(--dsw-alias-state-success-primary,#22c55e)}
1684
+ .balance-pop__switch--on .balance-pop__switch-dot::after{transform:translateX(12px)}
1685
+ @media (prefers-reduced-motion:reduce){
1686
+ .balance-pop__switch-dot,.balance-pop__switch-dot::after{transition:none}
1687
+ }
1688
+ .balance-pop__close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;
1689
+ padding:0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#b9b9bd);
1690
+ font-size:15px;line-height:1;cursor:pointer}
1691
+ .balance-pop__close:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
1692
+ /* 时间线浮窗单独加宽(2026-11-26 用户:「左右拉长一点」)。330 是明细列表的宽度,别一起改。 */
1693
+ .balance-pop--wide{width:min(498px,calc(100vw - 20px))}
1694
+ /* 图 + 明细合并后内容明显变高,会话一多会把卡片顶出视口 —— 限高并让 body 自己滚 */
1695
+ .balance-pop__body{flex:1 1 auto;min-height:0;max-height:min(60vh,460px);overflow-y:auto;padding:0 8px 8px}
1696
+ .balance-pop__body::-webkit-scrollbar{width:9px}
1697
+ .balance-pop__body::-webkit-scrollbar-thumb{border:3px solid transparent;background-clip:padding-box;
1698
+ border-radius:5px;background-color:rgba(127,127,127,.35)}
1699
+ /* 会话明细一行:名字(可省略)+ 金额 */
1700
+ .balance-pop__row{display:flex;align-items:baseline;gap:8px;min-width:0;padding:6px 6px;border-radius:7px;font-size:12px}
1701
+ .balance-pop__row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.08))}
1702
+ .balance-pop__name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
1703
+ color:var(--dsw-alias-label-primary,#e6e6e8)}
1704
+ .balance-pop__meta{flex:none;color:var(--dsw-alias-label-tertiary,#9a9a9e);font-size:10.5px;font-variant-numeric:tabular-nums}
1705
+ .balance-pop__amount{flex:none;min-width:62px;text-align:right;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8);
1706
+ font-variant-numeric:tabular-nums}
1707
+ /* 会话行前的小色条:按金额排序后给个视觉锚点 */
1708
+ .balance-pop__swatch{flex:none;width:3px;height:11px;border-radius:2px;background:rgba(77,107,254,.85)}
1709
+ .balance-pop__swatch--plugin{background:rgba(127,127,127,.55)}
1710
+ /* 网页工具费那一行的色块:与同步费的蓝区分开 */
1711
+ .balance-pop__swatch--web{background:var(--dsw-alias-state-warning-primary,#d97706)}
1712
+ .balance-pop__empty{padding:18px 12px;text-align:center;font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1713
+ /* 时间线曲线 */
1714
+ /* 图与明细之间的分隔线(两个浮窗合并后的接缝) */
1715
+ .balance-pop__hr{height:.5px;margin:8px 0 6px;background:var(--dsw-alias-border-l1,rgba(127,127,127,.16))}
1716
+ /* 合并面板里那句「N 个会话 · 合计 …(会话 … + 同步 …)」,
1717
+ 用来解释累计与会话合计的差额,别让它贴着上一行图 */
1718
+ .balance-pop__sub--inline{margin:0 0 5px;padding:0 2px;font-size:11px;line-height:15px;color:var(--dsw-alias-label-tertiary,#9a9a9e);font-variant-numeric:tabular-nums}
1719
+ .balance-pop__chart{position:relative;padding:2px 2px 0}
1720
+ .balance-pop__svg{display:block;width:100%;height:auto;overflow:visible}
1721
+ /* 图表要能接键盘(方向键逐分钟),所以挂了 tabIndex —— 于是浏览器给 SVG 画了一圈
1722
+ 焦点框,在深色卡片上是整整一道白边(2026-11-27 用户截图「怎么回事」)。
1723
+ 键盘用户另有可见反馈:胶囊本身会跟着动,不需要这圈 outline。 */
1724
+ .balance-pop__svg:focus,.balance-pop__svg:focus-visible{outline:none}
1725
+ /* 曲线语言(2026-11-26 用户给了参考图:绿线 + 虚分隔 + 右侧金额,
1726
+ 不要红绿色块带、不要图例)。 */
1727
+ .balance-pop__axis{font-size:9px;fill:var(--dsw-alias-label-tertiary,#9a9a9e);font-variant-numeric:tabular-nums}
1728
+ /* 纵轴金额刻度提亮(2026-11-27 用户:「顶部的刻度是不是太不明显了」)。
1729
+ 原来 9.5px + label-secondary,在深色色带上基本涂开;
1730
+ 现在提到 10.5px、primary 色、加一档字重,数字才读得出来。 */
1731
+ /* ⚠️ stroke-width 不能太粗:11px 字的笔画才 1px 宽,描边沿轮廓内外各扩一半,
1732
+ 3px 描边会把字形内部也填满 —— 整个「¥15」变成一块黑瘩瘩,
1733
+ 在深色背景上看上去就是「消失了」(2026-11-27 用户:「bug了 怎么消失了」)。
1734
+ 现在 2px:比原来的 2.4px 还细一点,但描边色从 .55 提到 .82,对比反而更强。 */
1735
+ .balance-pop__axis--value{fill:#ffffff;font-size:11px;font-weight:600;letter-spacing:.2px;
1736
+ paint-order:stroke;stroke:rgba(0,0,0,.82);stroke-width:2px;stroke-linejoin:round}
1737
+ /* 峰谷切换处的虚竖线(09:00 / 12:00 / 14:00 / 18:00) */
1738
+ /* 峰谷底色:高峰暖橙、空闲淡绿。只给 fill、不给 opacity ——
1739
+ 色带铺在面积图下面,opacity 会连曲线一起压暗。 */
1740
+
1741
+ .balance-pop__band--peak{fill:rgba(226,152,88,.105)}
1742
+ .balance-pop__band--offpeak{fill:rgba(46,168,118,.075)}
1743
+ .balance-pop__grid{stroke:rgba(255,255,255,.22);stroke-width:1}
1744
+ /* 横向金额刻度线:比竖向分界线淡一档,免得和峰谷分界抢注意力 */
1745
+ .balance-pop__grid-h{stroke:rgba(255,255,255,.09);stroke-width:1;stroke-dasharray:2 4}
1746
+ /* 曲线下方极淡的绿雾,别做成实心块 */
1747
+ .balance-pop__area{fill:rgba(34,197,94,.10)}
1748
+ /* ── 打开时**不做**入场动画(2026-11-27 用户:「打开的时候不要动画了」)──
1749
+ 要的是 y 轴档位变化时的缩放:¥1 → ¥2 → ¥5,整张图从旧高度展开到新高度,
1750
+ 看的是"刻度换档"这个动作,不是"窗口弹出来"。
1751
+ 做法:金额上界变了就给绘图组换 key 重挂,并从旧比例 scaleY 展开到 1。
1752
+ --balance-zfrom 由上一档 / 这一档算出来(¥1→¥2 就是 .5,¥2→¥5 是 .4)。 */
1753
+ /* y 轴数字换档淡入:位置直接到位(文字不能 scaleY,会变形),只淡入。 */
1754
+ /* 换档时数字从上方滚下来(而不是干巴巴淡入)。
1755
+ 用 both 收尾在 transform:none:常驻节点留下 transform 会让小字号发虚。
1756
+ 数值本身不变档位也不换 key,只在 targetMaxY 变时重挂一次。 */
1757
+ @media (prefers-reduced-motion:reduce){
1758
+ .balance-pop__tip{transition:none}
1759
+ }
1760
+ @keyframes balance-pop-ylabelroll{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:none}}
1761
+ /* ⚠️ 动画**不能**写在基础类上。写在上面等于「每次节点挂载都自动播一遍」,
1762
+ 而 y 轴数字每次打开浮窗都是新挂载 → 一打开就滚一下
1763
+ (2026-11-27 用户:「打开浮窗的时候 这个数字为什么也会动 这个数字的动画
1764
+ 只在缩放的时候有」)。现在只有档位真的变了才挂 --anim。 */
1765
+ .balance-pop__axis--value{animation:none}
1766
+ .balance-pop__axis--value--anim{animation:balance-pop-ylabelroll .34s cubic-bezier(.33,0,.2,1) both}
1767
+ @media (prefers-reduced-motion:reduce){
1768
+ .balance-pop__axis--value--anim{animation:none}
1769
+ }
1770
+ /* 换档不做 transform:会把描边、圆点一起拉变形。
1771
+ 改成逐帧插值纵轴上限(见 animMaxY):坐标平滑变化、形状不变
1772
+ (2026-11-27 用户:「我说的压只是效果 不是真的东西都变形了」)。 */
1773
+ @media (prefers-reduced-motion:reduce){
1774
+ .balance-pop__plot{animation:none}
1775
+ }
1776
+ .balance-pop__line{fill:none;stroke:var(--dsw-alias-state-success-primary,#22c55e);stroke-width:1.8;
1777
+ stroke-linejoin:round;stroke-linecap:round}
1778
+ /* 当前时刻:白竖线 + 绿点 */
1779
+ /* 悬停:一条细竖线 + 一个白点,跟着鼠标走 */
1780
+ .balance-pop__hover-line{stroke:rgba(255,255,255,.42);stroke-width:1;stroke-dasharray:2 2;pointer-events:none}
1781
+ /* 5 分钟采样点:线色的低调版本(不用 opacity —— 色带那边踩过,opacity 会连带影响兄弟节点观感) */
1782
+ .balance-pop__hover-dot{fill:#fff;stroke:var(--dsw-alias-bg-layer-1,#232324);stroke-width:1.6;pointer-events:none}
1783
+ /* 悬停提示:绝对定位在图表容器里,translateX(-50%) 居中,两端由 JS 夹回来 */
1784
+ /* 两行(2026-11-26 用户:「这个第二行显示」):上行累计、下行本小时。
1785
+ 两行都做 space-between,金额那一列自然对齐;min-width 让短的那行不至于把数字拉回去。 */
1786
+ .balance-pop__tip{position:absolute;top:1px;transform:translateX(-50%);display:inline-flex;flex-direction:column;align-items:stretch;gap:0;padding:3px 8px;border-radius:6px;background:rgba(18,18,20,.93);border:1px solid rgba(255,255,255,.10);box-shadow:0 4px 14px rgba(0,0,0,.45);font-size:10.5px;line-height:1.55;white-space:nowrap;pointer-events:none;z-index:2;min-width:96px;
1787
+ /* 宽度真正自适应内容(原来 128px 下限拿掉,短内容也能收紧) */
1788
+ width:max-content;
1789
+ color:var(--dsw-alias-label-primary,#e6e6e8);
1790
+ /* ⚠️ transition-property 必须**常驻**,只让 duration 走变量。
1791
+ 之前是 inline 整串 transition 在 none 和长串之间切换,同一帧里
1792
+ transition-property 变了、left 也变了,浏览器经常**不启动过渡** ——
1793
+ 表现就是「没动画」(2026-11-27 用户:「没动画啊 你加在哪了」)。
1794
+ 现在 property 不动、时长由 --tip-dur 控制,跟手写 0ms 即可。 */
1795
+ /* 宽度不做过渡(2026-11-27 用户:「就自适应长短吧 不要动画了」)。
1796
+ 之前尝试过 interpolate-size 与 FLIP,前者在本机不生效、后者会与
1797
+ 「-100%」随宽度变化叠加成中途抽动,已全部撤掉。
1798
+ 位秶过渡照旧:跟手 0ms,归位按距离。 */
1799
+ transition-property:left,top,transform;
1800
+ transition-duration:var(--tip-dur,0ms);
1801
+ transition-timing-function:cubic-bezier(.4,0,.2,1)}
1802
+ .balance-pop__tip-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
1803
+ .balance-pop__tip-left{flex:none;display:inline-flex;align-items:baseline;gap:5px}
1804
+ .balance-pop__tip-tag{flex:none;font-size:10px;color:var(--dsw-alias-label-tertiary,#9a9aa0)}
1805
+ .balance-pop__tip-time{color:var(--dsw-alias-label-tertiary,#9a9aa0);font-variant-numeric:tabular-nums}
1806
+ .balance-pop__tip-cost{font-variant-numeric:tabular-nums;font-weight:600}
1807
+ /* 第三格:鼠标所在那个小时的消耗合计(2026-11-26 用户:「黑胶囊里面加一个当前小时的总消耗」)。
1808
+ 三级色 + 更细的分隔,别和左边的累计抢注意力。 */
1809
+ .balance-pop__tip-hour{color:var(--dsw-alias-label-tertiary,#9a9aa0);font-weight:400}
1810
+ .balance-pop__tip-hourcost{font-variant-numeric:tabular-nums;font-weight:600;color:var(--dsw-alias-label-secondary,#c9c9cd)}
1811
+ /* 还没到的时段:金额位换成「暂未产生消耗」。
1812
+ 弱化到 tertiary 且不加粗 —— 它是一句说明,不是一笔钱(2026-11-26 用户:
1813
+ 「鼠标移到没到的时间点上显示 0 暂未产生消耗」)。
1814
+ white-space 已经是 nowrap,这里只用字号压一点点,免得把胶囊撑太宽。 */
1815
+ /* ⚠️ 字号必须和正常态一致(都 10.5px)。原来 pending 写了 10px,而
1816
+ 归位瞬间第二行从「暂未产生消耗」切回「¥x.xx」,行高从 15.5 变回 16.3,
1817
+ 两行相加胶囊矮/高 1.5px —— 看上去就是「自动归位时窗口高度闪一下」
1818
+ (2026-11-27 用户)。要缩小字就整体缩,不能只缩一种状态。 */
1819
+ .balance-pop__tip-hourcost--pending{font-weight:400;color:var(--dsw-alias-label-tertiary,#9a9aa0)}
1820
+ /* 位数变化时「¥ 被顶出去」(2026-11-26 用户:「我的意思是数字给¥顶到左边 有动画
1821
+ 不是这种整体滑动」)。
1822
+ ⚠️ 金额列是右对齐的,所以位数一变,**右缘固定、左缘(¥)瞬间挪位**——
1823
+ 要平滑的正是这个左缘。整体 translateX 做不到(右缘会跟着抖),
1824
+ 得用 scaleX 并且把原点钉在右缘:压缩态的左缘停在旧位置,展开到 1 就是新位置。
1825
+ ⚠️ 动画里**绝对不能有 opacity** —— 之前 from 带 opacity:.35,数字先变淡再变实,
1826
+ 看着就是闪(用户:「变的时候 不要闪啊 为什么数字会闪啊」)。全程不透明。
1827
+ 触发条件仍然是「整数位数变化」(见 JSX key 里的 indexOf(".")),同位数内静默换值。 */
1828
+ .balance-pop__tip-cost,
1829
+ .balance-pop__tip-hourcost{display:inline-block;transform-origin:right center;animation:balance-pop-tip-push .16s cubic-bezier(.22,.72,.28,1) both}
1830
+ @keyframes balance-pop-tip-push{from{transform:scaleX(.9)}to{transform:scaleX(1)}}
1831
+ @media(prefers-reduced-motion:reduce){.balance-pop__tip-cost,.balance-pop__tip-hourcost{animation:none}}
1832
+ /* 当前时刻的白条:两层 drop-shadow 做泛光(近处锐、远处散)。
1833
+ 2026-11-26 用户:「白条可以添加泛光效果」。 */
1834
+ .balance-pop__now{stroke:rgba(255,255,255,.92);stroke-width:1.4;filter:drop-shadow(0 0 2.5px rgba(255,255,255,.8)) drop-shadow(0 0 7px rgba(255,255,255,.35))}
1835
+ .balance-pop__dot{fill:var(--dsw-alias-state-success-primary,#22c55e);
1836
+ stroke:var(--dsw-alias-bg-layer-1,#232324);stroke-width:1.4}
1837
+ /* 此刻绿点的外圈:空心 + **泛光**(2026-11-27 用户:「泛光的」)。
1838
+ 写法照「此刻白线」那条来:两层 drop-shadow,一层贴边描轮廓、一层大半径铺光晕,
1839
+ 才会看着像「亮着」而不是一条灰圈。 */
1840
+ /* 白色泛光环(2026-11-27 用户:「光圈改成白色」)。和「此刻白线」同色系,
1841
+ 绿点本身已经是绿的,圈再绿就分不出层次。 */
1842
+ .balance-pop__dot-ring{fill:none;stroke:rgba(255,255,255,.9);
1843
+ stroke-width:1.15;stroke-opacity:.95;pointer-events:none;
1844
+ filter:drop-shadow(0 0 2.5px rgba(255,255,255,.75)) drop-shadow(0 0 7px rgba(255,255,255,.34))}
1845
+ @media(prefers-reduced-motion:reduce){.balance-pop,.balance-pop--closing{animation:none}}
1569
1846
  @media(prefers-reduced-motion:reduce){.balance-stats-panel,.balance-stats-panel--closing,.balance-stats-layer,.balance-stats-layer--closing,.balance-stats-card,.balance-stats-group,.balance-stats-heatmap-card{animation:none}.balance-heatmap-cell{transition:none}}
1570
1847
  /* ── 展开态底部一行:[设置齿轮][余额胶囊],余额在设置右边 ──
1571
1848
  全部使用稳定锚点,不依赖 CSS Modules hash 类名(DSH 升级后仍有效):
@@ -1590,18 +1867,27 @@ window.__ModuleLoader__.load({
1590
1867
  变量缺失时仍然可读,不会变成透明文字。开关/按钮的真圆角要显式 corner-shape:round,
1591
1868
  否则会被 DSH 主题的全局 superellipse 画成方圆角。 */
1592
1869
  .balance-settings{box-sizing:border-box;display:flex;flex-direction:column;width:100%;margin:0;padding:18px 20px;border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));border-radius:var(--dsw-radius-lg,16px);background:var(--dsw-alias-bg-module-platform,transparent)}
1870
+ /* 设置卡片里所有带 padding 的块统一 border-box。
1871
+ DSH 页面**没有**全局 border-box(而 .balance-settings 自己写了),
1872
+ 而这些块是 flex column 的子项,被 stretch 拉到父宽之后再加 padding,
1873
+ content-box 下左右各多出 24px —— 直接溢出卡片,压在相邻行上,
1874
+ 看上去就像「显示在最上层」(2026-11-27 用户:「我说的最顶层时显示在最上层」)。 */
1875
+ .balance-settings__head,.balance-settings__body,.balance-settings__group,
1876
+ .balance-settings__notice,.balance-settings__newcue,.balance-settings__group-note,
1877
+ .balance-settings__row,.balance-settings__below,.balance-settings__actions,
1878
+ .balance-settings__sync-grid,.balance-settings__label,.balance-settings__progress{box-sizing:border-box}
1593
1879
  .balance-settings__head{display:flex;align-items:baseline;justify-content:space-between;gap:12px}
1594
- .balance-settings__title{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary)}
1595
- .balance-settings__version{font-size:12px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}
1596
- .balance-settings__desc{margin:4px 0 0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary)}
1880
+ .balance-settings__title{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8)}
1881
+ .balance-settings__version{font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e);font-variant-numeric:tabular-nums}
1882
+ .balance-settings__desc{margin:4px 0 0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1597
1883
  .balance-settings__group{margin:18px 0 0;padding:14px 0 0;border-top:.5px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22))}
1598
1884
  /* 第一个分组紧接折叠头,顶线和额外内边距都去掉,避免双线 */
1599
1885
  .balance-settings__body > .balance-settings__group:first-child{margin-top:0;padding-top:0;border-top:0}
1600
1886
  /* 分组标题:左侧一道 3px 品牌色竖条做视觉分隔,字号收到 11px 并加字距,比正文弱、比说明强,避免和行内容糊在一起 */
1601
- .balance-settings__group-title{display:flex;align-items:center;gap:7px;margin:0 0 4px;font-size:11px;font-weight:600;letter-spacing:.3px;color:var(--dsw-alias-label-secondary)}
1887
+ .balance-settings__group-title{display:flex;align-items:center;gap:7px;margin:0 0 4px;font-size:11px;font-weight:600;letter-spacing:.3px;color:var(--dsw-alias-label-secondary,#b9b9bd)}
1602
1888
  /* 顶部告示条:设置页最前面的一条范围声明。底色/边框比分组说明再重一档,
1603
1889
  文字提到 primary,整块在深色背景里第一个跳出来。 */
1604
- .balance-settings__notice{display:flex;align-items:flex-start;gap:8px;margin:0 0 14px;padding:10px 12px;border-radius:var(--dsw-radius-md,8px);border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 34%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 13%,transparent);font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-primary)}
1890
+ .balance-settings__notice{display:flex;align-items:flex-start;gap:8px;margin:0 0 14px;padding:10px 12px;border-radius:var(--dsw-radius-md,8px);border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 26%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 10%,transparent);font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-primary,#e6e6e8)}
1605
1891
  .balance-settings__notice-icon{flex:none;display:block;margin-top:1px;color:var(--dsw-alias-brand-primary,#4d6bfe)}
1606
1892
  .balance-settings__notice-text{min-width:0}
1607
1893
  /* 「本版新增」横幅:不依赖侧栏入口也能知道有新功能。
@@ -1609,8 +1895,8 @@ window.__ModuleLoader__.load({
1609
1895
  或者从 DSH「插件」页直接进来时,这是唯一的提示(2026-10-31 用户问
1610
1896
  「如果用户没打开这个设置页面入口 怎么提示用户有新功能」)。
1611
1897
  用品牌色实心胶囊当引子 + 一行白字说明 + 右侧跳转按钮,视觉上比告示条更"新"。 */
1612
- .balance-settings__newcue{display:flex;align-items:center;gap:9px;margin:0 0 12px;padding:9px 12px;border-radius:var(--dsw-radius-md,8px);border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 40%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 12%,transparent);font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-primary)}
1613
- .balance-settings__newcue-badge{flex:none;padding:1.5px 6px;border-radius:999px;corner-shape:round;background:var(--dsw-alias-brand-primary,#4d6bfe);color:var(--dsw-alias-label-primary-foreground,#fff);font-size:9.5px;line-height:12px;font-weight:700;letter-spacing:.4px}
1898
+ .balance-settings__newcue{display:flex;align-items:center;gap:9px;margin:0 0 12px;padding:9px 12px;border-radius:var(--dsw-radius-md,8px);border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 26%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 10%,transparent);font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-primary,#e6e6e8)}
1899
+ .balance-settings__newcue-badge{flex:none;padding:1.5px 6px;border-radius:999px;corner-shape:round;background:#4d6bfe;color:var(--dsw-alias-label-primary-foreground,#fff);font-size:9.5px;line-height:12px;font-weight:700;letter-spacing:.4px}
1614
1900
  .balance-settings__newcue-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1615
1901
  .balance-settings__newcue-btn{flex:none;padding:2px 9px;border-radius:999px;corner-shape:round;border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 45%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 18%,transparent);color:var(--dsw-alias-brand-primary,#4d6bfe);font:inherit;font-size:11.5px;line-height:16px;cursor:pointer}
1616
1902
  .balance-settings__newcue-btn:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 28%,transparent)}
@@ -1637,14 +1923,14 @@ window.__ModuleLoader__.load({
1637
1923
  @media (prefers-reduced-motion:reduce){.balance-settings__row--flash::before{display:none}}
1638
1924
  /* 分组说明条:不是灰小字,而是带图标的淡蓝提示条——要一眼看见「仅支持 DeepSeek Harness」。
1639
1925
  底色用品牌色 10%、边框 26%,文字提到 secondary;图标跟文字同色。 */
1640
- .balance-settings__group-note{display:flex;align-items:flex-start;gap:7px;margin:3px 0 5px;padding:8px 10px;border-radius:var(--dsw-radius-md,8px);border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 26%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 10%,transparent);font-size:12px;line-height:17px;color:var(--dsw-alias-label-secondary)}
1926
+ .balance-settings__group-note{display:flex;align-items:flex-start;gap:7px;margin:3px 0 5px;padding:8px 10px;border-radius:var(--dsw-radius-md,8px);border:.5px solid color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 26%,transparent);background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 10%,transparent);font-size:12px;line-height:17px;color:var(--dsw-alias-label-secondary,#b9b9bd)}
1641
1927
  .balance-settings__group-note-icon{flex:none;display:block;margin-top:.5px;color:var(--dsw-alias-brand-primary,#4d6bfe);opacity:.9}
1642
1928
  .balance-settings__group-note-text{min-width:0}
1643
1929
  .balance-settings__group-title::before{content:"";flex:none;width:3px;height:11px;border-radius:1px;corner-shape:round;background:var(--dsw-alias-brand-primary,#4d6bfe);opacity:.75}
1644
1930
  .balance-settings__head-btn{display:flex;align-items:center;justify-content:space-between;gap:12px;width:100%;box-sizing:border-box;padding:0;border:0;background:0 0;font:inherit;text-align:left;cursor:pointer;color:inherit}
1645
1931
  .balance-settings__head-btn:focus-visible{outline:var(--dsw-focus-ring-width,2px) solid var(--dsw-focus-ring-color,var(--dsw-alias-state-business-primary));outline-offset:2px;border-radius:var(--dsw-radius-sm,6px)}
1646
1932
  .balance-settings__head-text{flex:1;min-width:0}
1647
- .balance-settings__chevron{flex:none;color:var(--dsw-alias-label-tertiary);transition:transform .16s ease}
1933
+ .balance-settings__chevron{flex:none;color:var(--dsw-alias-label-tertiary,#9a9a9e);transition:transform .16s ease}
1648
1934
  .balance-settings[data-open="true"] .balance-settings__chevron{transform:rotate(180deg)}
1649
1935
  .balance-settings__body{margin:10px 0 0;padding:10px 0 0;border-top:.5px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22))}
1650
1936
  /* 标签行:文字 + NEW 徽标并排 */
@@ -1665,32 +1951,101 @@ window.__ModuleLoader__.load({
1665
1951
  @media (prefers-reduced-motion:reduce){.balance-settings__new-badge{animation:none;box-shadow:0 0 5px color-mix(in srgb,#4d6bfe 28%,transparent)}}
1666
1952
  .balance-settings__row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:11px 0}
1667
1953
  /* 行与行之间用半像素淡线分开,避免几行文字堆成一片 */
1954
+ /* row 下方的全宽内容(节假日同步进度条)。必须渲染在 row 外面:
1955
+ 塞进 .balance-settings__control 里时,control 是 flex:none、宽度由内容决定,
1956
+ 进度条一出现就把它撑宽,左边 flex:1 的说明文字跟着换行重排
1957
+ (2026-11-27 用户:「这个进度条换个地方 要不然导致左边的字一直在动」)。 */
1958
+ .balance-settings__below{padding:0 0 11px}
1959
+ /* 中间插了 below 之后,相邻兄弟选择器断了一节,补回来 */
1960
+ .balance-settings__below + .balance-settings__row{border-top:.5px solid var(--dsw-alias-border-l1,rgba(127,127,127,.12))}
1668
1961
  .balance-settings__row + .balance-settings__row{border-top:.5px solid var(--dsw-alias-border-l1,rgba(127,127,127,.12))}
1669
1962
  .balance-settings__label{display:flex;flex-direction:column;gap:3px;min-width:0}
1670
- .balance-settings__label-text{font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary)}
1671
- .balance-settings__hint{font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary)}
1963
+ .balance-settings__label-text{font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary,#e6e6e8)}
1964
+ /* 注意提示(橙)。配色要弱一档:
1965
+ 底色从 12% 降到 6%、边框 34% → 20%、图标也从原色降到 80%。
1966
+ 2026-11-27 用户:「这个提示的颜色改成啥了 饱和度这么高」。
1967
+ 原因是上一轮把半透明底改成实心底(为了不透出下层),
1968
+ 12% 混在深色底上原本看着很淡,变实心后就是一块橙板。 */
1969
+ /* 底色直接去掉(改成 6% 透明橙,实际就是几乎看不出来)。
1970
+ 2026-11-27 用户第二次:「不还是一样吗」—— 6% 橙混进实心深色底,
1971
+ 算出来是 #2a2118,在深灰背景上仍然是明显的一块棕橙。
1972
+ 只要底色是不透明的,再少的橙也是「一块色卡」;要弱就得让它半透明。
1973
+ 这里下层就是卡片自己的底,透出去不会压到别的元素,和 notice 那条不一样。 */
1974
+ /* 提醒类提示也用和普通提示完全相同的配色。
1975
+ 2026-11-27 用户拿一条普通提示截图说「改成这种颜色」。
1976
+ 之前为了「注意」需要单独给橙色(#d97706),两轮降饱和都被嫌显眼——
1977
+ 底色不透明时再少的橙也是一块色卡,改成半透明又和整个卡片不搭。
1978
+ 现在彻底同色,区别只留在文字内容上。 */
1979
+
1980
+ /* 「注意」提示用橙色。
1981
+ 2026-11-27 用户:「这个之前的颜色恢复回去」。
1982
+ 恢复的是最初那一套:**半透明**的 12% 橙底 + 34% 橙边 + 橙类白字。
1983
+ 中间几轮都是因为「最顶层」那个问题把 transparent 改成了实心底,
1984
+ 12% 橙一变实心就是一块橙板(他随后说「饱和度这么高」)。
1985
+ 底色回到半透明就恢复原样,和「最顶层」无关。 */
1986
+ .balance-settings__group-note--warn{border-color:color-mix(in srgb,#d97706 34%,transparent);background:color-mix(in srgb,#d97706 12%,transparent);color:color-mix(in srgb,#d97706 78%,#e8e8ea)}
1987
+ .balance-settings__group-note--warn .balance-settings__group-note-icon{color:#d97706;opacity:1}.balance-settings__hint-warn{display:block;margin-top:3px;color:#d97706;font-weight:600}
1988
+ .balance-settings__hint-error{display:block;margin-top:3px;color:#e5484d;font-weight:600}
1989
+ .balance-settings__sync-grid{display:grid;grid-template-columns:auto 1fr;gap:7px 16px;font-size:12px;line-height:1.5;align-items:baseline}
1990
+ .balance-settings__sync-key{color:#9a9a9e;white-space:nowrap}
1991
+ .balance-settings__sync-val{color:#e8e8ea}
1992
+ .balance-settings__sync-val--warn{color:#d97706;font-weight:600}
1993
+ .balance-settings__sync-val--cost{color:#4d6bfe;font-weight:600;font-variant-numeric:tabular-nums}
1994
+ /* 「模型解析」下面那一行模型名。独占一行,避免和标签挤在一起被从 "v4-" 中间切断。 */
1995
+ .balance-settings__sync-sub{display:block;margin-top:1px;font-size:11px;font-weight:400;line-height:16px;color:#9a9a9e;word-break:break-all}
1996
+ .balance-settings__row-actions{display:flex;align-items:center;gap:8px;justify-content:flex-end}
1997
+ /* 进度条压成一行(track 左 + label 右):竖排时 track 2px + gap 4px + label 15px = 27px,
1998
+ 同步过程中整块卡片会明显抽一下。横排只占 13px,且 label 靠右不挤标题。 */
1999
+ .balance-settings__progress{order:4;flex:1 0 100%;display:flex;align-items:center;gap:8px;margin-top:5px;min-height:13px}
2000
+ /* 轨道很细:它是「还在动」的提示,不该抢走金额和按钮的注意力 */
2001
+ .balance-settings__progress-track{flex:1 1 auto;min-width:40px;height:2px;border-radius:2px;background:rgba(255,255,255,.08);overflow:hidden}
2002
+ .balance-settings__progress-fill{height:100%;border-radius:2px;background:rgba(255,255,255,.55);transition:width .35s ease}
2003
+ /* 拿不到总步数时的兜底:来回扫的滑块。比一条永远为 0 的空轨道诚实。 */
2004
+ .balance-settings__progress-fill--indeterminate{width:35%;animation:balance-progress-scan 1.2s ease-in-out infinite}
2005
+ @keyframes balance-progress-scan{0%{transform:translateX(-100%)}100%{transform:translateX(300%)}}
2006
+ .balance-settings__progress-label{flex:0 1 auto;min-width:0;font-size:11px;line-height:13px;color:var(--dsw-alias-label-tertiary,#9a9a9e);text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
2007
+ .balance-settings__mode-mini{display:inline-flex;flex:none;align-items:center;border-radius:6px;background:rgba(255,255,255,.06);padding:1px;gap:1px}
2008
+ .balance-settings__mode-mini-btn{appearance:none;border:0;background:transparent;color:#9a9a9e;font-size:11px;line-height:16px;padding:1px 7px;border-radius:5px;cursor:pointer;font-family:inherit;transition:background .12s,color .12s}
2009
+ .balance-settings__mode-mini-btn:hover{color:#e8e8ea}
2010
+ .balance-settings__mode-mini-btn--on{background:rgba(255,255,255,.14);color:#e8e8ea;font-weight:600}
2011
+ /* 环境没挂载 dsh-llm 时「模型」是真点不了,灰掉并禁用指针,别让人以为能点 */
2012
+ /* 选中态按「要不要花钱」分色:「模型」走模型、会扣 token → 橙;
2013
+ 「免费」不调模型 → 绿。两个都是半透明底,不压其他元素。
2014
+ 2026-11-27 用户:「并且给按钮添加颜色 如果是需要token的就显示橙色」。 */
2015
+ .balance-settings__mode-mini-btn--on.balance-settings__mode-mini-btn--model{background:color-mix(in srgb,#d97706 26%,transparent);color:#f2ab55}
2016
+ .balance-settings__mode-mini-btn--on.balance-settings__mode-mini-btn--free{background:color-mix(in srgb,#22c55e 22%,transparent);color:#63dc92}
2017
+ .balance-settings__mode-mini-btn:disabled{opacity:.38;cursor:not-allowed}
2018
+ .balance-settings__mode-mini-btn:disabled:hover{color:#9a9a9e}
2019
+ .balance-settings__sync-note{margin-top:13px;font-size:11px;line-height:1.6;color:#9a9a9e}
2020
+ .balance-settings__hint{font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1672
2021
  .balance-settings__control{display:flex;align-items:center;gap:6px;flex:none}
1673
- .balance-settings__unit{font-size:12px;color:var(--dsw-alias-label-tertiary)}
2022
+ .balance-settings__unit{font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1674
2023
  /* 文本类输入:数字框那套 96px + 右对齐会把「9-12, 14-18」截掉,单独放宽并左对齐 */
1675
2024
  .balance-settings__input--text{width:132px;text-align:left;font-variant-numeric:normal;letter-spacing:.2px}
1676
- .balance-settings__input--text::placeholder{color:var(--dsw-alias-label-tertiary)}/* 输入框底色照抄 DSH 官方设置页(dsh-client-ui-settings-models 的 input 规则):
2025
+ .balance-settings__input--text::placeholder{color:var(--dsw-alias-label-tertiary,#9a9a9e)}/* 输入框底色照抄 DSH 官方设置页(dsh-client-ui-settings-models 的 input 规则):
1677
2026
  那边用 --dsw-alias-bg-layer-1,不是 layer-3。深色主题下三层分别是
1678
2027
  bg-layer-1 #232324 / bg-layer-2 #2c2c2e / bg-layer-3 #353638,页面底 bg-base #151517 —
1679
2028
  用 layer-3 比底色亮 32 级,在设置卡片里就是一块发闷的灰板(用户反馈「那个框的颜色太灰了」)。
1680
2029
  layer-1 只亮 14 级,和官方观感一致;浅色主题下 layer-1 = #fff 与底色同色,
1681
2030
  层次完全靠 .5px 的 border-l4 撑,这也是官方那套的样子。 */
1682
- .balance-settings__input{box-sizing:border-box;width:96px;height:34px;padding:0 10px;text-align:right;font-variant-numeric:tabular-nums;border:.5px solid var(--dsw-alias-border-l4,rgba(127,127,127,.35));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1,rgba(127,127,127,.06));color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;font-variant-numeric:tabular-nums;outline:none}
2031
+ .balance-settings__input{box-sizing:border-box;width:96px;height:34px;padding:0 10px;text-align:right;font-variant-numeric:tabular-nums;border:.5px solid var(--dsw-alias-border-l4,rgba(127,127,127,.35));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-layer-1,rgba(127,127,127,.06));color:var(--dsw-alias-label-primary,#e6e6e8);font:inherit;font-size:13px;font-variant-numeric:tabular-nums;outline:none}
1683
2032
  .balance-settings__input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary,#4d6bfe)}
1684
2033
  .balance-settings__input--wide{width:100%;max-width:340px;min-width:0;text-align:left}
1685
2034
  /* 关掉侧边栏入口后的提醒:壳用 DSH 官方 Modal,这里只留正文排版。 */
1686
- .balance-tip-body{margin:0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary)}
2035
+ .balance-tip-body{margin:0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary,#b9b9bd)}
1687
2036
  /* 节假日数据行:右侧是「状态文案 + 立即同步」两段,窄屏时自动换行靠右。 */
1688
2037
  .balance-settings__calendar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;justify-content:flex-end}
1689
- .balance-settings__calendar-note{font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary);text-align:right;font-variant-numeric:tabular-nums;max-width:100%;word-break:keep-all}
1690
- .balance-settings__calendar-note--warn{color:var(--dsw-alias-state-warn-primary,#d97706)}
2038
+ /* 「立即同步」和「同步中…」字数相同但标点不等宽,实测差 4px ——
2039
+ 而 control 是 flex:none、宽度由内容决定,这 4px 会一路传到左边 label 的宽度上,
2040
+ 说明文字就在换行边界上来回跳。把按钮宽度钉死,两种文案一样宽。 */
2041
+ .balance-settings__calendar .balance-settings__btn{min-width:78px}
2042
+ /* 状态文字(已同步 106 天 · 11-26 21:11)和「模型/免费」挤一行会互相压位置,
2043
+ 所以让它独占第二行、右对齐。order 把三样排成「切换 + 同步按钮」在上、状态在下。 */
2044
+ .balance-settings__calendar-note{order:3;flex:1 0 100%;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e);text-align:right;font-variant-numeric:tabular-nums;max-width:100%;word-break:keep-all;margin-top:-1px}
2045
+ .balance-settings__calendar-note--warn{color:var(--dsw-alias-state-warning-primary,#d97706)}
1691
2046
  .balance-settings__calendar-note--ok{color:var(--dsw-alias-state-success-primary,#22c55e)}
1692
2047
  .balance-settings__calendar-note--error{color:var(--dsw-alias-state-error-primary,#e5484d)}
1693
- .balance-tip-ok{padding:5px 14px;border:.5px solid transparent;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3);font:inherit;font-size:13px;line-height:1.5;cursor:pointer}
2048
+ .balance-tip-ok{padding:5px 14px;border:.5px solid transparent;border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-label-primary,#e6e6e8);color:var(--dsw-alias-bg-layer-3);font:inherit;font-size:13px;line-height:1.5;cursor:pointer}
1694
2049
  .balance-tip-ok:hover{opacity:.88}
1695
2050
  .balance-settings__toggle{position:relative;box-sizing:border-box;flex:none;width:36px;height:20px;padding:2px;border:none;border-radius:999px;corner-shape:round;background:var(--dsw-alias-border-l3,rgba(127,127,127,.35));cursor:pointer;transition:background .12s ease}
1696
2051
  .balance-settings__toggle[aria-checked="true"]{background:var(--dsw-alias-brand-primary,#4d6bfe)}
@@ -1698,9 +2053,9 @@ window.__ModuleLoader__.load({
1698
2053
  .balance-settings__toggle[aria-checked="true"]::after{background:var(--dsw-alias-label-primary-foreground,#fff);transform:translateX(16px)}
1699
2054
  /* 二选一分段控件(余额行外观 新版/旧版) */
1700
2055
  .balance-settings__segmented{display:inline-flex;flex:none;padding:2px;gap:2px;border-radius:999px;corner-shape:round;background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
1701
- .balance-settings__segment{box-sizing:border-box;padding:2px 12px;border:none;border-radius:999px;corner-shape:round;background:0 0;color:var(--dsw-alias-label-secondary);font:inherit;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap;transition:background .15s var(--ds-ease-in-out,.2s),color .15s var(--ds-ease-in-out,.2s)}
1702
- .balance-settings__segment:hover{color:var(--dsw-alias-label-primary)}
1703
- .balance-settings__segment--on{background:var(--dsw-alias-bg-module-platform,var(--dsw-alias-bg-base,#2a2a2c));color:var(--dsw-alias-label-primary);box-shadow:0 1px 2px rgba(0,0,0,.2)}
2056
+ .balance-settings__segment{box-sizing:border-box;padding:2px 12px;border:none;border-radius:999px;corner-shape:round;background:0 0;color:var(--dsw-alias-label-secondary,#b9b9bd);font:inherit;font-size:12px;line-height:18px;font-weight:500;cursor:pointer;white-space:nowrap;transition:background .15s var(--ds-ease-in-out,.2s),color .15s var(--ds-ease-in-out,.2s)}
2057
+ .balance-settings__segment:hover{color:var(--dsw-alias-label-primary,#e6e6e8)}
2058
+ .balance-settings__segment--on{background:var(--dsw-alias-bg-module-platform,var(--dsw-alias-bg-base,#2a2a2c));color:var(--dsw-alias-label-primary,#e6e6e8);box-shadow:0 1px 2px rgba(0,0,0,.2)}
1704
2059
  /* 「消耗行加载动效」那一行的实时预览(2026-10-31 用户要求:「在介绍栏预览给用户看红圈位置」)。
1705
2060
  直接复用消耗行的真实类名(.balance-usage-mist / .balance-usage-calc),
1706
2061
  所以这里看到的就是输入框下方真会出现的那个效果 —— 两边永远不会走样,改一处两边一起变。
@@ -1711,14 +2066,14 @@ window.__ModuleLoader__.load({
1711
2066
  窄屏整块隐藏:640px 以下 label 已经被挤得很窄,再加预览会把文字压断。 */
1712
2067
  .balance-settings__preview{display:flex;align-items:center;margin-left:auto;margin-right:8px;flex:none}
1713
2068
  .balance-settings__preview-item{display:flex;flex-direction:column;align-items:center;gap:4px;padding:5px 7px;border-radius:8px;border:.5px solid color-mix(in srgb,#4d6bfe 55%,transparent);background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.08))}
1714
- .balance-settings__preview-tag{font-size:9.5px;line-height:1;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
2069
+ .balance-settings__preview-tag{font-size:9.5px;line-height:1;color:var(--dsw-alias-label-tertiary,#9a9a9e);white-space:nowrap}
1715
2070
  /* 预览里要把「本会话消耗」这几个字一起画出来 —— 只放一条光带的话看不出这是哪一行,
1716
2071
  真实的那颗胶囊就是「本会话消耗 + 效果」,预览得对得上(2026-10-31 用户:「这个不应该显示对话消耗吗」)。
1717
2072
  胶囊宽度取 81px:真身是 min-width:10.6ch(13px 字号下约 80.8px),预览要是收成 44px,
1718
2073
  光团被裁得更狠、纵向那点涌动就看不出来了 —— 预览跟着真身的尺寸走才不会骗人。
1719
2074
  stage 的 min-width 钉住两种样式的宽度差(「计算中」那颗比光胶囊宽),切样式时右侧按钮不会左右挪。 */
1720
2075
  .balance-settings__preview-stage{position:relative;display:inline-flex;align-items:center;gap:5px;height:20px;min-width:140px}
1721
- .balance-settings__preview-text{font-size:10.5px;line-height:14px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
2076
+ .balance-settings__preview-text{font-size:10.5px;line-height:14px;color:var(--dsw-alias-label-tertiary,#9a9a9e);white-space:nowrap}
1722
2077
  .balance-settings__preview-stage .balance-usage-mist{min-width:0;width:81px}
1723
2078
  /* .balance-usage-calc 本身只定了尺寸和圆角,字号/行高/nowrap 是从消耗行的 .balance-usage-line 继承来的
1724
2079
  —— 预览里没有那层,不补这三行「计算中」会折成「计算 / 中」两行并撑破胶囊。 */
@@ -1733,41 +2088,52 @@ window.__ModuleLoader__.load({
1733
2088
  .balance-settings__update--newer{border-color:color-mix(in srgb,#4d6bfe 42%,transparent);background:color-mix(in srgb,#4d6bfe 14%,transparent)}
1734
2089
  .balance-settings__update--done{border-color:color-mix(in srgb,var(--dsw-alias-state-success-primary,#22c55e) 34%,transparent);background:color-mix(in srgb,var(--dsw-alias-state-success-primary,#22c55e) 11%,transparent)}
1735
2090
  .balance-settings__update-head{display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
1736
- .balance-settings__update-title{display:flex;align-items:center;gap:7px;min-width:0;font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-secondary)}
1737
- .balance-settings__update-ver{font-weight:600;color:var(--dsw-alias-label-primary);font-variant-numeric:tabular-nums}
2091
+ .balance-settings__update-title{display:flex;align-items:center;gap:7px;min-width:0;font-size:12.5px;line-height:18px;color:var(--dsw-alias-label-secondary,#b9b9bd)}
2092
+ .balance-settings__update-ver{font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8);font-variant-numeric:tabular-nums}
1738
2093
  /* 新版徽标:实心品牌色胶囊,形状必须是正圆角(DSH 全局把圆角改成 superellipse 了) */
1739
2094
  .balance-settings__update-badge{flex:none;padding:1px 7px;border-radius:999px;corner-shape:round;background:#4d6bfe;color:#fff;font-size:11px;font-weight:600;line-height:16px;white-space:nowrap}
1740
2095
  .balance-settings__update-btns{display:flex;align-items:center;gap:6px;flex:none}
1741
2096
  /* 查询中的进度文案:跟按钮同一行、排在左边,灰一点,不跟主文案抢注意力。 */
1742
- .balance-settings__update-busy{flex:none;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
2097
+ .balance-settings__update-busy{flex:none;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e);white-space:nowrap}
1743
2098
  /* 标题行左侧的状态话(目前只有「已是最新版本。」)—— 成功绿,前面一个细分隔点,
1744
2099
  与「版本 2.0.2」拉开层次但不抢眼。 */
1745
2100
  .balance-settings__update-inline{flex:none;font-size:11.5px;line-height:17px;color:var(--dsw-alias-state-success-primary,#22c55e);white-space:nowrap}
1746
- .balance-settings__update-inline::before{content:"·";margin:0 2px 0 0;color:var(--dsw-alias-label-tertiary)}
1747
- .balance-settings__update-note{margin:7px 0 0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary)}
2101
+ .balance-settings__update-inline::before{content:"·";margin:0 2px 0 0;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
2102
+ .balance-settings__update-note{margin:7px 0 0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1748
2103
  .balance-settings__actions{display:flex;align-items:center;gap:8px;margin:14px 0 0;padding:12px 0 0;border-top:.5px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22))}
1749
2104
  /* 数据诊断:按钮组 + 报告块。
1750
2105
  报告是等宽文本、要能整段选中复制,所以 pre + user-select:text;
1751
2106
  放不下时自己滚(max-height 限制高度,别把设置页撑到几屏长)。 */
1752
2107
  .balance-settings__diag-btns{display:flex;align-items:center;gap:6px;flex:none}
1753
- .balance-settings__diag{box-sizing:border-box;margin:8px 0 0;padding:10px 12px;max-height:320px;overflow:auto;border:.5px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-base,rgba(0,0,0,.18));color:var(--dsw-alias-label-secondary);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11.5px;line-height:1.65;white-space:pre;tab-size:2;user-select:text;-webkit-user-select:text}
2108
+ .balance-settings__diag{box-sizing:border-box;margin:8px 0 0;padding:10px 12px;max-height:320px;overflow:auto;border:.5px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-bg-base,rgba(0,0,0,.18));color:var(--dsw-alias-label-secondary,#b9b9bd);font-family:ui-monospace,SFMono-Regular,Consolas,monospace;font-size:11.5px;line-height:1.65;white-space:pre;tab-size:2;user-select:text;-webkit-user-select:text}
1754
2109
  .balance-settings__diag--error{color:var(--dsw-alias-state-error-primary,#e5484d)}
1755
2110
  .balance-settings__diag-bad{color:var(--dsw-alias-state-error-primary,#e5484d)}
1756
- .balance-settings__diag-warn{color:var(--dsw-alias-state-warn-primary,#d97706)}
2111
+ .balance-settings__diag-warn{color:var(--dsw-alias-state-warning-primary,#d97706)}
1757
2112
  .balance-settings__diag-ok{color:var(--dsw-alias-state-success-primary,#3fb950)}
1758
2113
  .balance-settings__diag-head{font-weight:600}
1759
2114
  .balance-settings__diag-fix{margin:8px 0 0;font-size:12px;line-height:17px}
1760
2115
  .balance-settings__diag-fix--ok{color:var(--dsw-alias-state-success-primary,#3fb950)}
1761
- .balance-settings__diag-fix--warn{color:var(--dsw-alias-state-warn-primary,#d97706)}
1762
- .balance-settings__status{flex:1;min-width:0;font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary)}
2116
+ .balance-settings__diag-fix--warn{color:var(--dsw-alias-state-warning-primary,#d97706)}
2117
+ .balance-settings__status{flex:1;min-width:0;font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1763
2118
  .balance-settings__status--error{color:var(--dsw-alias-state-error-primary,#e5484d)}
1764
2119
  .balance-settings__status--ok{color:var(--dsw-alias-state-success-primary,#22c55e)}
1765
- .balance-settings__btn{box-sizing:border-box;flex:none;white-space:nowrap;padding:5px 14px;border:.5px solid var(--dsw-alias-border-l2,rgba(127,127,127,.28));border-radius:var(--dsw-radius-md,8px);background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.1));color:var(--dsw-alias-label-primary);font:inherit;font-size:13px;line-height:1.5;cursor:pointer;transition:background .12s ease,border-color .12s ease,opacity .12s ease}
1766
- .balance-settings__btn:hover:not(:disabled){background:var(--dsw-alias-interactive-bg-active,rgba(127,127,127,.18))}
2120
+ /* 设置面板的按钮不跟主题走(2026-11-27 用户:
2121
+ 「插件的设置界面你是不是保持了 dsh 的风格 导致按钮的颜色显示不出来
2122
+ 可以不用同一个主题的」)。
2123
+ 原来主按钮是 background:label-primary + color:bg-layer-3 ——
2124
+ 这两个变量在某些主题里反差太小(或根本未定义),
2125
+ 字和底一起消失。现在用固定品牌蓝 + 白字,不受主题影响。 */
2126
+ .balance-settings__btn{box-sizing:border-box;flex:none;white-space:nowrap;padding:5px 14px;
2127
+ border:.5px solid rgba(127,127,127,.34);border-radius:var(--dsw-radius-md,8px);
2128
+ background:rgba(127,127,127,.12);color:var(--dsw-alias-label-primary,#e6e6e8);
2129
+ font:inherit;font-size:13px;line-height:1.5;cursor:pointer;
2130
+ transition:background .12s ease,border-color .12s ease,opacity .12s ease}
2131
+ .balance-settings__btn:hover:not(:disabled){background:rgba(127,127,127,.22);border-color:rgba(127,127,127,.5)}
1767
2132
  .balance-settings__btn:disabled{opacity:.4;cursor:default}
1768
- .balance-settings__btn--primary{border-color:transparent;background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}
1769
- .balance-settings__btn--primary:hover:not(:disabled){opacity:.88;color:var(--dsw-alias-bg-layer-3)}
1770
- .balance-settings__summary{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--dsw-alias-label-tertiary);font-variant-numeric:tabular-nums}
2133
+ .balance-settings__btn--primary{border-color:#4d6bfe;background:#4d6bfe;color:#fff;font-weight:600}
2134
+ .balance-settings__btn--primary:hover:not(:disabled){background:#5d79ff;border-color:#5d79ff;color:#fff;opacity:1}
2135
+ .balance-settings__btn--primary:active:not(:disabled){background:#3f5bef;border-color:#3f5bef}
2136
+ .balance-settings__summary{display:inline-flex;align-items:center;gap:8px;font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e);font-variant-numeric:tabular-nums}
1771
2137
  `;
1772
2138
 
1773
2139
  const tagId = "balance/balance-widget.css";
@@ -2407,11 +2773,16 @@ let floatRemeasureHook = null;
2407
2773
  // (2026-10-30 用户要求「对话消耗的数字变动动画跟余额的自动刷新一样」)。
2408
2774
  const ROLL_EMPTY = "\u0000";
2409
2775
  function buildRollCells(fromText, toText) {
2776
+ // ⚠️ 正则必须能吃掉**前导非数字**(¥ / $ 这类货币符号)。
2777
+ // 原来写的是 /^([0-9]*)(\.?)([0-9]*)…/,数字段在开头 —— 喂进来的 real 值是
2778
+ // totalText("¥1.9400"),首字符是 ¥,于是 int/dot/frac 全空、**整个串被当成 tail**。
2779
+ // tail 现在整段一格且 changed 恒 false ⇒ 余额胶囊会一格都不滚、数字硬切。
2780
+ // 拆成 pre(符号)/ int / dot / frac / tail 五段,符号和尾巴各自是静态整格。
2410
2781
  const split = (text) => {
2411
- const m = /^([0-9]*)(\.?)([0-9]*)([\s\S]*)$/.exec(text);
2782
+ const m = /^([^0-9]*)([0-9]*)(\.?)([0-9]*)([\s\S]*)$/.exec(text);
2412
2783
  return m
2413
- ? { int: m[1], dot: m[2], frac: m[3], tail: m[4] }
2414
- : { int: "", dot: "", frac: "", tail: text };
2784
+ ? { pre: m[1], int: m[2], dot: m[3], frac: m[4], tail: m[5] }
2785
+ : { pre: "", int: "", dot: "", frac: "", tail: text };
2415
2786
  };
2416
2787
  const a = split(fromText);
2417
2788
  const b = split(toText);
@@ -2427,7 +2798,6 @@ let floatRemeasureHook = null;
2427
2798
  const padRight = (s, n) => s.padEnd(n, ROLL_EMPTY);
2428
2799
  const intLen = Math.max(a.int.length, b.int.length);
2429
2800
  const fracLen = Math.max(a.frac.length, b.frac.length);
2430
- const tailLen = Math.max(a.tail.length, b.tail.length);
2431
2801
  // 小数点这一格**按新值的形态**决定去留:新值不带小数就是空位(滚走 + --gone 收宽)。
2432
2802
  // 原来是 `a.dot || b.dot` 两边都取「有小数点的那一侧」,于是 99.99 → 100 之后
2433
2803
  // 新值侧仍留着一个小数点,小数位已经收成 0 宽,屏幕上却是 `¥100.`,
@@ -2443,7 +2813,6 @@ let floatRemeasureHook = null;
2443
2813
  [padLeft(a.int, intLen), padLeft(b.int, intLen)],
2444
2814
  ...dotCells,
2445
2815
  [padRight(a.frac, fracLen), padRight(b.frac, fracLen)],
2446
- [padRight(a.tail, tailLen), padRight(b.tail, tailLen)],
2447
2816
  ];
2448
2817
  const cells = [];
2449
2818
  for (const [left, right] of rows) {
@@ -2451,6 +2820,19 @@ let floatRemeasureHook = null;
2451
2820
  cells.push({ from: left[i], to: right[i], changed: left[i] !== right[i] });
2452
2821
  }
2453
2822
  }
2823
+ // ⚠️ 尾巴(" CNY" / " USD" 这类)**整段一格**,绝不逐字符拆
2824
+ // (2026-11-26 用户:「这个滚动是不是有点问题 我刚刚余光看到了」)。
2825
+ // 原来它走和数字一样的逐字符循环," CNY" 就变成「空格 / C / N / Y」四个独立 span:
2826
+ // 每格都是独立的 inline-block,字母之间的字距、抗锯齿、亚像素定位都不再是
2827
+ // 一整段文本的排法,整串看起来有点毛;而且它永远不变,拆了也毫无用处。
2828
+ // 现在它是一格静态 dcell(changed 恒 false → 不滚),宽度随内容自适应。
2829
+ // 前缀(¥ / $)整段一格,永远是静态的;币种不会变,拆字符只会让字距发毛
2830
+ if (a.pre !== "" || b.pre !== "") {
2831
+ cells.unshift({ from: a.pre, to: b.pre, changed: false, whole: true });
2832
+ }
2833
+ if (a.tail !== "" || b.tail !== "") {
2834
+ cells.push({ from: a.tail, to: b.tail, changed: false, whole: true });
2835
+ }
2454
2836
  return cells;
2455
2837
  }
2456
2838
 
@@ -2560,16 +2942,25 @@ let floatRemeasureHook = null;
2560
2942
 
2561
2943
  function renderRollCells(cells, prefix, settled, quick) {
2562
2944
  // 先按从右往左给「会滚的格子」编号:最右边的滚动格延迟 0
2563
- const total = cells.length;
2564
2945
  const staggerMs = quick === true ? COST_ROLL_STAGGER_MS : ROLL_STAGGER_MS;
2565
2946
  const staggerMax = quick === true ? COST_ROLL_STAGGER_MAX : ROLL_STAGGER_MAX;
2947
+ // ⚠️ 只给**会滚的格子**编号,静态格(¥ 前缀、CNY 尾巴)不占号。
2948
+ // 用 cells.length 的话,加了符号格之后每个滚动格的 fromRight 整体偏大一档,
2949
+ // 延迟被白白推后,看起来就是「旁边的格子先滚、它还在原地」。
2950
+ const rollIdx = new Array(cells.length).fill(-1);
2951
+ {
2952
+ let n = 0;
2953
+ for (let k = cells.length - 1; k >= 0; k -= 1) {
2954
+ if (cells[k].changed) rollIdx[k] = n++;
2955
+ }
2956
+ }
2566
2957
  return jsx.jsx("span", {
2567
2958
  className: "balance-footer__roll" + (quick === true ? " balance-footer__roll--quick" : ""),
2568
2959
  children: cells.map((cell, i) => {
2569
2960
  if (!cell.changed) {
2570
2961
  return jsx.jsx("span", { className: "balance-footer__dcell", children: cell.to === ROLL_EMPTY ? "\u00a0" : cell.to }, prefix + i);
2571
2962
  }
2572
- const fromRight = total - 1 - i;
2963
+ const fromRight = rollIdx[i];
2573
2964
  const step = Math.min(fromRight, staggerMax);
2574
2965
  const delay = step * staggerMs;
2575
2966
  const style = delay > 0 ? { animationDelay: delay + "ms" } : undefined;
@@ -2582,6 +2973,9 @@ let floatRemeasureHook = null;
2582
2973
  className: "balance-footer__dcell balance-footer__dcell--roll"
2583
2974
  + (cell.to === ROLL_EMPTY ? " balance-footer__dcell--gone" : "")
2584
2975
  + (settled === true ? " balance-footer__dcell--roll-done" : ""),
2976
+ // ⚠️ dout 必须显式 hidden 自己那份。--roll-done 那条 CSS 已经写了
2977
+ // display:none,这里再兜一层:一旦哪天真丢了那条规则,旧值不会
2978
+ // 和新值叠在同一个位置(用户看到的就是「滚动时有别的数字」)。
2585
2979
  children: [
2586
2980
  // 影子格用「新字符」撑宽;新值是空位时退回旧字符 —— 滚动开始那一刻的宽度
2587
2981
  // 正好等于滚动前,之后由 --gone 的 max-width 动画把它平滑收到 0。
@@ -2693,7 +3087,8 @@ let floatRemeasureHook = null;
2693
3087
  return activePeakWindows;
2694
3088
  }
2695
3089
  // 中国大陆法定节假日与调休(北京时区)。**必须与 lib/index.js 的 CN_CALENDAR 完全一致**
2696
- // (服务端负责算钱、客户端只负责显示时段标签)。来源:国办发明电〔2025〕7号,每年需补录。
3090
+ // (服务端负责算钱、客户端只负责显示时段标签)。2026 来自国办发明电〔2025〕7号,
3091
+ // 2027 来自国务院 2026-11 的次年安排。每年 11 月前后要补录下一年。
2697
3092
  const CN_CALENDAR = {
2698
3093
  // 元旦:1/1-1/3 放假,1/4(周日) 上班
2699
3094
  "2026-01-01": "holiday", "2026-01-02": "holiday", "2026-01-03": "holiday", "2026-01-04": "workday",
@@ -2716,6 +3111,27 @@ let floatRemeasureHook = null;
2716
3111
  // 国庆节:10/1-10/7 放假,10/10(周六) 上班
2717
3112
  "2026-10-01": "holiday", "2026-10-02": "holiday", "2026-10-03": "holiday", "2026-10-04": "holiday",
2718
3113
  "2026-10-05": "holiday", "2026-10-06": "holiday", "2026-10-07": "holiday", "2026-10-10": "workday",
3114
+ // ── 2027 年(国办发明电〔2026〕10 号,2026-11-05 发布,已正式公布才收录)──
3115
+ // 元旦:1/1(五)-1/3(日) 放假,共 3 天(与周末自然相连,无调休)
3116
+ "2027-01-01": "holiday", "2027-01-02": "holiday", "2027-01-03": "holiday",
3117
+ // 春节:2/5(除夕、五)-2/13(正月初八、六) 放假调休,共 9 天;1/31(日)、2/14(日) 上班
3118
+ "2027-01-31": "workday",
3119
+ "2027-02-05": "holiday", "2027-02-06": "holiday", "2027-02-07": "holiday", "2027-02-08": "holiday",
3120
+ "2027-02-09": "holiday", "2027-02-10": "holiday", "2027-02-11": "holiday", "2027-02-12": "holiday",
3121
+ "2027-02-13": "holiday", "2027-02-14": "workday",
3122
+ // 清明节:4/3(六)-4/5(一) 放假,共 3 天(无调休)
3123
+ "2027-04-03": "holiday", "2027-04-04": "holiday", "2027-04-05": "holiday",
3124
+ // 劳动节:5/1(六)-5/5(三) 放假调休,共 5 天;5/8(六) 上班
3125
+ "2027-05-01": "holiday", "2027-05-02": "holiday", "2027-05-03": "holiday", "2027-05-04": "holiday",
3126
+ "2027-05-05": "holiday", "2027-05-08": "workday",
3127
+ // 端午节:6/9(三) 放假,共 1 天(无调休)
3128
+ "2027-06-09": "holiday",
3129
+ // 中秋节:9/15(三) 放假,共 1 天(无调休)
3130
+ "2027-09-15": "holiday",
3131
+ // 国庆节:10/1(五)-10/7(四) 放假调休,共 7 天;9/26(日)、10/9(六) 上班
3132
+ "2027-09-26": "workday",
3133
+ "2027-10-01": "holiday", "2027-10-02": "holiday", "2027-10-03": "holiday", "2027-10-04": "holiday",
3134
+ "2027-10-05": "holiday", "2027-10-06": "holiday", "2027-10-07": "holiday", "2027-10-09": "workday",
2719
3135
  };
2720
3136
 
2721
3137
  // 节假日自动补录:与 lib/index.js 同源、同逻辑(客户端只用来显示时段标签)。
@@ -2770,7 +3186,7 @@ const CN_CALENDAR_SOURCES = [
2770
3186
  * 点关闭按钮 → 捕获阶段先 arm 230ms 打开定时器 → 按钮随即关闭 → 230ms 后又被打开,面板关不掉)。 */
2771
3187
  function isOverlayTarget(target) {
2772
3188
  try {
2773
- return Boolean(target && typeof target.closest === "function" && target.closest(".balance-stats-layer, .balance-platform-layer"));
3189
+ return Boolean(target && typeof target.closest === "function" && target.closest(".balance-stats-layer, .balance-platform-layer, .balance-pop"));
2774
3190
  } catch {
2775
3191
  return false;
2776
3192
  }
@@ -2822,7 +3238,16 @@ const CN_CALENDAR_SOURCES = [
2822
3238
  // 跨多版升上来的会看到中间所有新功能,只升一版的老功能一条都不亮。
2823
3239
  if (recV !== "" && recV === intro) {
2824
3240
  const baseline = String(fallbackFrom || "");
2825
- const since = Number.isFinite(recT) && recT > 0 ? recT : Number(fallbackSince);
3241
+ // ⚠️ `t` 是「这一项被记下来时的升级时刻」,不许伪造;但它可能来自**上一次**升级 ——
3242
+ // 本版新加的功能在用户还没升级时就被 markNewTagsEntered 贴上了旧 t
3243
+ // (锚点用的是当时的 newTagSince),于是窗口一天都没走就先判了过期。
3244
+ // 2026-11-26 用户报「我这边怎么没有 newtag 标签」就是这个:aggCacheMax 的
3245
+ // t = 11/24,而本次升级是 11/26,差 45.5 小时 → within() 恒 false。
3246
+ // 窗口起点取两者较晚的那个:既不动 t,也不会让老功能重新计时
3247
+ // (reallyFresh 仍然卡着 compareVersion(intro, baseline) > 0)。
3248
+ const recSince = Number.isFinite(recT) && recT > 0 ? recT : 0;
3249
+ const upSince = Number(fallbackSince) > 0 ? Number(fallbackSince) : 0;
3250
+ const since = Math.max(recSince, upSince);
2826
3251
  const reallyFresh = baseline === "" || compareVersion(intro, baseline) > 0 || isCurrentIntro(since);
2827
3252
  const entered = rec !== null && rec.d === true;
2828
3253
  return {
@@ -2868,6 +3293,10 @@ const CN_CALENDAR_SOURCES = [
2868
3293
  ["todaySessionLimit", "2.1.0"], // 今日消耗扫描上限:多开对话 / 多跑子代理时把今日汇总算全
2869
3294
  ["showUsagePill", "2.1.6"], // 2.1.6:消耗行搬成对话界面右下角小浮窗(两行:本会话估算 / 金额)
2870
3295
  ["diag", "2.2.6"], // 2.2.6:设置页「数据诊断」—— 一键出结论 + 复制 + 查出问题给「修复」
3296
+ ["aggCacheMax", "2.3.6"], // 2.3.6:聚合缓存条数上限(原来写死 320,会话多的人装不下)
3297
+ ["syncedPricingAt", "2.3.6"], // 2.3.6:一键同步官方价与时段(官网改价不用等插件发版)
3298
+ ["syncModePricing", "2.3.6"], // 2.3.6:价格同步走模型还是免费
3299
+ ["syncModeCalendar", "2.3.6"], // 2.3.6:节假日同步走模型还是免费
2871
3300
  ]);
2872
3301
 
2873
3302
  /** NEW_TAGS 的 key → 设置项中文名。横幅要写「本版新增:消耗行加载动效」,
@@ -2880,6 +3309,10 @@ const CN_CALENDAR_SOURCES = [
2880
3309
  todaySessionLimit: "今日消耗扫描上限",
2881
3310
  showUsagePill: "对话右下角消耗浮窗",
2882
3311
  diag: "数据诊断",
3312
+ aggCacheMax: "聚合缓存条数上限",
3313
+ syncModePricing: "价格同步方式",
3314
+ syncModeCalendar: "节假日同步方式",
3315
+ syncedPricingAt: "同步官方价格与时段",
2883
3316
  };
2884
3317
 
2885
3318
  /** 模板串里取一张表的三个 NEW 相关字段,缺省一律安全兜底。 */
@@ -3179,6 +3612,13 @@ const CN_CALENDAR_SOURCES = [
3179
3612
  // 今日消耗单独一个上限,默认比统计宽(服务端 TODAY_MAX_SESSIONS 同值)
3180
3613
  todaySessionLimit: 200,
3181
3614
  statsCacheSec: 300,
3615
+ aggCacheMax: 320,
3616
+ syncModePricing: "model",
3617
+ syncModeCalendar: "model",
3618
+ syncedPricingAt: 0,
3619
+ syncedPricingFrom: "",
3620
+ syncedPricingNote: "",
3621
+ priceBaseline: null,
3182
3622
  peakWindowsText: "9-12, 14-18",
3183
3623
  peakMultiplier: 2,
3184
3624
  priceFlash: null,
@@ -3266,6 +3706,24 @@ const CN_CALENDAR_SOURCES = [
3266
3706
  return calendarCache;
3267
3707
  }
3268
3708
 
3709
+ /** 一年之内的阶段权重。`done` 是 0:那一年已经计进 `done` 计数了,不能再叠一次。 */
3710
+ const CAL_PHASE_WEIGHT = { search: 0.12, fetch: 0.45, parse: 0.85, done: 0 };
3711
+
3712
+ /** 进度百分比。done 是「已经走完几年」,phase 是「当前这一年走到哪一步」。
3713
+ * ⚠️ 必须**单调递增**:早先 done 阶段给了权重 1,于是「2 个年份、第 1 个刚跑完」
3714
+ * 算成 (1+1)/2 = 100%,紧接着第 2 年一开始又算成 (0+0.12)/2 = 6% ——
3715
+ * 进度条从满格猛地退到最左,用户看到的就是「查询下一年会往左跑」。
3716
+ * 现在分母固定为总年数、分子只由「走完几年 + 当前年走到第几步」决定,只会前进。 */
3717
+ function calendarProgressPct(p) {
3718
+ if (p == null) return 0;
3719
+ const total = Number(p.total) || 0;
3720
+ const done = Number(p.done) || 0;
3721
+ if (total <= 0) return 0;
3722
+ if (total <= done) return 100;
3723
+ const w = CAL_PHASE_WEIGHT[p.phase] ?? 0;
3724
+ return Math.min(100, Math.max(0, ((done + w) / total) * 100));
3725
+ }
3726
+
3269
3727
  function emitSettings() {
3270
3728
  // 逐个订阅者隔离:设置热更新必须送达所有订阅者。
3271
3729
  for (const listener of settingsListeners) {
@@ -3290,6 +3748,7 @@ const CN_CALENDAR_SOURCES = [
3290
3748
  value: { ...SETTINGS_DEFAULTS, ...data.settings },
3291
3749
  loaded: true,
3292
3750
  version: typeof data.version === "string" ? data.version : settingsCache.version,
3751
+ modelSync: data.modelSync ?? null,
3293
3752
  };
3294
3753
  // 高峰窗口跟着设置走:判定与刻度都得换,否则标签会和实际计费对不上
3295
3754
  applyPeakWindowsText(settingsCache.value.peakWindowsText);
@@ -3334,6 +3793,7 @@ const CN_CALENDAR_SOURCES = [
3334
3793
  value: { ...SETTINGS_DEFAULTS, ...server, ...kept },
3335
3794
  loaded: true,
3336
3795
  version: typeof data.version === "string" ? data.version : settingsCache.version,
3796
+ modelSync: data.modelSync ?? settingsCache.modelSync,
3337
3797
  };
3338
3798
  applyPeakWindowsText(settingsCache.value.peakWindowsText);
3339
3799
  emitSettings();
@@ -3588,6 +4048,28 @@ const CN_CALENDAR_SOURCES = [
3588
4048
  void fetchTodayOnce(false);
3589
4049
  }
3590
4050
 
4051
+ /** `?session=` 带回来的 today 可能**没有** hourly / sessionTitles —— 那两项只有
4052
+ * `?today=1` 那条全量路径才会算。直接采纳它会把手里已有的曲线数据抹掉,
4053
+ * 小窗就从「有曲线」退回「正在汇总」。这里按字段级继承:新值有就用新的,
4054
+ * 没有就留住旧的那份。 */
4055
+ function inheritTodayExtras(next, prev) {
4056
+ if (next == null || typeof next !== "object") return next;
4057
+ if (prev == null || typeof prev !== "object") return next;
4058
+ const out = { ...next };
4059
+ const hasHourly = Array.isArray(next.hourly) && next.hourly.length > 0;
4060
+ if (!hasHourly && Array.isArray(prev.hourly) && prev.hourly.length > 0) out.hourly = prev.hourly;
4061
+ const hasTitles = next.sessionTitles != null && typeof next.sessionTitles === "object"
4062
+ && Object.keys(next.sessionTitles).length > 0;
4063
+ if (!hasTitles && prev.sessionTitles != null && typeof prev.sessionTitles === "object") {
4064
+ out.sessionTitles = prev.sessionTitles;
4065
+ }
4066
+ // bySession 同理:增量路径只带「当前会话那一桶 + 其余原样搬运」,正常情况下是全的,
4067
+ // 但 baseline 是旧快照时可能只有一两个桶 —— 少于旧的就别用它。
4068
+ const nextBuckets = next.bySession && typeof next.bySession === "object" ? Object.keys(next.bySession).length : 0;
4069
+ const prevBuckets = prev.bySession && typeof prev.bySession === "object" ? Object.keys(prev.bySession).length : 0;
4070
+ if (nextBuckets < prevBuckets) out.bySession = prev.bySession;
4071
+ return out;
4072
+ }
3591
4073
  function raiseTodayFromSession(today) {
3592
4074
  if (today == null || typeof today.cost !== "number" || !Number.isFinite(today.cost)) return;
3593
4075
  const prev = todayCache.value;
@@ -3603,7 +4085,7 @@ const CN_CALENDAR_SOURCES = [
3603
4085
  // 现在:新的一天直接采纳服务端口径(它含实时事件,比持久化口径只多不少),
3604
4086
  // 再补一次 `?today=1` 把「其余会话」那部分也拿回来。昨天的账一个字都不搬过来。
3605
4087
  if (prev.date !== today.date) {
3606
- todayCache.value = today;
4088
+ todayCache.value = inheritTodayExtras(today, prev);
3607
4089
  todayCache.at = Date.now();
3608
4090
  todayCache.tried = true;
3609
4091
  todayCache.settled = true;
@@ -3627,7 +4109,7 @@ const CN_CALENDAR_SOURCES = [
3627
4109
  return;
3628
4110
  }
3629
4111
  }
3630
- todayCache.value = today;
4112
+ todayCache.value = inheritTodayExtras(today, prev);
3631
4113
  todayCache.tried = true;
3632
4114
  todayCache.settled = true;
3633
4115
  notifyToday();
@@ -4017,6 +4499,10 @@ const CN_CALENDAR_SOURCES = [
4017
4499
  // 网页搜索 / 抓取:官方 2026-10-17 上线独立计费,¥5 / 千次 = ¥0.005 / 次,
4018
4500
  // 北京时间 2026-11-01 00:00 起开始收费(此前免费)。与 lib/index.js 同名常量保持一致。
4019
4501
  const WEB_TOOL_BILLING_START = Date.parse("2026-11-01T00:00:00+08:00");
4502
+ /** 官方自北京时间 2026-11-18 12:00 起取消「模型调用触发的服务端搜索与网页抓取」的
4503
+ * 工具费,改为只算 token。所以「¥5 / 千次」只对 11-01 ~ 11-18 这段历史有效;
4504
+ * 之后一律不计次(web_fetch 还是本地匿名 HTTP,本来就不经过 DeepSeek API)。 */
4505
+ const WEB_TOOL_FREE_FROM = Date.parse("2026-11-18T12:00:00+08:00");
4020
4506
  // 动效时长:**两态各算各的**(2026-10-31:「收起是收起 展开是展开 动画播放完了
4021
4507
  // 我还不能刷新」)。原来两态共用一个 900(取最大值),展开态白光只有 580ms,
4022
4508
  // 播完之后还要再被锁 320ms —— 用户点下去毫无反应,像卡住了。
@@ -4180,7 +4666,1228 @@ const CN_CALENDAR_SOURCES = [
4180
4666
  });
4181
4667
  }
4182
4668
 
4183
- function UsageStatsPanel({ onClose, panelRef, closing }) {
4669
+ // ─── 两个「上滑小窗」(2026-11-26)──────────────────────────────────────
4670
+ // 用户原话:
4671
+ // 「点击左侧的今日消耗可以上滑一个小窗显示那些对话消耗了多少钱」
4672
+ // 「点击时段条或者空闲时间可以上滑一个小窗显示对应时间线消耗了多少余额(用时间线来表示)」
4673
+ // 原来整行是一个热区(单击=统计面板),现在在 rowInteractions 里按 closest() 分流。
4674
+
4675
+ /** 金额格式化成 ¥x.xxxx:今日明细要看清「哪段对话更贵」,四位小数够用。 */
4676
+ function popMoney(n) {
4677
+ const v = Number(n);
4678
+ if (!Number.isFinite(v)) return "¥0.0000";
4679
+ return "¥" + v.toFixed(4);
4680
+ }
4681
+ /** 悬停金额:固定两位小数(2026-11-26 用户:「只显示到小数点后两位吧」)。
4682
+ * 之前按量级分 4/3/2 位,悬停扫过时位数反复跳、也没人看第四位。
4683
+ * ⚠️ 别改 popMoney 本身 —— 余额行、明细列表都用它,那些地方必须固定 4 位。 */
4684
+ function popMoneyTip(n) {
4685
+ const v = Number(n) || 0;
4686
+ return "¥" + v.toFixed(2);
4687
+ }
4688
+ /** token 数:1234567 → 1.23M,123456 → 123.5k,太小原样。 */
4689
+ function popTokens(n) {
4690
+ const v = Number(n) || 0;
4691
+ if (v >= 1000000) return (v / 1000000).toFixed(2) + "M";
4692
+ if (v >= 10000) return (v / 1000).toFixed(1) + "k";
4693
+ return String(Math.round(v));
4694
+ }
4695
+
4696
+ /** 小窗外壳:定位、三角、头部、Esc / 点外关闭都由它统一处理。
4697
+ * `anchorRect` 是被点那一块的 getBoundingClientRect(),小窗出现在它**上方**
4698
+ * (这就是「上滑」),上方放不下就翻到下面。左右夹在视口内并回填三角位置。 */
4699
+ function PopShell({ anchorRect, title, subtitle, onClose, children, wide, headExtra }) {
4700
+ const ref = react.useRef(null);
4701
+ const [box, setBox] = react.useState(null);
4702
+ const [closing, setClosing] = react.useState(false);
4703
+ // ⚠️ 关闭是**延迟**的(130ms 淡出),所以定时器必须能被取消,否则会出现
4704
+ // 「有时候点不开」:开着 → 点一下(mousedown 触发 requestClose,排了个 130ms 后的
4705
+ // onClose;同一次点击的 click 又把状态 toggle 成 null)→ 130ms 内再点一下想打开,
4706
+ // 状态确实变成 {rect} 了,**然后上一次那个定时器到点执行 onClose,把它关掉**
4707
+ // (2026-11-27 用户:「有时候点不开时段表」)。
4708
+ // 定时器存进 ref,组件卸载就清掉;重开时是新实例,旧定时器不会再打到新状态上。
4709
+ const closeTimerRef = react.useRef(null);
4710
+ const requestClose = react.useCallback(() => {
4711
+ setClosing(true);
4712
+ if (closeTimerRef.current !== null) clearTimeout(closeTimerRef.current);
4713
+ closeTimerRef.current = setTimeout(() => {
4714
+ closeTimerRef.current = null;
4715
+ onClose();
4716
+ }, 130);
4717
+ }, [onClose]);
4718
+ react.useEffect(() => () => {
4719
+ if (closeTimerRef.current !== null) {
4720
+ clearTimeout(closeTimerRef.current);
4721
+ closeTimerRef.current = null;
4722
+ }
4723
+ }, []);
4724
+ /** 量尺寸 → 算落点。抽出来是为了**能重复调**:
4725
+ * ① 首帧(usePrePaintEffect,paint 之前量,不闪);
4726
+ * ② 内容变了之后(ResizeObserver)—— 小窗里正文是异步的
4727
+ * (「正在加载」→ 一堆会话行),高度会变,不重算就会压住下面那一行。
4728
+ * ⚠️ 位置没变时必须返回同一个对象,否则 RO 回调 → setState → 重渲染 →
4729
+ * 尺寸变化 → RO 回调,转成死循环。 */
4730
+ const place = react.useCallback(() => {
4731
+ if (!anchorRect) return;
4732
+ const el = ref.current;
4733
+ if (el == null) return;
4734
+ const vw = typeof window === "undefined" ? 1200 : window.innerWidth;
4735
+ const vh = typeof window === "undefined" ? 800 : window.innerHeight;
4736
+ const w = el.offsetWidth > 0 ? el.offsetWidth : Math.min(wide ? 498 : 330, vw - 20);
4737
+ const h = el.offsetHeight > 0 ? el.offsetHeight : 260;
4738
+ // GAP 让开小三角(自身 11px、旋转后探出约 6px)+ 4px 呼吸。
4739
+ // 原来 10 太紧,内容一高就贴到 anchor 脸上。
4740
+ const GAP = 12;
4741
+ const wantTop = anchorRect.top - GAP - h;
4742
+ const above = wantTop >= 8;
4743
+ const top = above ? wantTop : Math.min(vh - h - 8, anchorRect.bottom + GAP);
4744
+ const cx = anchorRect.left + anchorRect.width / 2;
4745
+ const left = Math.max(8, Math.min(vw - w - 8, cx - w / 2));
4746
+ const next = {
4747
+ left: Math.round(left),
4748
+ top: Math.round(Math.max(8, top)),
4749
+ arrow: Math.round(Math.max(10, Math.min(w - 10, cx - left))),
4750
+ above,
4751
+ };
4752
+ setBox((prev) => (prev !== null
4753
+ && prev.left === next.left && prev.top === next.top
4754
+ && prev.arrow === next.arrow && prev.above === next.above
4755
+ ? prev : next));
4756
+ }, [anchorRect, wide]);
4757
+ usePrePaintEffect(() => { place(); return undefined; }, [place]);
4758
+ // 内容高度变化就重量一次(会话行数变、正文从「正在加载」变成列表……)
4759
+ react.useEffect(() => {
4760
+ const el = ref.current;
4761
+ if (el == null || typeof ResizeObserver !== "function") return undefined;
4762
+ const ro = new ResizeObserver(() => { place(); });
4763
+ ro.observe(el);
4764
+ const bodyEl = el.querySelector(".balance-pop__body");
4765
+ if (bodyEl) ro.observe(bodyEl);
4766
+ return () => ro.disconnect();
4767
+ }, [place]);
4768
+ // 窗口尺寸变了(拖窗口 / 侧栏折叠)也要重算,否则小窗会飘到视口外
4769
+ react.useEffect(() => {
4770
+ const onResize = () => place();
4771
+ window.addEventListener("resize", onResize);
4772
+ return () => window.removeEventListener("resize", onResize);
4773
+ }, [place]);
4774
+ react.useEffect(() => {
4775
+ const onKey = (e) => { if (e && e.key === "Escape") requestClose(); };
4776
+ const onDown = (e) => {
4777
+ const el = ref.current;
4778
+ if (el == null || e == null) return;
4779
+ if (el.contains(e.target)) return;
4780
+ // 点在**触发小窗的热区**上时,关闭交给同一轮 click 的 toggle 处理。
4781
+ // 否则 mousedown 先把 closing 置上(并排一个 130ms 的 onClose),click 再 toggle,
4782
+ // 两边各改一次状态 —— 连点时会互相打断,表现就是「有时候点不开」
4783
+ // (2026-11-27 用户反馈)。热区自身的 click 一定会紧跟 mousedown 到来,不会漏。
4784
+ if (typeof e.target.closest === "function"
4785
+ && (e.target.closest(".balance-footer__today") !== null
4786
+ || e.target.closest(".balance-footer__timeline-meta") !== null
4787
+ || e.target.closest(".balance-footer__timeline-track") !== null
4788
+ // 左下角金额胶囊:点它是“刷新余额”,不是“关弹窗”。不放白名单的话,
4789
+ // 一点先把弹窗关掉,看起来就像它自己没了(用户:「我点了下左下角就消失了」)。
4790
+ || e.target.closest(".balance-footer__value") !== null
4791
+ // 胶囊上面还盖着两层(擦除层 / 刷新白光层),点到它们也算点胶囊。
4792
+ || e.target.closest(".balance-footer__reveal") !== null
4793
+ || e.target.closest(".balance-footer__wave") !== null)) {
4794
+ return;
4795
+ }
4796
+ requestClose();
4797
+ };
4798
+ window.addEventListener("keydown", onKey);
4799
+ window.addEventListener("mousedown", onDown, true);
4800
+ return () => {
4801
+ window.removeEventListener("keydown", onKey);
4802
+ window.removeEventListener("mousedown", onDown, true);
4803
+ };
4804
+ }, [requestClose]);
4805
+ // ⚠️ 首帧(box === null)必须是**完整结构**,只差定位 ——
4806
+ // 原来只渲染 title,少了 subtitle 那一行,量出来的高度比真实矮 ~16px,
4807
+ // top 就少减了这 16px,小窗底边正好压住被点的那一行(2026-11-26 截图)。
4808
+ // visibility:hidden 仍然保留,所以这一帧看不到、也不会闪。
4809
+ const style = box === null
4810
+ ? { left: "-9999px", top: "-9999px", visibility: "hidden" }
4811
+ : { left: box.left + "px", top: box.top + "px", "--balance-pop-arrow": box.arrow + "px" };
4812
+ return jsx.jsx("div", {
4813
+ ref,
4814
+ className: "balance-pop" + (closing ? " balance-pop--closing" : "")
4815
+ + (box !== null && !box.above ? " balance-pop--below" : "")
4816
+ + (wide ? " balance-pop--wide" : ""),
4817
+ style,
4818
+ onMouseDown: (e) => e.stopPropagation(),
4819
+ children: [
4820
+ jsx.jsxs("div", {
4821
+ className: "balance-pop__head",
4822
+ children: [
4823
+ jsx.jsxs("div", {
4824
+ style: { minWidth: 0 },
4825
+ children: [
4826
+ jsx.jsx("h3", { className: "balance-pop__title", children: title }),
4827
+ subtitle ? jsx.jsx("p", { className: "balance-pop__sub", children: subtitle }) : null,
4828
+ ],
4829
+ }),
4830
+ // 右上角左侧的额外控件(目前只有时间线的「常显」开关)。
4831
+ headExtra ? jsx.jsx("div", { className: "balance-pop__head-extra", children: headExtra }) : null,
4832
+ jsx.jsx("button", {
4833
+ className: "balance-pop__close",
4834
+ type: "button",
4835
+ onClick: requestClose,
4836
+ "aria-label": "关闭",
4837
+ children: "×",
4838
+ }),
4839
+ ],
4840
+ }),
4841
+ jsx.jsx("div", { className: "balance-pop__body", children }),
4842
+ ],
4843
+ });
4844
+ }
4845
+
4846
+ /** 今日各对话花了多少:按金额降序,末位单列插件自耗(同步费不属于任何会话)。 */
4847
+ function TodayBreakdown({ today, onClose, anchorRect, bare }) {
4848
+ const rows = react.useMemo(() => {
4849
+ const map = today && today.bySession && typeof today.bySession === "object" ? today.bySession : {};
4850
+ const titles = today && today.sessionTitles && typeof today.sessionTitles === "object" ? today.sessionTitles : {};
4851
+ const list = Object.keys(map).map((id) => {
4852
+ const rec = map[id] || {};
4853
+ return {
4854
+ id,
4855
+ title: typeof titles[id] === "string" && titles[id] !== "" ? titles[id] : "(未命名会话)",
4856
+ cost: Number(rec.cost) || 0,
4857
+ tokens: Number(rec.totalTokens) || 0,
4858
+ };
4859
+ });
4860
+ list.sort((a, b) => b.cost - a.cost);
4861
+ return list;
4862
+ }, [today]);
4863
+ const pluginCost = Number(today && today.pluginCost) || 0;
4864
+ const pluginCalls = Number(today && today.pluginCalls) || 0;
4865
+ // 网页工具费:同样不在任何会话账上。不单列的话「合计 − 会话 − 同步」会剩一截
4866
+ // 没头没尾的差额,看起来就像数据没刷新(2026-11-27 用户:「怎么显示有延迟」)。
4867
+ const webCost = Number(today && today.webToolCost) || 0;
4868
+ const webCalls = (Number(today && today.webSearchCalls) || 0) + (Number(today && today.webFetchCalls) || 0);
4869
+ const total = Number(today && today.cost) || 0;
4870
+ const sessionTotal = rows.reduce((s, r) => s + r.cost, 0);
4871
+ const subtitle = rows.length + " 个会话 · 合计 " + popMoney(total)
4872
+ + "(会话 " + popMoney(sessionTotal)
4873
+ + (pluginCost > 0 ? " + 同步 " + popMoney(pluginCost) : "")
4874
+ + (webCost > 1e-9 ? " + 工具 " + popMoney(webCost) : "") + ")";
4875
+ const body = rows.length === 0 && pluginCost <= 0
4876
+ ? jsx.jsx("div", { className: "balance-pop__empty", children: "今天还没有消耗" })
4877
+ : jsx.jsxs(react.Fragment, {
4878
+ children: [
4879
+ rows.map((r) => jsx.jsxs("div", {
4880
+ className: "balance-pop__row",
4881
+ title: r.id,
4882
+ children: [
4883
+ jsx.jsx("span", { className: "balance-pop__swatch" }),
4884
+ jsx.jsx("span", { className: "balance-pop__name", children: r.title }),
4885
+ jsx.jsx("span", { className: "balance-pop__meta", children: popTokens(r.tokens) }),
4886
+ jsx.jsx("span", { className: "balance-pop__amount", children: popMoney(r.cost) }),
4887
+ ],
4888
+ }, r.id)),
4889
+ pluginCost > 0
4890
+ ? jsx.jsxs("div", {
4891
+ className: "balance-pop__row",
4892
+ title: "价格 / 节假日同步时插件自己发的模型调用(不在任何会话里)",
4893
+ children: [
4894
+ jsx.jsx("span", { className: "balance-pop__swatch balance-pop__swatch--plugin" }),
4895
+ jsx.jsx("span", { className: "balance-pop__name", children: "插件同步" }),
4896
+ jsx.jsx("span", { className: "balance-pop__meta", children: pluginCalls + " 次" }),
4897
+ jsx.jsx("span", { className: "balance-pop__amount", children: popMoney(pluginCost) }),
4898
+ ],
4899
+ }, "__plugin")
4900
+ : null,
4901
+ webCost > 1e-9
4902
+ ? jsx.jsxs("div", {
4903
+ className: "balance-pop__row",
4904
+ title: "网页搜索 / 抓取按次计费(不乘峰谷),不属于任何会话",
4905
+ children: [
4906
+ jsx.jsx("span", { className: "balance-pop__swatch balance-pop__swatch--web" }),
4907
+ jsx.jsx("span", { className: "balance-pop__name", children: "网页工具" }),
4908
+ jsx.jsx("span", { className: "balance-pop__meta", children: webCalls + " 次" }),
4909
+ jsx.jsx("span", { className: "balance-pop__amount", children: popMoney(webCost) }),
4910
+ ],
4911
+ }, "__web")
4912
+ : null,
4913
+ ],
4914
+ });
4915
+ // bare:只给内容,不套弹窗壳 —— 合并进「今日消耗时间线」那个面板时用
4916
+ // (2026-11-27 用户:「这两个浮窗合并吧 然后这两个选中改成整体」)。
4917
+ // ⚠️ 必须排在 useMemo 之后:这里 early return,hook 一条都不能漏在前面。
4918
+ // ⚠️ bare 模式也要渲染 subtitle。它写的是「N 个会话 · 合计 ¥x(会话 ¥a + 同步 ¥b)」,
4919
+ // 正是用来解释「累计」和下面几行会话合计之间的差额的。
4920
+ // 少了这一行,用户只会看到累计 ¥2.1399 而明细只加到 ¥2.1250,看着就像
4921
+ // 「插件同步的数据没跟上」(2026-11-27 用户:「这个插件同步的怎么显示有延迟」)。
4922
+ if (bare === true) {
4923
+ return jsx.jsxs("div", {
4924
+ children: [
4925
+ subtitle
4926
+ ? jsx.jsx("p", {
4927
+ className: "balance-pop__sub balance-pop__sub--inline",
4928
+ children: subtitle,
4929
+ })
4930
+ : null,
4931
+ body,
4932
+ ],
4933
+ });
4934
+ }
4935
+ return jsx.jsx(PopShell, {
4936
+ anchorRect,
4937
+ title: "今日消耗明细",
4938
+ subtitle,
4939
+ onClose,
4940
+ children: body,
4941
+ });
4942
+ }
4943
+
4944
+ /** 今日余额时间线:从「今日起始余额」一路降到当前余额,按小时采样。
4945
+ * 起始余额 = 当前余额 + 今日已消耗(反推),所以曲线终点必然落在当前余额上。 */
4946
+ /** 今日**累计消耗**时间线:从 0 一路涨到此刻花了多少(2026-11-26 用户:
4947
+ * 「时间线改成消费的吧」)。原来是余额下降曲线,反推出的起点不够直观,
4948
+ * 而且要先知道余额才能画;改成累计消费后纵轴就是「今天花了多少钱」,自洽。
4949
+ * ⚠️ 金额一律不放图里:小卡片里 SVG 会缩放,`text` 跟着缩,
4950
+ * 一长就挤成一团(用户截图「右上角数字被挡住了」)。金额全走 header 副标题。 */
4951
+ function BalanceTimeline({ today, balance, onClose, anchorRect }) {
4952
+ // ⚠️ 所有 hook 必须排在任何一个 return 之前。
4953
+ // clipId 原来写在「!model.ok 早退」之后:首次渲染 today 还是 null 只跑 1 个 hook,
4954
+ // today 到位后变成 2 个 → React 抛 "Rendered more hooks than during the previous render"
4955
+ // → 整棵组件树挂掉,左下角余额胶囊直接消失(2026-11-26 用户:「bug了 左下角没了」)。
4956
+ const clipId = react.useMemo(() => "balance-pop-clip-" + Math.random().toString(36).slice(2, 9), []);
4957
+ // 鼠标位置的悬停态:{ hour, acc, cost, label }。和 clipId 一样必须排在早退之前。
4958
+ const [hover, setHover] = react.useState(null);
4959
+ // 常显开关(2026-11-27 用户:「在这里添加一个小开关 是否要常显的功能」)。
4960
+ // ⚠️ 存 localStorage、不走插件设置文件:这是纯展示偏好,
4961
+ // 新版本覆盖安装、设置默认值重写都不会改变它(用户:
4962
+ // 「这个功能不跟随插件变动」)。默认开。
4963
+ // 胶囊上一次停在哪个小时:用来算归位动画的时长。
4964
+ // ⚠️ ref 必须和其他 hook 一起排在「if (!model.ok)」之前。
4965
+ // ⚠⚠ 初值只能是常量:这里离 nowHour(约 5180 行)还很远,
4966
+ // 写 nowHour 会撞 TDZ —— const 声明前引用直接 ReferenceError,
4967
+ // BalanceTimeline 一渲染就崩,整个下左角点不开(2026-11-27 用户:
4968
+ // 「现在完全点不开了」)。-1 = 还没定过位。
4969
+ const lastTipHourRef = react.useRef(-1);
4970
+ const [tipAlways, setTipAlwaysBase] = react.useState(() => {
4971
+ try { return localStorage.getItem("balance-tip-always") !== "0"; } catch { return true; }
4972
+ });
4973
+ const setTipAlways = react.useCallback(() => {
4974
+ setTipAlwaysBase((v) => {
4975
+ const next = !v;
4976
+ try { localStorage.setItem("balance-tip-always", next ? "1" : "0"); } catch { /* 私有模式下忽略 */ }
4977
+ return next;
4978
+ });
4979
+ }, []);
4980
+ // y 轴换档的缩放起点(上一档 / 这一档:¥1→¥2 是 .5,¥2→¥5 是 .4)。
4981
+ // ⚠️ 必须和 clipId / hover 一样排在 model.ok 早退**之前**:
4982
+ // 首次渲染 today 还是 null、只跑到早退,数据一到又多出这两个 hook,
4983
+ // React 会抛 Rendered more hooks than during the previous render,
4984
+ // 整个小窗连图表一起消失。这个坑已经踩过两次了。
4985
+ // ── 个人调试:时间加快,直接看挡位缩放动画──
4986
+ // 开关:控制台执行 localStorage.setItem("balance-debug-zoom", "1") 后刷新;
4987
+ // 关 回去用 removeItem。也认 window.__balanceDebugZoom = true。
4988
+ // 开了之后 y 轴上界每 1.6 秒在这几档之间跳,动画连着播,
4989
+ // 不用真等金额涨到跳档。不影响真实数据。
4990
+ const [debugTick, setDebugTick] = react.useState(0);
4991
+ const debugZoom = react.useMemo(() => {
4992
+ try {
4993
+ if (typeof window !== "undefined" && window.__balanceDebugZoom === true) return true;
4994
+ return localStorage.getItem("balance-debug-zoom") === "1";
4995
+ } catch { return false; }
4996
+ }, []);
4997
+ react.useEffect(() => {
4998
+ if (!debugZoom) return undefined;
4999
+ const t = setTimeout(() => setDebugTick((n) => n + 1), 1600);
5000
+ return () => clearTimeout(t);
5001
+ }, [debugZoom, debugTick]);
5002
+ const prevMaxYRef = react.useRef(0);
5003
+ react.useEffect(() => { prevMaxYRef.current = maxY; });
5004
+ const model = react.useMemo(() => {
5005
+ const hourly = Array.isArray(today && today.hourly) ? today.hourly : [];
5006
+ if (hourly.length === 0) {
5007
+ return {
5008
+ ok: false,
5009
+ reason: today == null ? "正在加载今日数据…" : "这一版服务端还没返回按小时的用量,重启 DSH 后可用",
5010
+ };
5011
+ }
5012
+ // ⚠️ 不能拿数组下标当小时。buildHourlySlots 现在是铺满 24 格的密集数组,
5013
+ // 但快照里的旧数据不一定 —— 一律按 slot.hour 归位,缺的小时补 0。
5014
+ const byHour = new Array(24).fill(0);
5015
+ for (const slot of hourly) {
5016
+ const h = Number(slot && slot.hour);
5017
+ if (!Number.isInteger(h) || h < 0 || h > 23) continue;
5018
+ byHour[h] += Number(slot && slot.cost) || 0;
5019
+ }
5020
+ // 5 分钟粒度(服务端 byStep):钱**真正发生在哪一段**就落在哪一段。
5021
+ // 原来只有 hourly,只能把整小时的量平均摊成 12 段 —— 长时间没动、10:11 突然花一笔,
5022
+ // 摊完就成了「10:00 起匀速爬坡」,和事实不符
5023
+ // (2026-11-27 用户:「有的时候不用平摊 比如 我很长时间没用 但是在10:11分产生消耗
5024
+ // 就要指定在这个时间段」)。有 steps 就按它落位,没有才退回平摊。
5025
+ const stepCost5 = new Array(1440).fill(0);
5026
+ let hasStepData = false;
5027
+ for (const it of Array.isArray(today && today.steps) ? today.steps : []) {
5028
+ const k = Math.floor(Number(it && it.step));
5029
+ if (!Number.isInteger(k) || k < 0 || k > 1439) continue;
5030
+ const v = Number(it && it.cost) || 0;
5031
+ if (Math.abs(v) < 1e-12) continue;
5032
+ stepCost5[k] += v;
5033
+ hasStepData = true;
5034
+ }
5035
+ // 差额**按比例**摊到有消耗的小时上:hourly 只统计会话消耗,今日总额里还有同步费用
5036
+ // 这类没记到小时上的钱,不摊的话 hover 到 23:00 的累计会永远比副标题那行「累计 ¥x」少一截。
5037
+ // ⚠️ 绝不能按时钟线性摊(之前那版就是):那样没消耗的小时也会凭空冒出钱,
5038
+ // 05:08 显示「本小时 ¥0.0028」,一点参考意义都没有
5039
+ // (2026-11-26 用户:「如果没有实际消耗的 就不要计算值了 有问题 我要的是仅供参考」)。
5040
+ // 按比例缩放的三个好处:形状不变、总和等于今日总额、0 消耗的小时恒为 0。
5041
+ const dayTotal = Number(today && today.cost) || 0;
5042
+ const hourlySum = byHour.reduce((s, v) => s + v, 0);
5043
+ const scale = hourlySum > 1e-9 && dayTotal > hourlySum + 1e-9 ? dayTotal / hourlySum : 1;
5044
+ // 采样粒度 = **5 分钟**(2026-11-27 用户:「每小时分成 12 段 就是从 0 点开始
5045
+ // 0 点 5 分 0 点 10 分 以此类推」)。每小时的钱平均分成 12 份,
5046
+ // 于是折线上 0:00 / 0:05 / 0:10 … 都落在真实的数据点上,
5047
+ // 而不是像小时粒度那样在 0:00→1:00 之间硬插一条直线
5048
+ // (那样 0:04 会报 ¥0.08,而这一小时实际已经花了 ¥1.20)。
5049
+ // 改粒度只动 STEP_MIN,STEPS 和下面所有换算都跟着走。
5050
+ const STEP_MIN = 1;
5051
+ const STEPS_PER_HOUR = 60 / STEP_MIN;
5052
+ const STEPS = 24 * STEPS_PER_HOUR;
5053
+ let acc = 0;
5054
+ const pts = [{ at: 0, acc: 0 }];
5055
+ if (hasStepData) {
5056
+ // ⚠️ 两种画法**按小时各自选**(2026-11-27 用户:「有的时候不用平摊 有的时候需要平摊」):
5057
+ // · 那个小时有 ≥ SPREAD_MIN_STEPS 个非零段(持续在跑)→ **摊开**,
5058
+ // 否则一小时里挖出几个孤零零的台阶,看着像数据坏了;
5059
+ // · 只有一两段有钱(长时间没用、某一刻突然花一笔)→ **精确落位**,
5060
+ // 摊开会把 10:11 那一笔抹成「10:00 起匀速爬坡」,和事实不符。
5061
+ // 两种都按该小时自己的 step 小计做基准,逐时守恒,加起来仍等于今日总额。
5062
+ const SPREAD_MIN_STEPS = 20;
5063
+ const hourStepSum = new Array(24).fill(0);
5064
+ const hourStepCount = new Array(24).fill(0);
5065
+ for (let k = 0; k < STEPS; k += 1) {
5066
+ const h = Math.floor(k / STEPS_PER_HOUR);
5067
+ hourStepSum[h] += stepCost5[k];
5068
+ if (stepCost5[k] > 1e-12) hourStepCount[h] += 1;
5069
+ }
5070
+ const stepSum = hourStepSum.reduce((s, v) => s + v, 0);
5071
+ const stepScale = stepSum > 1e-9 && dayTotal > stepSum + 1e-9 ? dayTotal / stepSum : 1;
5072
+ for (let k = 0; k < STEPS; k += 1) {
5073
+ const h = Math.floor(k / STEPS_PER_HOUR);
5074
+ const v = hourStepCount[h] >= SPREAD_MIN_STEPS
5075
+ ? (hourStepSum[h] * stepScale) / STEPS_PER_HOUR
5076
+ : stepCost5[k] * stepScale;
5077
+ acc += v;
5078
+ pts.push({ at: (k + 1) * STEP_MIN / 60, acc });
5079
+ }
5080
+ } else {
5081
+ // 服务端没给 steps(旧版本 / 旧快照):退回整小时平摊
5082
+ for (let k = 0; k < STEPS; k += 1) {
5083
+ acc += (byHour[Math.floor(k / STEPS_PER_HOUR)] * scale) / STEPS_PER_HOUR;
5084
+ pts.push({ at: (k + 1) * STEP_MIN / 60, acc });
5085
+ }
5086
+ }
5087
+ // ⚠️ 累计终值不能小于今日总额。hourly 全空但 today.cost 有钱的时候
5088
+ // (新的一天刚开、分小时数据还没写进来,或者钱全在 pluginCost 上),
5089
+ // byHour 全是 0 ⇒ acc 恒 0,副标题就会显示「累计 ¥0.0000 · 今天还没有消耗」,
5090
+ // 而实际上有消耗 —— 用户看到的就是「怎么看不到消耗」(2026-11-26)。
5091
+ // 曲线仍然按真实 acc 画(没数据就是贴底的虚线),只有这个标量兜底。
5092
+ const total = Math.max(acc, dayTotal);
5093
+ // 纵轴上界:至少 1 分钱,免得今天零消耗时除 0。
5094
+ // 上界 = 总额**向上取到「还没到的下一级刻度」**,只多抬这一级
5095
+ // (2026-11-27 用户:「不用全显示 刚刚那样挺好的 没到就先别显示 只显示没到的下一级」)。
5096
+ // ¥3.74 → ¥4 → 刻度 1/2/3/4(3.74 已过 3,下一级是 4)
5097
+ // ¥5.00 → ¥5 → 刻度 1..5
5098
+ // ¥5.50 → ¥10 → 5~20 这一档每 5,下一级就是 10,中间没有 6/7/8/9
5099
+ // 早前那版直接抬到档位「边界」(¥3.74 → ¥5),等于把没到的两级也画出来,太满。
5100
+ const maxY = (() => {
5101
+ const t = total > 1e-9 ? total : 0.01;
5102
+ if (t <= 5) return Math.ceil(t);
5103
+ if (t <= 20) return Math.ceil(t / 5) * 5;
5104
+ if (t <= 50) return Math.ceil(t / 10) * 10;
5105
+ return Math.ceil(t / 100) * 100;
5106
+ })();
5107
+ return { ok: true, pts, total, maxY, hourly: byHour, scale, STEP_MIN, STEPS_PER_HOUR, STEPS, activeHours: byHour.filter((v) => v > 0).length };
5108
+ }, [today]);
5109
+ // ⚠️ 必须在 model 之后(读它的字段)、但在 model.ok 早退之前。
5110
+ // 上一版插在了另一个 useMemo 后面,model 还在临时性死区 →
5111
+ // 一点左下角就崩(用户:「又崩了」)。
5112
+ const DEBUG_MAX_Y = [2, 5, 10, 20, 50, 12, 4];
5113
+ const targetMaxY = model.ok ? (debugZoom ? DEBUG_MAX_Y[debugTick % DEBUG_MAX_Y.length] : model.maxY) : 0;
5114
+ // ── 逐帧插值纵轴上限 ──
5115
+ // ⚠️ 必须排在 model.ok 早退**之前**:否则首次渲染(数据还没到)
5116
+ // 这两个 hook 不跑,数据一到突然多跑两个 → Rendered more hooks than
5117
+ // during the previous render,整个图直接崩(2026-11-27 用户:「bug了」)。
5118
+ const [animMaxY, setAnimMaxY] = react.useState(0);
5119
+ // y 轴数字的滚入动画开关:**首次挂载(打开浮窗)不播**,
5120
+ // 只有金额上界真的换档(缩放)时才允许。
5121
+ // 不这样阻一下的话,CSS 动画会在每次新节点挂载时自动播放。
5122
+ const [labelAnim, setLabelAnim] = react.useState(false);
5123
+ const prevLabelMaxRef = react.useRef(targetMaxY);
5124
+ react.useEffect(() => {
5125
+ const to = targetMaxY;
5126
+ if (to <= 1e-9) return undefined;
5127
+ const from = animMaxY > 1e-9 ? animMaxY : to;
5128
+ if (Math.abs(from - to) < 1e-9) { if (animMaxY !== to) setAnimMaxY(to); return undefined; }
5129
+ const STEPS = 20;
5130
+ let i = 0;
5131
+ let timer = null;
5132
+ const tick = () => {
5133
+ i += 1;
5134
+ const t = i / STEPS;
5135
+ const e = 1 - Math.pow(1 - t, 3); // ease-out,不过冲
5136
+ setAnimMaxY(i >= STEPS ? to : from + (to - from) * e);
5137
+ if (i < STEPS) timer = setTimeout(tick, 26);
5138
+ };
5139
+ timer = setTimeout(tick, 26);
5140
+ return () => clearTimeout(timer);
5141
+ }, [targetMaxY]);
5142
+ // 档位(targetMaxY)真的变了才把数字动画开着;一开就一直开,
5143
+ // 后续靠 key 重挂触发播放。首次挂载时两者相等,不会置 true。
5144
+ react.useEffect(() => {
5145
+ if (prevLabelMaxRef.current === targetMaxY) return;
5146
+ prevLabelMaxRef.current = targetMaxY;
5147
+ setLabelAnim(true);
5148
+ }, [targetMaxY]);
5149
+ // 实际用的上限:插值中用插值值,否则用目标值。
5150
+ // ⚠️ 必须在 animMaxY 之后(上一版在前面 → TDZ)。
5151
+ const maxY = animMaxY > 1e-9 ? animMaxY : (targetMaxY || 1);
5152
+ if (!model.ok) {
5153
+ return jsx.jsx(PopShell, {
5154
+ anchorRect,
5155
+ title: "今日消耗时间线",
5156
+ subtitle: "0:00 → 现在",
5157
+ onClose,
5158
+ children: jsx.jsx("div", { className: "balance-pop__empty", children: model.reason }),
5159
+ });
5160
+ }
5161
+ // W 跟着卡片 498 走(内容宽 ~474),别留太多缩放,1px 线会发虚;
5162
+ // 加宽是为了让「每小时 60 分钟」在横轴上真的分得开(2026-11-27 用户:
5163
+ // 「每小时拆成60份 然后可以拉长一点 显示的全一点」)。
5164
+ const W = 494;
5165
+ // 高度 116:色块 306×90,宽高比 ~3.4:1。
5166
+ // 124 是「太高了」那版(2.7:1 偏方),100 是更早「扁得厉害」那版(3.5:1)。
5167
+ // 高度 116 → 128(2026-11-27):上面多出来的 12px 给纵轴最顶一档刻度。
5168
+ // 原来 PAD_T = 6,顶档(maxY)的 baseline 只能在 11,11px 字的顶部落在 2px:
5169
+ // 几乎贴着 SVG 上沿,看上去就是「最顶上的刻度被切了一半」
5170
+ // (2026-11-27 用户两次:「最顶上的刻度」「顶上还是这样啊」)。
5171
+ const H = 128;
5172
+ // 2026-11-26 用户:「外面的框不要了」—— 只剩带圆角的色带本身,
5173
+ // FRAME 现在只表示「绘图区到 SVG 边缘的留白」,不再画任何边框。
5174
+ const FRAME_L = 2;
5175
+ const FRAME_T = 2;
5176
+ const FRAME_R = 2;
5177
+ const FRAME_B = 16; // 下面留给坐标轴
5178
+ const FRAME_W = W - FRAME_L - FRAME_R;
5179
+ const FRAME_H = H - FRAME_T - FRAME_B;
5180
+ // 横向留白由两端刻度定:去掉外框之后色块就是最外层,
5181
+ // 「0:00」「24:00」这两个标签得完整落在可见区里(2026-11-26 用户:
5182
+ // 「保证0点1分和23点59分显示全就行了 可以多一点点 为了显示清除」)。
5183
+ // 16 + 4 让两端标签各留出 ~16px,label 不会贴到卡片边缘。
5184
+ // ⚠️ 26 不是 16:这里同时要容下左侧的金额刻度。
5185
+ // 刻度是 textAnchor="end" 贴在 x = PAD_L - 2,「¥15」在 11px 字下宽约 23px,
5186
+ // 16 只够「¥5」(约 17px)—— 多一位就从画布左边被裁掉。
5187
+ // 用户截图里「¥15」只剩一半,看上去就是「顶部刻度看不清」
5188
+ // (2026-11-27 用户:「顶部的刻度」)。
5189
+ const INSET_X = 26;
5190
+ // 上下内缩不对称已不可行:下面要留给时间轴,上面要留给顶档刻度。
5191
+ // 14 让 PAD_T = 16,顶档 baseline 落在 19 左右,字顶离上沿 ~11px,彻底不碰边。
5192
+ const INSET_Y = 14;
5193
+ const PAD_L = FRAME_L + INSET_X;
5194
+ const PAD_T = FRAME_T + INSET_Y;
5195
+ const plotW = FRAME_W - INSET_X * 2;
5196
+ const plotH = FRAME_H - INSET_Y * 2;
5197
+ // ⚠️ 与 xPlot 同式 **必须保持**。曾经 xOf 不内缩、xPlot 内缩 8px,
5198
+ // 两套坐标只在 12:00 重合:用户对着 9 点的分隔线指,悬停读数却是 08:53
5199
+ // (2026-11-27 用户:「这时间不对吧 我都对齐了 怎么是8:51」)。
5200
+ // 现在色块 / 竖分隔线 / 横网格 / 折线 / 绿点 / 轴刻度 全部走这一个坐标。
5201
+ // xOf = 色块的外缘(铺满绘制区,左右各留 PLOT_PAD_X 的肉)
5202
+ // xPlot = 数据座标(折线 / 绿点 / 轴刻度 / 悬停换算 / 分隔线)
5203
+ // 两套坐标只在**色块两端**差 8px,中间的分界全部走 xPlot,
5204
+ // 所以对着分隔线指一定读得准(2026-11-27 用户:「这时间不对吧」)。
5205
+ const xOf = (h) => PAD_L + (Math.max(0, Math.min(24, h)) / 24) * plotW;
5206
+ // 数据图元(曲线 / 圆点 / 竖线 / 刻度)要在两端再内缩 PLOT_PAD_X:
5207
+ // 色块是 8px 圆角,0 点的白点和竖线正好压在圆角上被裁掉一半
5208
+ // (2026-11-26 用户:「0点的时候 被圆角挡住了 可以往左右两边留点余量 保证都在色块内」)。
5209
+ // 内缩值取圆角半径:圆心落在圆角圆心正上/正下方,整颗点都在色块内。
5210
+ // ⚠️ 色带和分隔线仍用 xOf —— 色块必须铺满绘图区,内缩了会露出背景。
5211
+ const PLOT_PAD_X = 8;
5212
+ const xPlot = (h) => PAD_L + PLOT_PAD_X + (Math.max(0, Math.min(24, h)) / 24) * (plotW - PLOT_PAD_X * 2);
5213
+ // 累计消费是**向上长**的:0 贴底、total 贴顶。
5214
+ // 最低点要比裁剪边界高 1px —— 曲线贴底那一段正好落在 clip 边界上,
5215
+ // 1.8px 描边有一半被裁掉,看起来就和升上去那截不是一个颜色。
5216
+ const plotBase = PAD_T + plotH - 1;
5217
+ // 调试档位循环:真实 maxY 不变,只覆盖纵轴上界(连带刻度一起)。
5218
+ const yOf = (v) => {
5219
+ const t = Math.max(0, Math.min(1, v / maxY));
5220
+ return PAD_T + (1 - t) * (plotH - 1);
5221
+ };
5222
+ // 没有任何一个时段有消耗时,曲线是一条贴着底边的水平线,和色块下边框糊在一起 ——
5223
+ // 看着像「图表没数据 / 坏了」(2026-11-26 用户截图问:「这个情况怎么看不到消耗」)。
5224
+ // 这种情况改画虚线:表示「有图,但没有分小时的数据」,而不是「花了 0 元」。
5225
+ // ⚠️ 判据是 activeHours,不是 total —— 钱的分布可能全在 pluginCost 上
5226
+ // (total > 0 但每小时都是 0),这时候贴底的实线同样是在骗人。
5227
+ const isZero = model.activeHours === 0;
5228
+ // 只画已经发生的那一段(终点是「此刻」,不是 24:00)
5229
+ const nowBJT = new Date(Date.now() + 8 * 3600000);
5230
+ const nowHour = nowBJT.getUTCHours() + nowBJT.getUTCMinutes() / 60;
5231
+ const clipped = model.pts.filter((p) => p.at <= nowHour + 1e-9);
5232
+ // ⚠️ 曲线必须画到**此刻**,不能只截到最后一个整点。
5233
+ // pts 是每小时一个点,只 filter 的话终点落在 23:00;而悬停上限是 nowHour(23:52),
5234
+ // 中间那 52 分钟没有线、悬停却有数字 —— 看着就像在算还没发生的钱
5235
+ // (2026-11-26 用户指着 24:00 附近:「怎么还算没有的东西」)。
5236
+ // 这里补一个 at = nowHour 的插值点,线、白点、可悬停范围三者对齐。
5237
+ {
5238
+ const tailAt = Math.max(0, Math.min(24, nowHour));
5239
+ const lastAt = clipped.length > 0 ? clipped[clipped.length - 1].at : -1;
5240
+ if (tailAt > 1e-9 && tailAt - lastAt > 1e-9) {
5241
+ // 索引按 **5 分钟段** 算(STEPS_PER_HOUR 段 = 1 小时)
5242
+ const sp = model.STEPS_PER_HOUR || 60;
5243
+ const kIdx = Math.min(model.STEPS || 1440, Math.floor(tailAt * sp));
5244
+ const p0 = model.pts[kIdx] ? model.pts[kIdx].acc : 0;
5245
+ clipped.push({ at: tailAt, acc: p0 });
5246
+ }
5247
+ }
5248
+ // 折线上的采样点标记。曲线已是**1 分钟**粒度(见 STEP_MIN),打点仍按 5 分钟一个
5249
+ // (DOT_STRIDE)—— 一分钟一颗的话一小时 60 颗、凌晨那截直接糊成实线。
5250
+ // 打点的语义是「这一段有数据」,不是「这里是采样边界」。只打有消耗的小时。
5251
+ // 逐帧插值纵轴上限:每一帧都用真实坐标重算,
5252
+ // 所以描边粗细、圆点大小、文字字号全都不变,变的只是位置。
5253
+ // 用 setTimeout 递归(DSH 里 rAF 会被挂起)。20 帧 × 26ms ≈ 520ms。
5254
+ // transition 需要两个帧:先拿起点渲染一次,下一帧才改成 1。
5255
+ // 不这样做的话,两个值在同一次渲染里写完,浏览器只看到终值、不播过渡。
5256
+ // 两拍:
5257
+ // 1. 先把位移瞬时摆到 yShift、并把 transition 关掉 — — 否则起点这一帧自己就在动,
5258
+ // 看上去是只滑了 1/20 就被拉回 0(用户:「还是一帧一帧的」)。
5259
+ // 2. 下一拍开 transition、改回 0 — — 这一次才是真正要看的那段滚动。
5260
+ const last = clipped.length > 0 ? clipped[clipped.length - 1] : model.pts[0];
5261
+ // 折线在每小时一个采样点,画出来是硬拐角(2026-11-26 用户:「线段有点丑 拐弯太生硬了」)。
5262
+ // 用 Fritsch–Carlson 单调三次插值:普通 Catmull-Rom 会在台阶前后过冲,
5263
+ // 画成「先回弹再冲上去」,而累计消耗只增不减,过冲就是假的。
5264
+ const dl = (() => {
5265
+ const n = clipped.length;
5266
+ if (n === 0) return "";
5267
+ const xs = clipped.map((p) => xPlot(p.at));
5268
+ const ys = clipped.map((p) => yOf(p.acc));
5269
+ // 起点的**水平引线**(2026-11-27 用户:「给初始画平的绿线 这样就不像从下面直接冲出来的感觉」)。
5270
+ // xPlot(0) 落在 PAD_L + PLOT_PAD_X,绘图区最左那 8px 一直是空的,曲线等于在
5271
+ // 离边缘 8px 处凭空冒出来。把首点钉到 PAD_L 正好吃掉这 8px:
5272
+ // 于是先平一小段、再按真实斜率上升,起点落在色块左缘上。
5273
+ // ⚠️ 只改首点的 x,不动 at —— 悬停、打点、颜色带全部按 at 取,不受影响。
5274
+ xs[0] = PAD_L;
5275
+ if (n === 1) return "M" + xs[0].toFixed(2) + " " + ys[0].toFixed(2);
5276
+ const dx = [];
5277
+ const d = [];
5278
+ for (let i = 0; i < n - 1; i += 1) {
5279
+ dx.push(xs[i + 1] - xs[i]);
5280
+ d.push(dx[i] === 0 ? 0 : (ys[i + 1] - ys[i]) / dx[i]);
5281
+ }
5282
+ // 切线:中间取相邻差分的平均,变号(平台/拐点)就压成 0
5283
+ const m = new Array(n);
5284
+ // 起点切线归零 = 水平入弯(2026-11-27 用户:「弯曲地方要点圆过度」)。
5285
+ // 原来是 m[0] = d[0](直接用首段斜率),于是曲线从 0 点冲出来那一下
5286
+ // 是个硬拐角;归零之后首段从平缓加速,接上真实斜率时已经是弧线。
5287
+ // 限制器会把 m[1] 一并压低(a=m[0]/d[0]=0),所以起段不会过冲。
5288
+ m[0] = 0;
5289
+ m[n - 1] = d[n - 2];
5290
+ for (let i = 1; i < n - 1; i += 1) {
5291
+ m[i] = d[i - 1] * d[i] <= 0 ? 0 : (d[i - 1] + d[i]) / 2;
5292
+ }
5293
+ // 限制器:保证 α²+β² ≤ 9,否则陡升段仍会轻微过冲
5294
+ for (let i = 0; i < n - 1; i += 1) {
5295
+ if (d[i] === 0) { m[i] = 0; m[i + 1] = 0; continue; }
5296
+ const a = m[i] / d[i];
5297
+ const b = m[i + 1] / d[i];
5298
+ const sq = a * a + b * b;
5299
+ if (sq > 9) {
5300
+ const t = 3 / Math.sqrt(sq);
5301
+ m[i] = t * a * d[i];
5302
+ m[i + 1] = t * b * d[i];
5303
+ }
5304
+ }
5305
+ let out = "M" + xs[0].toFixed(2) + " " + ys[0].toFixed(2);
5306
+ for (let i = 0; i < n - 1; i += 1) {
5307
+ const h = dx[i] / 3;
5308
+ out += "C" + (xs[i] + h).toFixed(2) + " " + (ys[i] + m[i] * h).toFixed(2)
5309
+ + " " + (xs[i + 1] - h).toFixed(2) + " " + (ys[i + 1] - m[i + 1] * h).toFixed(2)
5310
+ + " " + xs[i + 1].toFixed(2) + " " + ys[i + 1].toFixed(2);
5311
+ }
5312
+ return out;
5313
+ })();
5314
+ // 峰谷色带:逐小时扫 currentPeriod,把连续同类时段合并成一段。
5315
+ // 2026-11-26 用户:「高峰和空闲的颜色呢」—— 光靠虚竖线只能看清分界,
5316
+ // 看不出哪一段是高峰,所以底色要跟上。
5317
+ const dayStart = dayStartOf(Date.now());
5318
+ const bands = [];
5319
+ let prevKind = currentPeriod(dayStart);
5320
+ let segStart = 0;
5321
+ for (let h = 1; h <= 24; h += 1) {
5322
+ const kind = h === 24 ? "" : currentPeriod(dayStart + h * 3600000);
5323
+ if (kind !== prevKind) {
5324
+ bands.push({ from: segStart, to: h, kind: prevKind });
5325
+ segStart = h;
5326
+ if (h < 24) prevKind = kind;
5327
+ }
5328
+ }
5329
+ const dividers = bands.filter((b) => b.to < 24).map((b) => b.to);
5330
+ // y 轴横向刻度:步长**阶梯式**,钱越多格子越疏
5331
+ // (2026-11-27 用户:「加入5块之前每1块为一个刻度 5块之后每5块一个刻度 20之后就改成10块
5332
+ // 一个刻度 50之后就每100一个刻度」)。
5333
+ // 0~5 每 1
5334
+ // 5~20 每 5
5335
+ // 20~50 每 10
5336
+ // 50+ 每 100
5337
+ // 只画网格线,**不在图里写数字** —— 金额一律靠悬停胶囊报,
5338
+ // 画在 SVG 里会连同曲线一起被裁、还会和刻度标签抢空间。
5339
+ // ⚠️ 刻度**数值**用目标档位,不能用插值中的 maxY:插值期间 maxY 每帧都变,
5340
+ // 数值跟着重算就会一直跳(2026-11-27 用户:「就是这种效果 但是数字会跳动」)。
5341
+ // 位置仍然走 yOf(分母是插值中的 maxY),所以刻度是平滑移动的。
5342
+ const yTicks = (() => {
5343
+ const top = targetMaxY || 1;
5344
+ const raw = [];
5345
+ // ⚠️ 用 <= :maxY 已经取整到档位边界(¥3.74 → ¥5),顶档那一条必须画得出来,
5346
+ // 否则轴顶到 5 却只标到 4,用户还是觉得「刻度不全」。
5347
+ const add = (v) => { if (v > 1e-9 && v <= top + 1e-9) raw.push(v); };
5348
+ for (let v = 1; v <= 5; v += 1) add(v);
5349
+ for (let v = 10; v <= 20; v += 5) add(v);
5350
+ for (let v = 30; v <= 50; v += 10) add(v);
5351
+ for (let v = 150; v < top; v += 100) add(v);
5352
+ // 密集处省略:上限一大,1/2/3/4/5 就全挤在底部几十像素里,一堆数字反而
5353
+ // 看不清。按**像素间距**过滤:距上一条不足 MIN_TICK_GAP 就跳过
5354
+ // (2026-11-27 用户:「到密集的时候 可以省略密集处的刻度」)。
5355
+ // 距离用 top(目标档位)算,不用插值中的 maxY,否则每帧过滤结果不一样、又会跳。
5356
+ const MIN_TICK_GAP = 11;
5357
+ const denom = top > 1e-9 ? top : 1;
5358
+ const out = [];
5359
+ let lastY = Infinity;
5360
+ for (const v of raw) {
5361
+ const y = PAD_T + (1 - v / denom) * (plotH - 1);
5362
+ if (Math.abs(y - lastY) < MIN_TICK_GAP) continue;
5363
+ out.push(v);
5364
+ lastY = y;
5365
+ }
5366
+ return out;
5367
+ })();
5368
+ // 左侧**标签**只留两条:顶档 + 接近一半的那档(网格线仍然按 yTicks 全画)。
5369
+ // 2026-11-27 用户:「不用显示所有消耗刻度」—— 四个数字(¥10 ¥5 ¥3 ¥1)挤在
5370
+ // 90px 高的绘图区左边,比曲线本身还抢眼。
5371
+ const yLabels = (() => {
5372
+ const top = targetMaxY || 1;
5373
+ const ticks2 = yTicks;
5374
+ if (ticks2.length === 0) return [top];
5375
+ const half = top / 2;
5376
+ let pick = null;
5377
+ for (const v of ticks2) {
5378
+ if (v >= top - 1e-9) continue;
5379
+ if (pick === null || Math.abs(v - half) < Math.abs(pick - half)) pick = v;
5380
+ }
5381
+ return pick === null ? [top] : [pick, top];
5382
+ })();
5383
+ // 内层圆角 8(比外框的 12 小一档):2026-11-26 用户「算了还是加圆角吧 里面的色块可以延申一点点」。
5384
+ const R = 8;
5385
+ const ticks = [0, 6, 12, 18, 24];
5386
+ // 两端标签往内收几像素:色块从 PAD_L 起,「0:00」用 textAnchor=start 时
5387
+ // 字头正好压在色块边界上,看着像跑出界(2026-11-26 用户:「让时间在色块内」)。
5388
+ const TICK_NUDGE = 6;
5389
+ // 鼠标横向位置 → 小时。preserveAspectRatio=none 只影响绘制,
5390
+ // getBoundingClientRect 拿到的是实际像素宽度,反解回 viewBox 坐标即可。
5391
+ // ⚠️ 只接受有限数字并取整:任何非法值都会渲染成 "01e-9" / "NaN" 这种垃圾
5392
+ const pad2 = (n) => {
5393
+ const v = Math.round(Number(n)) || 0;
5394
+ return v < 10 ? "0" + v : "" + v;
5395
+ };
5396
+ // 当前那个小时的已知消耗。
5397
+ // ⚠️ 现在是按 hourly 直取,不再用 pts 相邻差 —— pts 已经加密到 5 分钟一段,
5398
+ // pts[i+1]-pts[i] 变成「那 5 分钟的一份」,不是整小时了。
5399
+ const currentHourCost = (() => {
5400
+ const i = Math.min(23, Math.max(0, Math.floor(nowHour)));
5401
+ return (model.hourly[i] || 0) * (model.scale || 1);
5402
+ })();
5403
+ const onHoverMove = (event) => {
5404
+ const rect = event.currentTarget.getBoundingClientRect();
5405
+ if (!(rect.width > 0)) return;
5406
+ const userX = ((event.clientX - rect.left) / rect.width) * W;
5407
+ // ⚠️ 必须用 xPlot 的逆,不能用 xOf 的逆。
5408
+ // 绘制时两端各内缩 PLOT_PAD_X(8px,给色块圆角让位),
5409
+ // 反解还按 xOf 算的话:0:00 处的鼠标会被解成 00:37、24:00 处解成 23:22。
5410
+ // 两个后果都撞上过 —— 悬停位置整体偏、以及鼠标放在绿点(此刻)上时
5411
+ // 解出来的 raw 比 nowHour 大,直接被下面那条 range 判定拦掉,
5412
+ // 于是「鼠标放在绿点上没有反应」(2026-11-26 用户)。
5413
+ const raw = ((userX - PAD_L - PLOT_PAD_X) / (plotW - PLOT_PAD_X * 2)) * 24;
5414
+ // 只报**已经发生**的那一段:鼠标滑到「现在」右边就什么都不显示
5415
+ // (2026-11-26 用户:「没到的地方就不要计算了」)。
5416
+ // 曲线本来也只画到此刻(clipped),右边那截是空白,报数等于凭空编一段钱出来。
5417
+ // ⚠️ 范围按**像素**判、并且两端各给 NOW_HIT_PX 热区:
5418
+ // 绿点只有 r=3,要求像素级精准的话鼠标放上去 3px 就没反应
5419
+ // (2026-11-26 用户:「鼠标放在绿点上应该显示当前的今日消耗」)。
5420
+ const NOW_HIT_PX = 6;
5421
+ // 吸附范围(比命中范围小得多)。
5422
+ // ⚠️ 原来判「此刻」直接拿 NOW_HIT_PX=6px,凌晨时 nowHour 很小,
5423
+ // 6px 横跨 0:00~0:24 —— 鼠标停在 00:00 也会被当成此刻,
5424
+ // 于是 00:00 就报出今日总额 ¥0.85,把平摊曲线整个盖掉
5425
+ // (2026-11-26 用户:「我的平摊算法呢」)。
5426
+ // 现在只认绿点附近 2px(≈4 分钟)吸附,再往左老老实实按插值报。
5427
+ const NOW_SNAP_PX = 2;
5428
+ const nowPx = xPlot(nowHour);
5429
+ // 范围放到整条轴(2026-11-26 用户:「鼠标移到没到的时间点上显示 0 暂未产生消耗」)。
5430
+ // 原来右端只到绿点 + 热区,此刻右边整片灰着不能碰 —— 现在能停,只是金额报「还没到」。
5431
+ if (!(userX >= xPlot(0) - NOW_HIT_PX && userX <= xPlot(24) + NOW_HIT_PX)) { setHover(null); return; }
5432
+ // 贴着绿点时直接吸附到此刻(时刻和金额一起吸);右侧保留满命中范围方便把绿点点中
5433
+ const nearNow = userX >= nowPx - NOW_SNAP_PX && userX <= nowPx + NOW_HIT_PX;
5434
+ const hour = nearNow ? nowHour : Math.min(24, Math.max(0, raw));
5435
+ // 记下纵向位置,黑胶囊要跟着鼠标躲曲线(2026-11-26 用户:「还有这个黑胶囊挡住了」)。
5436
+ const userY = ((event.clientY - rect.top) / rect.height) * H;
5437
+ emitHover(hour, userY);
5438
+ };
5439
+ // 按「某个时刻 + 鼠标纵坐标」出胶囊。抽成独立函数是为了让**滚轮/方向键**能复用:
5440
+ // 图宽 474 铺 24 小时,一分钟只占 0.33px —— 鼠标动一像素就跨 3 分钟,
5441
+ // 再宽的卡片也治不好(要 1440px 才 1 分钟/px)。所以精确定位交给滚轮/方向键,
5442
+ // 指针只负责落个大概位置(2026-11-27 用户:「怎么还是只能3分钟的看」)。
5443
+ // 构造胶囊数据(纯函数)。抽出来是为了**常显**:鼠标不在图上时
5444
+ // 渲染层直接用 buildHover(nowHour) 算一份「此刻」的,不再需要先把鼠标摆上去。
5445
+ const buildHover = (hour, userY) => {
5446
+ const future = hour > nowHour + 1e-9;
5447
+ // 取**所在的 5 分钟段**(四舍五入到最近的段边界),段内不再插值。
5448
+ // 段内插值是纯猜测:这一小时花了 ¥1.20,但不知道是哪一分钟,
5449
+ // 按 4/60 摊出来是 ¥0.08,跟「已经花了 ¥1.20」完全对不上
5450
+ // (2026-11-27 用户拿着 0:04 的截图问「这个是准确数值是吗」)。
5451
+ // 现在每个 1 分钟段报它自己那一份,误差 ≤ byHour/60。
5452
+ // ⚠️ 兜底值必须是 60(1 分钟)—— 早前是 12(5 分钟),模型里字段缺失时会
5453
+ // 静默退回 5 分钟吸附,胶囊上的时刻就只在 :00/:05/:10… 之间跳
5454
+ // (2026-11-27 用户指着「06:54 累计」说「我说的是这个显示每分钟」)。
5455
+ const sp = model.STEPS_PER_HOUR || 60;
5456
+ const stepIdx = Math.min(model.STEPS || 1440, Math.max(0, Math.round(hour * sp)));
5457
+ // pts[i] 存的是第 i+1 分钟**末**的累计(pts[i].at = (i+1)*STEP_MIN/60),
5458
+ // 所以要取 segHour 那一刻的累计,索引是 stepIdx-1 而不是 stepIdx(差一分钟)。
5459
+ const accIdx = stepIdx - 1;
5460
+ const a0 = accIdx >= 0 && model.pts[accIdx] ? model.pts[accIdx].acc : 0;
5461
+ const aPrev = accIdx - 1 >= 0 && model.pts[accIdx - 1] ? model.pts[accIdx - 1].acc : 0;
5462
+ // 这一分钟自己花了多少 = 相邻两个累计之差(2026-11-27 用户:
5463
+ // 「就是这里滑动可以看到每一分钟的消耗 这样显示的可以准确一点」)。
5464
+ // 直接读曲线的差分,所以和画出来的线永远一致,不会出现「胶囊和曲线对不上」。
5465
+ const minuteCost = Math.max(0, a0 - aPrev);
5466
+ // 时刻吸附到**所在的分钟**:06:54 就是 06:54,不再四舍五入到 5 分钟一档
5467
+ // (2026-11-27 用户:「我说的是这个显示每分钟」)。
5468
+ const segHour = stepIdx / sp;
5469
+ const segI0 = Math.min(24, Math.floor(segHour + 1e-9));
5470
+ const segMin = Math.round((segHour - segI0) * 60);
5471
+ // 该小时整小时的钱(不再显示,留着给悬停胶囊以外的用途)
5472
+ const hourCost = (model.hourly[Math.min(23, Math.max(0, Math.floor(hour)))] || 0) * (model.scale || 1);
5473
+ // 第二行是**整小时**汇总(2026-11-27 用户:「小时还是不变」):
5474
+ // 左端标这一段属于哪个整点,跨整点悬停时才看得出来。
5475
+ const hourFrom = Math.min(23, Math.max(0, Math.floor(segHour + 1e-9)));
5476
+ const hourLabel = pad2(hourFrom) + ":00-" + pad2(Math.min(24, hourFrom + 1)) + ":00";
5477
+ // 鼠标压在曲线末端那颗绿点上时,直接报**今日总额**。
5478
+ // ⚠️ 这里不能用 onHoverMove 的 nearNow:抽成 emitHover 之后它不在这个作用域里,
5479
+ // 每次悬停都抛 ReferenceError,setHover 一次都没执行 —— 鼠标放上去什么都不显示(用户:
5480
+ // 「鼠标放在折线图上能看到对应时间的消耗」)。
5481
+ // onHoverMove 在 nearNow 时把 hour 直接定成 nowHour,所以这里比一下就等价。
5482
+ const onNow = Math.abs(hour - nowHour) < 1e-6;
5483
+ // 报的是**累计**(零点到此刻一共花了多少),不是这一小段单独花了多少 ——
5484
+ // 按段拆的话,没记录的时间 hover 上去恒是 ¥0.0000,看着像坏了。
5485
+ // 这一小时自己的消耗另开一格(2026-11-26 用户:「黑胶囊里面加一个当前小时的总消耗」)。
5486
+ return {
5487
+ // hour 是**未吸附**的插值位置,竖线要跟手;hourSnap 是吸附到分钟后的时刻,
5488
+ // 第二行「00:00-01:00」必须按它算 —— 否则 00:59 会被 round 到 01:00(第一行),
5489
+ // 而第二行仍写 00:00-01:00,两行自相矛盾。
5490
+ hour,
5491
+ hourSnap: segHour,
5492
+ // 此刻与未来都报今日总额(未来不会让累计变大)
5493
+ acc: (onNow || future) ? model.total : a0,
5494
+ hourCost: future ? 0 : hourCost,
5495
+ // 第一行的钱 = 截到此刻的累计(与曲线同源);第二行 = 该小时合计
5496
+ minuteCost: future ? 0 : minuteCost,
5497
+ hourLabel,
5498
+ future,
5499
+ // 不再写「此刻」这个词 —— 用户要看的是「当前时间 + 累计」
5500
+ // (2026-11-26:「显示此刻吗 不应该显示当前时间累计」)。
5501
+ // 第一行是**这一分钟**的消耗:时刻 + 这一分钟花了多少
5502
+ // (2026-11-27 用户圈着第二行说「小时还是不变 我说的是第一行的」)。
5503
+ label: pad2(segI0) + ":" + pad2(segMin),
5504
+ y: userY,
5505
+ };
5506
+ };
5507
+ const emitHover = (hour, userY) => { setHover(buildHover(hour, userY)); };
5508
+ // 滚轮 = 逐分钟微调(上 = 往后、下 = 往前),一格一分钟,不受像素密度限制。
5509
+ // 只在胶囊已经开着时生效,并且吞掉默认滚动,否则页面跟着滚。
5510
+ // ⚠️ 不调 preventDefault:React 的 onWheel 是 passive 监听,调了只会报警告、
5511
+ // 拦不住页面滚动。胶囊本来就贴着图表,滚一点点不影响阅读。
5512
+ const stepHoverBy = (minutes) => {
5513
+ if (hover == null) return;
5514
+ const next = Math.round(hover.hourSnap * 60 + minutes) / 60;
5515
+ emitHover(Math.min(24, Math.max(0, next)), hover.y);
5516
+ };
5517
+ const onHoverWheel = (event) => {
5518
+ if (hover == null) return;
5519
+ stepHoverBy((event && event.deltaY) < 0 ? 1 : -1);
5520
+ };
5521
+ // 方向键逐分钟:←/→ 各走一分钟,和滚轮同一套落点
5522
+ const onHoverKey = (event) => {
5523
+ if (event == null) return;
5524
+ if (event.key === "ArrowLeft") { stepHoverBy(-1); return; }
5525
+ if (event.key === "ArrowRight") { stepHoverBy(1); }
5526
+ };
5527
+ const onHoverLeave = () => setHover(null);
5528
+ // 黑胶囊的位置:横向跟着竖线(靠边时改对齐方式,不夹 left),
5529
+ // 纵向跟着鼠标 —— 鼠标在图表上半部就挂到下方、下半部挂到上方,别压住曲线本身。
5530
+ // 原来钉在 top:1px,曲线爬到右上角时正好被它盖住(2026-11-26 用户:「黑胶囊挡住了」)。
5531
+ // 归位用**滑动**,但时长跟距离走(2026-11-27 用户:「是滑动的动画」)。
5532
+ // 之前固定 100ms:从最右边归位就是 100ms 横跨 300px(~3000px/s),
5533
+ // 看上去像跳帧而不像滑。现在 90ms 起、每小时 +14ms、封顶 300ms,
5534
+ // 长距离也是可跟踪的匀速滑行。
5535
+ const tipPos = (hv) => {
5536
+ const pctX = xPlot(hv.hour) / W;
5537
+ // ⚠️ 不能居中:居中会横跨在竖线上,「此刻」那根白条就被胶囊盖死了
5538
+ // (2026-11-27 用户:「往右靠一点 遮住白条了」)。
5539
+ // 现在一律**贴着竖线向一侧展开**,左半边向右、右半边向左,
5540
+ // 中间留 6px,线与胶囊永不相交;同时两端也不会出界。
5541
+ // ⚠️ 两边必须写成**同一种形式** calc(% + px)。
5542
+ // 之前右展开写的是纯 6px、左展开写的是 calc(-100% - 6px),
5543
+ // 一个是纯 px、一个是百分比混合 —— 浏览器**无法插值**,
5544
+ // 方向一翻就是硬切一个胶囊宽度,看上去就像冲到最右边
5545
+ // (2026-11-27 用户:「好像只有在虚线的左侧才会导致」)。
5546
+ const alignX = pctX > 0.55 ? "translateX(calc(-100% - 6px))" : "translateX(calc(0% + 6px))";
5547
+ // ⚠️ 垂直基点用**曲线在该时刻的高度**,不是鼠标高度。
5548
+ // 用鼠标高度时,鼠标一旦落在曲线上(用户就是顺着线走的)胶囊反而
5549
+ // 挂到曲线那一侧、直接盖住它(2026-11-27 用户:「遮挡到折现了」)。
5550
+ // 现在按「曲线在上半部就挂下方、在下半部就挂上方」,胶囊永远在线的反侧。
5551
+ const curveY = yOf(hv.acc);
5552
+ const below = curveY < H * 0.5;
5553
+ const y = Math.max(2, Math.min(H - 2, curveY));
5554
+ // 归位用**滑动**,但时长跟距离走(2026-11-27 用户:「是滑动的动画」)。
5555
+ // 之前固定 100ms:从最右边归位就是 100ms 横跨 300px(~3000px/s),
5556
+ // 看上去像跳帧而不像滑。现在 90ms 起、每小时 +14ms、封顶 300ms。
5557
+ // 跟手中间那些帧不过渡(不卡);**进入**和**归位**都按距离滑。
5558
+ // 只保留**松开归位**的动画(2026-11-27 用户:「算了 就留松开归位的动画吧」)。
5559
+ // 鼠标在图上(含刚进入)一律 0ms 跟手,不过渡也就不会出现任何冲过头;
5560
+ // 只有 hover 变空、胶囊要回「此刻」时才按距离滑。
5561
+ const prevHour = lastTipHourRef.current;
5562
+ const dur = hover || prevHour < 0
5563
+ ? 0
5564
+ : Math.round(Math.min(200, 80 + Math.abs(hv.hour - prevHour) * 10));
5565
+ // 下一次算距离用就是这一次的位置。
5566
+ // 原来靠一个 react.useEffect 同步,但那个 effect 写在 model.ok 早退**之后** ——
5567
+ // 首次渲染(today 还是 null)少跑一个 hook,数据到位后多跑一个,React 抛
5568
+ // Rendered more hooks → 刚启动就点开时间线直接崩(2026-11-27 用户:
5569
+ // 「插件还在加载的时候点击左下角 插件就会崩」)。
5570
+ lastTipHourRef.current = hv.hour;
5571
+ return {
5572
+ left: pctX * 100 + "%",
5573
+ top: (y / H) * 100 + "%",
5574
+ // 两行之后胶囊更高(~32px),偏移从 10 提到 14。
5575
+ transform: alignX + " " + (below ? "translateY(14px)" : "translateY(calc(-100% - 14px))"),
5576
+ // 只写时长:property 列表由 CSS 常驻提供,这样过渡才能真正启动。
5577
+ // 0ms 时 CSS 那边也不会走过渡,相当于直接落位
5578
+ "--tip-dur": dur + "ms",
5579
+ };
5580
+ };
5581
+ // 第二行左端标签现在由 hover.minLabel 给出(分钟区间),组件体里不再需要
5582
+ // 反解整点 —— 原来那个 i0h 是给「03:00-04:00」用的,已随分钟化一起删掉。
5583
+ // 常显(2026-11-27 用户:「其实胶囊常显也可以加」):鼠标离开就贴回「此刻」,
5584
+ // 不再整块消失。真正悬停时跟手(hover 非空就用它)。
5585
+ // ⚠️ 只有胶囊(tip)常显;竖虚线与白点仍然只跟真实悬停,
5586
+ // 否则会和「此刻」的白线 + 绿点重叠成两套。
5587
+ // 开关关掉时 shownHover 可以是 null(那就是「胶囊不常显」)。
5588
+ const shownHover = tipAlways ? (hover ?? buildHover(nowHour, yOf(model.total))) : hover;
5589
+ const area = clipped.length > 1
5590
+ ? dl + "L" + xPlot(last.at).toFixed(2) + " " + plotBase + "L" + xPlot(0) + " " + plotBase + "Z"
5591
+ : "";
5592
+ return jsx.jsx(PopShell, {
5593
+ anchorRect,
5594
+ wide: true,
5595
+ title: "今日消耗时间线",
5596
+ // 常显开关:放在右上角、关闭按钮左边。
5597
+ headExtra: jsx.jsxs("button", {
5598
+ className: "balance-pop__switch" + (tipAlways ? " balance-pop__switch--on" : ""),
5599
+ type: "button",
5600
+ onClick: setTipAlways,
5601
+ "aria-pressed": tipAlways ? "true" : "false",
5602
+ title: tipAlways ? "常显:鼠标离开后胶囊仍在「此刻」" : "不常显:鼠标离开就隐藏胶囊",
5603
+ children: [
5604
+ jsx.jsx("span", { className: "balance-pop__switch-dot" }),
5605
+ jsx.jsx("span", { children: "常显" }),
5606
+ ],
5607
+ }),
5608
+ // 「今天还没有消耗」只在**真的一分钱没花**时出现。total > 0 但 activeHours 为 0
5609
+ // 说明钱不在分小时账上(pluginCost 等),这时候说「还没有消耗」是错的。
5610
+ // 金额单独拆成一个节点加粗提亮(2026-11-27 用户:
5611
+ // 「这个今日消耗可以显眼一点」)。
5612
+ subtitle: [
5613
+ jsx.jsx("span", { key: "s0", children: "累计 " }),
5614
+ jsx.jsx("strong", {
5615
+ key: "s1",
5616
+ className: "balance-pop__sub-amount",
5617
+ children: popMoney(model.total),
5618
+ }),
5619
+ jsx.jsx("span", {
5620
+ key: "s2",
5621
+ children: (model.activeHours > 0
5622
+ ? " · " + model.activeHours + " 个时段有消耗"
5623
+ : (model.total > 1e-9 ? "" : " · 今天还没有消耗"))
5624
+ + (debugZoom ? " · 调试上限 ¥" + maxY : ""),
5625
+ }),
5626
+ ],
5627
+ onClose,
5628
+ // ⚠️ 图 + 明细**同一个面板**(2026-11-27 用户:「这两个浮窗合并吧」)。
5629
+ // 原来点「今日」开明细、点时段条开时间线,两个浮窗内容互补却要分别点开;
5630
+ // 合并后图在上、明细在下,点哪一块都开这一个。
5631
+ children: jsx.jsxs("div", {
5632
+ children: [
5633
+ jsx.jsx("div", { className: "balance-pop__chart", children: [
5634
+ jsx.jsxs("svg", {
5635
+ key: "svg",
5636
+ className: "balance-pop__svg",
5637
+ viewBox: "0 0 " + W + " " + H,
5638
+ role: "img",
5639
+ "aria-label": "今日消耗时间线",
5640
+ style: { cursor: "crosshair" },
5641
+ // 一分钟一格、24 小时铺 474px ⇒ 1px 跨 3 分钟,鼠标扫过只能落在 3 的倍数上。
5642
+ // 所以精调交给滚轮和方向键(各一格 = 一分钟),鼠标只负责落个大概位置。
5643
+ tabIndex: 0,
5644
+ onWheel: onHoverWheel,
5645
+ onKeyDown: onHoverKey,
5646
+ onMouseMove: onHoverMove,
5647
+ onMouseLeave: onHoverLeave,
5648
+ children: [
5649
+ // 色带和面积图裁成圆角(2026-11-26 用户:「边缘加上圆角」)。
5650
+ // 只裁这两层:坐标轴文字在底部两角,一起裁会把「0:00」「24:00」切掉一半。
5651
+ jsx.jsx("defs", {
5652
+ children: jsx.jsx("clipPath", {
5653
+ id: clipId,
5654
+ // ⚠️ 裁剪框必须跟 xOf 走(和色块同范围)。
5655
+ // 曾经用 PAD_L/plotW(18–476),而色块内缩到 26–468 之后完全落在
5656
+ // 裁剪框内部,圆角根本碰不到边,直接露出矩形的直角
5657
+ // (2026-11-27 用户:「圆角呢」)。
5658
+ children: jsx.jsx("rect", { x: PAD_L, y: PAD_T, width: plotW, height: plotH, rx: R, ry: R }),
5659
+ }),
5660
+ }),
5661
+
5662
+ // 色块不参与缩放(2026-11-27 用户:「压缩的时候 色块不要被压缩
5663
+ // 只压缩里面的刻度」)。底色表示的是「24 小时长什么样」,和金额上限无关,
5664
+ // 跟着 scaleY 一起变形反而像色块自己在抽动。
5665
+ // 色块只在它自己的位置,不跟着缩放组一起动
5666
+ // (2026-11-27 用户:「就是色块只在对应的位置 不要乱动」)。
5667
+ jsx.jsx("g", {
5668
+ key: "bands",
5669
+ clipPath: "url(#" + clipId + ")",
5670
+ children: [
5671
+ // 色块横向归两类边(…………………………………………………………………………
5672
+ // 外缘(0:00 与 24:00)→ xOf,贴着绘制区边缘,左右才有那几像素肉
5673
+ // 内部分界→ xPlot,和轴刻度、分隔线、折线同一套坐标
5674
+ // 不这样分的话,两者只能二选一:全走 xOf 则分隔线与刻度错 2px、
5675
+ // 对着分隔线指会读错时间;全走 xPlot 则色块两端内缩、左右没了余量
5676
+ // (2026-11-27 用户两条反馈分别对应这两个坑)。
5677
+ bands.map((b) => {
5678
+ const bx = b.from <= 0 ? xOf(0) : xPlot(b.from);
5679
+ const bx2 = b.to >= 24 ? xOf(24) : xPlot(b.to);
5680
+ return jsx.jsx("rect", {
5681
+ key: "b" + b.from,
5682
+ className: "balance-pop__band balance-pop__band--" + b.kind,
5683
+ x: bx,
5684
+ y: PAD_T,
5685
+ width: Math.max(0, bx2 - bx),
5686
+ height: plotH,
5687
+ });
5688
+ }),
5689
+ dividers.map((h) => jsx.jsx("line", {
5690
+ key: "d" + h,
5691
+ className: "balance-pop__grid",
5692
+ // 描边按屏幕像素算,不跟着 viewBox 缩放走 —— 否则 1px 虚线被摊到亚像素上会发虚
5693
+ vectorEffect: "non-scaling-stroke",
5694
+ // 分界线的 x 由时间换算得到(119.25 / 153 / 175.5 / 220.5),
5695
+ // 每条落在不同的亚像素位置、抗锯齿程度就不同,看着像粗细不一。
5696
+ // crispEdges 把竖线吸附到像素网格,四条才对得齐。
5697
+ shapeRendering: "crispEdges",
5698
+ x1: xPlot(h), y1: PAD_T, x2: xPlot(h), y2: PAD_T + plotH,
5699
+ })),
5700
+
5701
+ ],
5702
+ }),
5703
+ jsx.jsx("g", {
5704
+ className: "balance-pop__plot",
5705
+ // 原点钉在绘图区的 0 线(plotBase),底边不动、上面伸缩
5706
+ children: [
5707
+ jsx.jsx("g", {
5708
+ clipPath: "url(#" + clipId + ")",
5709
+ children: [
5710
+ // 横向网格跟 yTicks 走 —— yTicks 已经按像素间距过滤掉密集处,
5711
+ // 所以这里不用再自己算一套。网格线与左侧数字始终一一对应。
5712
+ yTicks.map((v) => jsx.jsx("line", {
5713
+ key: "yh" + v,
5714
+ className: "balance-pop__grid-h",
5715
+ vectorEffect: "non-scaling-stroke",
5716
+ shapeRendering: "crispEdges",
5717
+ x1: xOf(0), y1: yOf(v), x2: xOf(24), y2: yOf(v),
5718
+ })),
5719
+ area ? jsx.jsx("path", { className: "balance-pop__area", d: area }) : null,
5720
+ jsx.jsx("path", {
5721
+ className: "balance-pop__line",
5722
+ d: dl,
5723
+ // scaleY 会把描边一起压细(粗细变了就像“折线变了”)
5724
+ vectorEffect: "non-scaling-stroke",
5725
+ // 零值画虚线(见上面 isZero 的注释)。undefined 时 React 不渲染这个属性。
5726
+ strokeDasharray: isZero ? "3 3" : undefined,
5727
+ }),
5728
+ // 悬停位置的竖线(在裁剪组里,贴边时不会跑出色块)
5729
+ hover ? jsx.jsx("line", {
5730
+ key: "hv",
5731
+ className: "balance-pop__hover-line",
5732
+ vectorEffect: "non-scaling-stroke",
5733
+ shapeRendering: "crispEdges",
5734
+ x1: xPlot(hover.hour), y1: PAD_T, x2: xPlot(hover.hour), y2: PAD_T + plotH,
5735
+ }) : null,
5736
+ ],
5737
+ }),
5738
+ // 光标也在缩放组里,跟着一起动(2026-11-27 用户:「绿点也要动的」)。
5739
+ jsx.jsx("line", {
5740
+ className: "balance-pop__now",
5741
+ x1: xPlot(last.at), y1: PAD_T, x2: xPlot(last.at), y2: PAD_T + plotH,
5742
+ }),
5743
+ // 绿点外面包一个**常亮的空心圈**(2026-11-27 用户:
5744
+ // 「鼠标重合和常显时 绿圈外面包一个空心圈 常量的」)。
5745
+ // 常驻,不受 hover 影响;重合时白点落在它里面也不会混。
5746
+ // 泛光圈只在两种情况下亮:
5747
+ // 1. 鼠标与此刻重合(不分开关);
5748
+ // 2. 「常显」开着、且鼠标不在图上。
5749
+ // 开关关掉时归位状态不亮 —— 那时候连胶囊都不在,
5750
+ // 只剩一个白圈孤零零地亮着很突冗(2026-11-27 用户:
5751
+ // 「关闭常显的话 除非指针对齐 这个白色光圈就不要显示了」)。
5752
+ // 容差取半分钟:比 hover 的分钟吸附更细一点,指到同一分钟就算重合。
5753
+ (hover ? Math.abs(hover.hourSnap - last.at) < 1 / 120 : tipAlways) ? jsx.jsx("circle", {
5754
+ className: "balance-pop__dot-ring",
5755
+ cx: xPlot(last.at), cy: yOf(last.acc), r: 6.4,
5756
+ }) : null,
5757
+ jsx.jsx("circle", { className: "balance-pop__dot", cx: xPlot(last.at), cy: yOf(last.acc), r: 3 }),
5758
+ // 鼠标手动指到此刻时**不画实心白点**:
5759
+ // 那里已经有绿点 + 白光圈,再叠一个白点就脏了
5760
+ // (2026-11-27 用户:「如果我手动重合 就不要哪个实心白点了」)。
5761
+ hover && Math.abs(hover.hourSnap - last.at) >= 1 / 120 ? jsx.jsx("circle", {
5762
+ key: "hdot",
5763
+ className: "balance-pop__hover-dot",
5764
+ cx: xPlot(hover.hour), cy: yOf(hover.acc), r: 3,
5765
+ }) : null,
5766
+ ],
5767
+ }),
5768
+ // 左侧金额刻度(2026-11-27 用户:「刻度数字显示出来」)。
5769
+ // 画在绘图区左缘之外、且**不在 clip 组里** —— 放进去会连同曲线一起被裁掉。
5770
+ // 文字用整数:¥1 / ¥5 / ¥10 / ¥150,不补 .00,否则每行四个字符会挤到曲线上。
5771
+ // ⚠️ 标签要防重叠:阶梯步长在低额区很密(¥1~¥5 只占底部两成高度),
5772
+ // 五条线挤进二十来像素会把 ¥1~¥5 糊成一团黑块。网格线照画,**标签按间距跳着写**:
5773
+ // 与上一个已画标签的中心距不足 11px 就跳过,宁可少标几个也不能叠。
5774
+ // key 带上 maxY:换档时重挂一次,搭 CSS 淡入,
5775
+ // 否则数字会“啪”一下换成另一批(2026-11-27 用户:
5776
+ // 「除了光标和背景色块 其他的都跟着数值走」)。
5777
+ yLabels.map((v) => jsx.jsx("text", {
5778
+ // ⬇️ 用 targetMaxY 而不是 maxY:maxY 在插值期间每帧都变,
5779
+ // key 跟着变就等于每帧重挂、每帧重播淡入 —— 屏幕上就是一片乱闪。
5780
+ key: "yv" + targetMaxY + "-" + v,
5781
+ className: "balance-pop__axis balance-pop__axis--value"
5782
+ + (labelAnim ? " balance-pop__axis--value--anim" : ""),
5783
+ x: PAD_L - 2,
5784
+ // 最顶上那个刻度(就是 maxY 那一档)的 yOf 恰好等于 PAD_T = 6,
5785
+ // 文字 baseline 在 9、字号 11 → 顶部到 1px,几乎贴着色带边、被上面的
5786
+ // 卡片内边距压住,看上去就是「最顶上的刻度看不见」(2026-11-27 用户)。
5787
+ // 所以给 baseline 一个下限:再高也不低于 11。
5788
+ y: Math.max(yOf(v) + 3.5, 15),
5789
+ textAnchor: "end",
5790
+ children: "¥" + v,
5791
+ })),
5792
+ ticks.map((h) => jsx.jsx("text", {
5793
+ key: "t" + h,
5794
+ className: "balance-pop__axis",
5795
+ x: xPlot(h) + (h === 0 ? TICK_NUDGE : (h === 24 ? -TICK_NUDGE : 0)),
5796
+ y: H - 3,
5797
+ textAnchor: h === 0 ? "start" : (h === 24 ? "end" : "middle"),
5798
+ children: h + ":00",
5799
+ })),
5800
+ ],
5801
+ }),
5802
+ // 悬停提示:贴着鼠标位置,靠近两端时收进卡片内,别被 overflow:hidden 裁掉
5803
+ shownHover ? jsx.jsx("div", {
5804
+ key: "tip",
5805
+ className: "balance-pop__tip",
5806
+ // 跟随期间**不过渡**(2026-11-27 用户:「这个跟随动画有bug
5807
+ // 我指针速度太快就出现卡顿了」)。
5808
+ // mousemove 每帧都会改 left/top,而 CSS transition 每次都从头重开 →
5809
+ // 胶囊永远在追一个每 16ms 就变一次的目标,快速移动时就是一顿一顿的。
5810
+ // 现在只有**回位**(鼠标离开 → 常显「此刻」)走过渡,跟手时零延迟。
5811
+ className: "balance-pop__tip",
5812
+ // 靠边时改对齐方式而不是夹 left:夹了 tooltip 就和竖线脱开,
5813
+ // 不夹又会被 .balance-pop 的 overflow:hidden 切掉。
5814
+ style: tipPos(shownHover),
5815
+ // 两行:上行「时刻 累计 → 总额」,下行「本小时 → 该小时合计」。
5816
+ // 值按分钟吸附(见 onHoverMove 的 sFrac),同一分钟内数字不动,
5817
+ // 换分钟才跳一次 —— 不挂动画,闪的问题就没了。
5818
+ children: [
5819
+ jsx.jsxs("span", {
5820
+ key: "r1",
5821
+ className: "balance-pop__tip-row",
5822
+ children: [
5823
+ // 时刻 + 「累计」必须包在一起:直接丢给 space-between 的话,
5824
+ // 三个子元素会被拉成三列,「累计」被推到正中间、离时刻
5825
+ // 一大截(2026-11-27 用户:「隔的太远了吧」)。
5826
+ jsx.jsxs("span", {
5827
+ key: "t",
5828
+ className: "balance-pop__tip-left",
5829
+ children: [
5830
+ jsx.jsx("span", { className: "balance-pop__tip-time", children: shownHover.label }),
5831
+ // 「累计」字样:光有时刻 + 金额看不出口径。
5832
+ jsx.jsx("span", { className: "balance-pop__tip-tag", children: "累计" }),
5833
+ ],
5834
+ }),
5835
+ // key 里带**整数位数**(小数点的位置):只有位数变化才重挂、才播滑入。
5836
+ // ⚠️ 不能用字符串长度 —— ¥8.9808 和 ¥12.337 都是 7 个字符,
5837
+ // 整数位从 1 位变 2 位的恰恰是 ¥ 会挪位置的那种情况,长度抓不到。
5838
+ // 同位数内静默换值,不会像之前那样每帧重播动画闪成一片。
5839
+ // 还没到的时段不给 ¥0.00(读起来像“花了 0 元”,实际是“还没发生”)。
5840
+ // 第二行很早就是这么做的,第一行按分钟化时漏了。
5841
+ jsx.jsx("span", {
5842
+ // ⚠️ 第一行 = **今日累计消耗**,不分过去 / 未来。
5843
+ // 曲线本身画的就是累计,报差分就变成「胶囊和曲线对不上」
5844
+ // (2026-11-27 用户圈着这一行:「上面是当前累计消耗」)。
5845
+ // 未来时段 buildHover 已经把 acc 置成 model.total,所以这里直接报就是
5846
+ // 「截到此刻的今日累计」;不再换成「暂未消耗」
5847
+ // (2026-11-27 用户:「我说的是第一行 显示累计消耗:今日消耗数值」)。
5848
+ // 四位小数,和副标题那个「累计 ¥x.xxxx」同一口径。
5849
+ key: "c" + popMoney(shownHover.acc).length,
5850
+ className: "balance-pop__tip-cost",
5851
+ children: popMoney(shownHover.acc),
5852
+ }),
5853
+ ],
5854
+ }),
5855
+ jsx.jsxs("span", {
5856
+ key: "r2",
5857
+ className: "balance-pop__tip-row",
5858
+ children: [
5859
+ // 第二行左标签 = **整小时**区间(03:00-04:00)。
5860
+ // 分钟化只改第一行(2026-11-27 用户圈着第二行:「小时还是不变 我说的是第一行的」);
5861
+ // 这一行保留整小时汇总,横向滑动时只在跨整点那一下变化。
5862
+ jsx.jsx("span", {
5863
+ key: "l",
5864
+ className: "balance-pop__tip-hour",
5865
+ children: shownHover.hourLabel,
5866
+ }),
5867
+ // 还没到的时段不给 ¥0.00 —— 那读起来像「花了 0 元」,
5868
+ // 实际是「这段时间还没发生」(2026-11-26 用户:「显示 0 暂未产生消耗」)。
5869
+ jsx.jsx("span", {
5870
+ key: shownHover.future ? "vdone" : "v" + popMoneyTip(shownHover.hourCost).indexOf("."),
5871
+ className: "balance-pop__tip-hourcost" + (shownHover.future ? " balance-pop__tip-hourcost--pending" : ""),
5872
+ children: shownHover.future ? "暂未产生消耗" : popMoneyTip(shownHover.hourCost),
5873
+ }),
5874
+ ],
5875
+ }),
5876
+ ],
5877
+ }) : null,
5878
+ ] }),
5879
+ jsx.jsx("div", { className: "balance-pop__hr" }),
5880
+ jsx.jsx(TodayBreakdown, { bare: true, today }),
5881
+ ],
5882
+ }),
5883
+ });
5884
+ }
5885
+
5886
+ // ─── 用量统计面板(点余额胶囊打开) ──────────────────────────────────
5887
+ // ⚠️ 这一段是 2026-11-26 从 old/package/lib/client.js 原样搬回来的:
5888
+ // 中途重写时只留了 4 组、丢了「账户余额」卡、「近期消耗」「日均与峰值」,
5889
+ // 用户一眼看出「少了不少东西」。原来的 6 组 + 4 张卡才是对的,别再精简。
5890
+ function UsageStatsPanel({ onClose, panelRef, closing }) {
4184
5891
  const liveBalance = useBalance();
4185
5892
  const [heatmapTooltip, setHeatmapTooltip] = react.useState(null);
4186
5893
  // 加载进度条的「已用 X.Xs」—— 服务端一次返回、给不出百分比,但一个还在涨的数字
@@ -4334,7 +6041,7 @@ const CN_CALENDAR_SOURCES = [
4334
6041
  webToolCost: num(t.webToolCost),
4335
6042
  };
4336
6043
  }, [days, total]);
4337
- const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START;
6044
+ const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START && Date.now() < WEB_TOOL_FREE_FROM;
4338
6045
  const fmtCost = (v) => "¥" + num(v).toFixed(4);
4339
6046
  const denomCost = num(total && total.cost) > 0 ? num(total.cost) : 1;
4340
6047
  const rangeDays = Number(stats && stats.rangeDays) || 90;
@@ -4446,7 +6153,7 @@ const CN_CALENDAR_SOURCES = [
4446
6153
  ? jsx.jsxs(StatsGroup, {
4447
6154
  index: 3,
4448
6155
  title: "网页工具",
4449
- hint: webBillingStarted ? "¥5 / 千次" : "免费期内",
6156
+ hint: webBillingStarted ? "¥5 / 千次" : (Date.now() >= WEB_TOOL_FREE_FROM ? "只算 token" : "免费期内"),
4450
6157
  children: [
4451
6158
  jsx.jsx(StatsRow, {
4452
6159
  name: "Search / Fetch",
@@ -4454,9 +6161,14 @@ const CN_CALENDAR_SOURCES = [
4454
6161
  }),
4455
6162
  jsx.jsx(StatsRow, {
4456
6163
  name: "网页工具费用",
6164
+ // 11-18 12:00 起官方取消按次计费(服务端搜索只算 token,
6165
+ // web_fetch 更是本地匿名 HTTP)。所以这里不能再报「计费 N 次」——
6166
+ // 那 13 次全是 fetch,单价 0,报出来是 ¥0.0000 配「计费 13 次」,自相矛盾。
4457
6167
  value: webBillingStarted
4458
6168
  ? fmtCost(derived.webToolCost) + " · 计费 " + (derived.webSearchBillable + derived.webFetchBillable) + " 次"
4459
- : "免费期内 · 11-01 起按 ¥5 / 千次计费",
6169
+ : Date.now() >= WEB_TOOL_FREE_FROM
6170
+ ? "¥0 · 服务端搜索 / 本地抓取,只算 token"
6171
+ : "免费期内 · 11-01 起按 ¥5 / 千次计费",
4460
6172
  }),
4461
6173
  ],
4462
6174
  })
@@ -4886,6 +6598,20 @@ function useFooterCompact() {
4886
6598
  const todayCost = today !== null && Number.isFinite(Number(today.cost)) ? Number(today.cost) : null;
4887
6599
  // 显示精度固定 2 位(见 todayDecimals)。
4888
6600
  const todayText = todayCost === null ? null : todayCost.toFixed(todayDecimals(todayCost));
6601
+ // 两个小窗的数据源。⚠️ 必须在这一片(所有早退 return 之前)取值 ——
6602
+ // 和 todayCost 同一个理由:早退分支之后取会让两次渲染的 hook / 变量数量不同。
6603
+ // `today` 是 useToday() 的整份对象(含 bySession / sessionTitles / hourly / pluginCost)。
6604
+ const todayForPop = today;
6605
+ // ⚠️ `state.balance` 是**对象**({total_balance, currency, ...}),金额在 total_balance 上,
6606
+ // 而且它是字符串。直接 Number(state.balance) 会得到 NaN → 曲线永远画不出来。
6607
+ // 用 total_balance(= 充值余额,与胶囊显示的主数字同源),别用「充值+赠送」的和。
6608
+ const balanceForPop = (() => {
6609
+ const raw = state !== null && state.balance !== null && typeof state.balance === "object"
6610
+ ? state.balance.total_balance
6611
+ : null;
6612
+ const n = Number(raw);
6613
+ return Number.isFinite(n) && n >= 0 ? n : null;
6614
+ })();
4889
6615
  const [todayRoll, setTodayRoll] = react.useState(null);
4890
6616
  // 今日等待胶囊的光团起始相位:**每次挂载随机一次**(见 makeTodayFlowStyle 的注释)。
4891
6617
  // 不能用 useRef 装 —— 那样每次渲染都会重新算;useState 的初始化函数只跑一次。
@@ -5416,12 +7142,70 @@ function useFooterCompact() {
5416
7142
  // 双击看起来毫无反应。USAGE_URL 才是要传的那个。
5417
7143
  openPlatformOrUrl(USAGE_URL);
5418
7144
  };
5419
- // 余额元素的交互。悬停提示不用原生 title,统一走主题化浮层(见 withPanel)。
7145
+ // ─── 三个点击热区(2026-11-26 拆分)────────────────────────────────
7146
+ // 原来整行只有一个动作(单击=统计面板),用户要的是「点哪块看哪块」:
7147
+ // · 余额胶囊 → 统计面板(原样)
7148
+ // · 左侧「今日 ¥x」→ 今日各对话花了多少(todayPop)
7149
+ // · 时段词 / 刻度条 → 今日余额时间线(timelinePop)
7150
+ // 两个小窗都带被点那一块的 rect(出现位置锚在它上方 = 「上滑」)。
7151
+ const [todayPop, setTodayPop] = react.useState(null);
7152
+ const [timelinePop, setTimelinePop] = react.useState(null);
7153
+ /** 按 closest() 判断这次点的是哪一块;都不是就返回空串(= 整行默认动作)。
7154
+ * ⚠️ 顺序要紧:`.balance-footer__today` 是 `.balance-footer__timeline-meta` 的子节点,
7155
+ * 先判 now 才能把它从时段那一支里摘出来。 */
7156
+ const hitAreaOf = (target) => {
7157
+ if (target == null || typeof target.closest !== "function") return "";
7158
+ if (target.closest(".balance-footer__today") !== null) return "today";
7159
+ if (target.closest(".balance-footer__timeline-meta-item--today") !== null) return "today";
7160
+ if (target.closest(".balance-footer__timeline-meta") !== null) return "timeline";
7161
+ if (target.closest(".balance-footer__timeline-track") !== null) return "timeline";
7162
+ return "";
7163
+ };
7164
+ /** 这次点的是不是余额胶囊。单击开统计面板、双击开官方用量页都只认它。
7165
+ * `reveal` / `wave` 是胶囊内部的擦除层和刷新白光层 —— 不认的话,
7166
+ * 那两层压在胶囊上面时点下去会没反应。 */
7167
+ const isOnCapsule = (target) => {
7168
+ if (target == null || typeof target.closest !== "function") return false;
7169
+ return target.closest(".balance-footer__value") !== null
7170
+ || target.closest(".balance-footer__reveal") !== null
7171
+ || target.closest(".balance-footer__wave") !== null;
7172
+ };
7173
+ const rectOf = (el) => {
7174
+ if (el == null || typeof el.getBoundingClientRect !== "function") return null;
7175
+ const r = el.getBoundingClientRect();
7176
+ if (r == null || r.width <= 0 || r.height <= 0) return null;
7177
+ return { left: r.left, top: r.top, right: r.right, bottom: r.bottom, width: r.width, height: r.height };
7178
+ };
5420
7179
  // 余额元素的交互。悬停提示不用原生 title,统一走主题化浮层(见 withPanel)。
5421
7180
  const interactions = {
5422
- // 单击打开统计面板;顺便阻止 <a href> 的默认跳转(否则会同时弹系统浏览器)
7181
+ // 单击:热区分流(今日 → 明细,时段条 → 时间线,其余 → 统计面板);
7182
+ // 顺便阻止 <a href> 的默认跳转(否则会同时弹系统浏览器)
5423
7183
  onClick: (event) => {
5424
7184
  if (event && typeof event.preventDefault === "function") event.preventDefault();
7185
+ const area = hitAreaOf(event && event.target);
7186
+ if (area !== "") {
7187
+ // 兜一层:`event.target` 可能是行内文字节点外的任意后代,用它的 closest 父级量矩形
7188
+ const el = area === "today"
7189
+ ? (event.target.closest(".balance-footer__today") || event.target.closest(".balance-footer__timeline-meta-item--today"))
7190
+ : (event.target.closest(".balance-footer__timeline") || event.target.closest(".balance-footer__timeline-track"));
7191
+ const rect = rectOf(el) ?? rectOf(event.currentTarget);
7192
+ // ⚠️ 点开就**强制**拉一次 `?today=1`,不走 TTL(2026-11-26 实测:
7193
+ // 小窗打开时手上那份 `today` 可能还是 null / 旧对象 —— hourly 与 sessionTitles
7194
+ // 都是这一版才加的字段,旧缓存里根本没有,于是小窗永远停在「正在汇总」。
7195
+ // 用户点开就是要看最新数据,多一次请求完全值得。
7196
+ void fetchTodayOnce(true);
7197
+ // 两个热区开**同一个**面板(2026-11-27 用户:「这两个选中改成整体」):
7198
+ // 图和时间线明细已经合并在一张卡里,点「今日」或点时段条都开它,
7199
+ // 再点一下关掉。todayPop 保留变量名是为了改动面最小,实际不再单独开窗。
7200
+ setTodayPop(null);
7201
+ setTimelinePop((prev) => (prev !== null ? null : { rect }));
7202
+ return;
7203
+ }
7204
+ setTodayPop(null);
7205
+ setTimelinePop(null);
7206
+ // ⚠️ 只有**余额胶囊**才开统计面板(2026-11-26 用户:
7207
+ // 「只有点击余额胶囊才弹出统计界面」)。原来整行都是热区,点空白也弹,很吵。
7208
+ if (!isOnCapsule(event && event.target)) return;
5425
7209
  openStats(event);
5426
7210
  },
5427
7211
  onDoubleClick: openUsagePage,
@@ -5437,6 +7221,9 @@ function useFooterCompact() {
5437
7221
  },
5438
7222
  onDoubleClick: (event) => {
5439
7223
  if (isOverlayTarget(event && event.target)) return;
7224
+ // 双击(打开官方用量页)同样只认余额胶囊(2026-11-26 用户:
7225
+ // 「双击的交互也是只应用在余额胶囊上」)。原来整行双击都会跳浏览器。
7226
+ if (!isOnCapsule(event && event.target)) return;
5440
7227
  interactions.onDoubleClick(event);
5441
7228
  },
5442
7229
  onContextMenu: (event) => {
@@ -5448,19 +7235,42 @@ function useFooterCompact() {
5448
7235
  // 之前挂在内部的 .balance-footer 上,而那一层正是 primitives.Tooltip 的 cloneElement 目标,
5449
7236
  // props 可能被 Tooltip 的触发逻辑覆盖,结果只有金额胶囊响应、整行看着能点却点不动
5450
7237
  // (2026-10-30 反馈)。提到 Tooltip 外层 + 捕获阶段,双保险。
5451
- const withPanel = (node, hint, anchorStyle, extraProps) => jsx.jsxs("div", {
7238
+ // hint 三态(2026-11-26 用户:「这个显示只应用在余额条上」):
7239
+ // · 字符串 → 用这句自定义文案
7240
+ // · null → **不挂 Tooltip**(收起态圆钮 / 矩形卡:它们只是显示金额,挂那句
7241
+ // 「单击查看余额与使用统计…」会跟着圆钮一路飘)
7242
+ // · undefined → 默认文案,**只有展开态余额条该用这个**
7243
+ const DEFAULT_PANEL_HINT = "单击查看余额与使用统计,双击打开 DeepSeek API 用量页,右键刷新";
7244
+ const withPanel = (node, hint, anchorStyle, extraProps) => {
7245
+ const tipLabel = hint === null
7246
+ ? null
7247
+ : (typeof hint === "string" && hint !== "" ? hint : DEFAULT_PANEL_HINT);
7248
+ return jsx.jsxs("div", {
5452
7249
  className: "balance-stats-anchor balance-stats-anchor--" + (wide ? "wide" : "compact"),
5453
7250
  style: anchorStyle,
5454
7251
  ...(extraProps || null),
5455
7252
  children: [
5456
7253
  // 悬停提示走 DSH 主题化浮层:primitives.Tooltip 内部是 cloneElement(children, {ref}),
5457
7254
  // 不会插入额外 DOM 层,因此不破坏余额行在 flex 容器里的 42px 布局(浮层本身 portal 到 body)。
5458
- jsx.jsx(Tooltip, {
5459
- label: hint || "单击查看余额与使用统计,双击打开 DeepSeek API 用量页,右键刷新",
7255
+ tipLabel === null ? node : jsx.jsx(Tooltip, {
7256
+ label: tipLabel,
5460
7257
  side: "top",
5461
7258
  delayMs: 400,
5462
7259
  children: node,
5463
7260
  }),
7261
+ // 两个「上滑小窗」:都 portal 到 body —— 余额行在一个 overflow 容器里,
7262
+ // 留在原地会被裁掉(和统计面板同一个理由)。
7263
+ todayPop !== null ? createPortal(jsx.jsx(TodayBreakdown, {
7264
+ today: todayForPop,
7265
+ anchorRect: todayPop.rect,
7266
+ onClose: () => setTodayPop(null),
7267
+ }), document.body) : null,
7268
+ timelinePop !== null ? createPortal(jsx.jsx(BalanceTimeline, {
7269
+ today: todayForPop,
7270
+ balance: balanceForPop,
7271
+ anchorRect: timelinePop.rect,
7272
+ onClose: () => setTimelinePop(null),
7273
+ }), document.body) : null,
5464
7274
  // 统计面板:居中弹层 + 半透明遮罩(点击遮罩 / Esc / 关闭按钮均可关闭)
5465
7275
  statsOpen ? createPortal(jsx.jsx("div", {
5466
7276
  ref: layerRef,
@@ -5473,7 +7283,8 @@ function useFooterCompact() {
5473
7283
  }),
5474
7284
  }), document.body) : null,
5475
7285
  ],
5476
- });
7286
+ });
7287
+ };
5477
7288
 
5478
7289
  // 收起态浮窗被 composer 压住时直接隐藏(2026-10-31:「如果被遮挡直接隐藏就行了」)。
5479
7290
  // ⚠️ 必须量**真实矩形**,不能按 bottom:140 之类常量去推算:上一版就是这样错的 ——
@@ -5854,7 +7665,8 @@ function useFooterCompact() {
5854
7665
  }),
5855
7666
  }),
5856
7667
  ],
5857
- }), undefined, anchorStyle);
7668
+ // null = 不挂 Tooltip:那句「单击查看余额…」只属于展开态余额条
7669
+ }), null, anchorStyle);
5858
7670
  return typeof document === "undefined" ? rectFab : createPortal(rectFab, document.body);
5859
7671
  }
5860
7672
  // 两种情况都经 withPanel:收起态的定位落在它渲染的 .balance-stats-anchor--compact
@@ -5873,7 +7685,8 @@ function useFooterCompact() {
5873
7685
  ...externalLink(USAGE_URL, "usage"),
5874
7686
  ...interactions,
5875
7687
  children: balanceText,
5876
- }), undefined, anchorStyle);
7688
+ // null = 不挂 Tooltip(理由同上)
7689
+ }), null, anchorStyle);
5877
7690
  return typeof document === "undefined" ? fab : createPortal(fab, document.body);
5878
7691
  }
5879
7692
 
@@ -5904,7 +7717,7 @@ function useFooterCompact() {
5904
7717
  label: state.error || "余额查询失败",
5905
7718
  side: "top",
5906
7719
  delayMs: 200,
5907
- children: jsx.jsx("span", { className: "balance-footer__error", children: "余额读取失败" }),
7720
+ children: jsx.jsx("span", { className: "balance-footer__value balance-footer__value--error", children: "余额读取失败" }),
5908
7721
  }),
5909
7722
  ],
5910
7723
  }));
@@ -6031,7 +7844,12 @@ function useFooterCompact() {
6031
7844
  metaChildren.push(jsx.jsx("span", {
6032
7845
  className:
6033
7846
  "balance-footer__timeline-meta-item balance-footer__timeline-meta-item--today" +
6034
- (todayCost === null ? " balance-footer__timeline-meta-item--today-waiting" : ""),
7847
+ (todayCost === null ? " balance-footer__timeline-meta-item--today-waiting" : "") +
7848
+ // 小窗开着时高亮(2026-11-26 用户:「点击今日 或者时段消耗 需要高亮显示按钮」)
7849
+ // 小窗开着时高亮。两个热区(今日 / 时段条)现在开同一个面板,
7850
+ // 所以高亮也跟着同一个 state 走,看起来才是一个整体
7851
+ // (2026-11-27 用户:「这两个选中改成整体」)。
7852
+ (timelinePop !== null ? " balance-footer__today--active" : ""),
6035
7853
  children: [
6036
7854
  // 「今日」二字恒定不动:**不给它挂任何动画类**(用户 2026-10-31 反馈
6037
7855
  // 「刷新出来的时候今日二字也会闪一下」—— 根因就是以前整块挂了淡入动画)。
@@ -6150,7 +7968,12 @@ function useFooterCompact() {
6150
7968
  ],
6151
7969
  }, "today"));
6152
7970
  }
6153
- metaChildren.push(jsx.jsx("span", { className: "balance-footer__timeline-meta-group", children: tail }, "tail"));
7971
+ metaChildren.push(jsx.jsx("span", {
7972
+ className: "balance-footer__timeline-meta-group" + (timelinePop !== null ? " balance-footer__timeline--active" : ""),
7973
+ children: tail,
7974
+ }, "tail"));
7975
+ // 高亮只挂在**最内层**可点区域上(见下面 CSS):挂到 .balance-footer__timeline-meta
7976
+ // 会连「今日」一起亮,看起来像选了整行。
6154
7977
  const metaNode = jsx.jsx("span", { className: "balance-footer__timeline-meta", children: metaChildren });
6155
7978
  // 新版把「meta 行 + 刻度条」当结构主体,不存在"关掉只剩金额"的形态,
6156
7979
  // 所以这里不看 showPeriodLabel;那个开关只在旧版有意义(见下面的 classic 分支)。
@@ -6167,7 +7990,7 @@ function useFooterCompact() {
6167
7990
  children: [
6168
7991
  metaNode,
6169
7992
  jsx.jsxs("span", {
6170
- className: "balance-footer__timeline-track balance-footer__timeline-track--" + period,
7993
+ className: "balance-footer__timeline-track balance-footer__timeline-track--" + period + (timelinePop !== null ? " balance-footer__timeline-track--active" : ""),
6171
7994
  children: [
6172
7995
  // 裁剪层让四周各留 1px,颜色不贴边框。
6173
7996
  // 里面是泛光 + 色带两层,换日时由 TimelineBand 做交叉淡入(gradient 不可插值)。
@@ -6302,6 +8125,23 @@ function UsageCostLine({ useProjection, sessionId }) {
6302
8125
  // (响应 → setSplitMap → effect 重跑 → 再请求),死循环。用 ref 读当前值。
6303
8126
  const splitMapRef = react.useRef(splitMap);
6304
8127
  splitMapRef.current = splitMap;
8128
+ // ⚠️ 价格变了要重算,否则屏幕上的金额会停在旧价上(2026-11-26 实测发现)。
8129
+ // usageKey 只由 token 数构成、不含价格,所以同步完不会触发 ?session= 重发,
8130
+ // 而 askedSessions 又把会话标成「问过」,两边一起把数字钉死在旧价。
8131
+ // 判据用 settings.syncedPricingAt:同步成功、手动改价都会让它变。
8132
+ const lastPricingAtRef = react.useRef(null);
8133
+ react.useEffect(() => {
8134
+ const at = Number(settings.syncedPricingAt) || 0;
8135
+ // 首次只记账不清缓存,避免刚打开页面就白拉一轮
8136
+ if (lastPricingAtRef.current === null) {
8137
+ lastPricingAtRef.current = at;
8138
+ return;
8139
+ }
8140
+ if (lastPricingAtRef.current === at) return;
8141
+ lastPricingAtRef.current = at;
8142
+ if (globalThis.__balanceAsked instanceof Set) globalThis.__balanceAsked.clear();
8143
+ setSplitMap({});
8144
+ }, [settings.syncedPricingAt]);
6305
8145
  // 消耗明细面板:**点击展开**(对齐 DSH 原生「会话统计」的交互——点开切换 + 选中态 + portal 浮层)
6306
8146
  const [detailsOpen, setDetailsOpen] = react.useState(false);
6307
8147
  const detailsAnchorRef = react.useRef(null);
@@ -7943,7 +9783,7 @@ function UsageCostLine({ useProjection, sessionId }) {
7943
9783
  // ⚠️ 「免费期内」是**有期限**的文案(2026-11-02 用户:「今天都11/2号了 怎么还显示啊」)。
7944
9784
  // 原来只判 `webToolCost > 0`:计费已开始、但这几次调用本来就不计费(或在 11-01 之前发生的)
7945
9785
  // 时,金额是 0,于是永远显示「免费期内(11-01 起收费)」。必须和统计面板一样按日期判。
7946
- const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START;
9786
+ const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START && Date.now() < WEB_TOOL_FREE_FROM;
7947
9787
  costDetails.push(
7948
9788
  ["网页搜索 / 抓取", webSearchCalls + " / " + webFetchCalls + " 次"],
7949
9789
  [
@@ -7954,7 +9794,9 @@ function UsageCostLine({ useProjection, sessionId }) {
7954
9794
  ? webBillable > 0
7955
9795
  ? "¥0.0000 · 计费 " + webBillable + " 次"
7956
9796
  : "¥0.0000 · 均在免费期内产生"
7957
- : "免费期内(11-01 起收费)",
9797
+ : Date.now() >= WEB_TOOL_FREE_FROM
9798
+ ? "¥0 · 服务端搜索 / 本地抓取,只算 token"
9799
+ : "免费期内(11-01 起收费)",
7958
9800
  ],
7959
9801
  );
7960
9802
  }
@@ -8324,6 +10166,16 @@ function UsageCostLine({ useProjection, sessionId }) {
8324
10166
  const s = settings != null && typeof settings === "object" ? settings : {};
8325
10167
  const issues = [];
8326
10168
 
10169
+ // 升级残留(2026-11-27):启动时服务端已经清过一轮历史版本文件,所以这里非空
10170
+ // 基本只说明「插件进程还没重启」。不是故障,但值得说一句,别让人对着目录猜。
10171
+ const obsolete = Array.isArray(d.obsolete) ? d.obsolete.filter((x) => typeof x === "string" && x !== "") : [];
10172
+ if (obsolete.length > 0) {
10173
+ issues.push({
10174
+ level: "warn",
10175
+ text: `插件目录里还留着历史版本的文件:${obsolete.join("、")}(重启插件后自动清理)`,
10176
+ });
10177
+ }
10178
+
8327
10179
  // 余额
8328
10180
  if (d.balance == null) {
8329
10181
  issues.push({
@@ -8437,7 +10289,7 @@ function UsageCostLine({ useProjection, sessionId }) {
8437
10289
  const warn = issues.filter((x) => x.level === "warn");
8438
10290
  const out = [];
8439
10291
  if (bad.length === 0 && warn.length === 0) {
8440
- out.push("诊断结论 PASS 5 项检查通过:余额 / 今日 / 本会话 / 浮窗 / 设置");
10292
+ out.push("诊断结论 PASS 6 项检查通过:余额 / 今日 / 本会话 / 浮窗 / 设置 / 升级残留");
8441
10293
  return out;
8442
10294
  }
8443
10295
  const head = [];
@@ -8475,6 +10327,11 @@ function UsageCostLine({ useProjection, sessionId }) {
8475
10327
  lines.push("");
8476
10328
  for (const line of formatDiagVerdict(issues)) lines.push(line);
8477
10329
 
10330
+ // ── 升级残留 ──(启动时已清一轮;这里还列得出名字,就是进程还没重启)
10331
+ const obsoleteList = Array.isArray(d.obsolete) ? d.obsolete.filter((x) => typeof x === "string" && x !== "") : [];
10332
+ lines.push("");
10333
+ lines.push(`升级残留 ${obsoleteList.length === 0 ? "无" : obsoleteList.join("、") + " (重启插件后自动清理)"}`);
10334
+
8478
10335
  // ── 余额 ──
8479
10336
  const bal = d.balance;
8480
10337
  const balObj = bal != null && typeof bal === "object" ? bal : null;
@@ -8591,6 +10448,7 @@ function UsageCostLine({ useProjection, sessionId }) {
8591
10448
  lines.push(
8592
10449
  `轮询 ${s.refreshIntervalSec ?? "—"}s · 今日扫描上限 ${s.todaySessionLimit ?? "—"} · ` +
8593
10450
  `统计上限 ${s.statsSessionLimit ?? "—"} · 统计缓存 ${s.statsCacheSec ?? "—"}s · ` +
10451
+ `聚合缓存 ${s.aggCacheMax ?? "—"} 条 · ` +
8594
10452
  `低余额阈值 ${s.lowBalanceThreshold ?? "—"}`,
8595
10453
  );
8596
10454
  lines.push(
@@ -8662,6 +10520,17 @@ function UsageCostLine({ useProjection, sessionId }) {
8662
10520
  // installed — 覆盖完成,等重启
8663
10521
  // error — 查询或更新失败
8664
10522
  const [updateCheck, setUpdateCheck] = react.useState({ kind: "idle" });
10523
+ // 官方价同步的状态。kind: idle | syncing | ok | error
10524
+ const [pricingSync, setPricingSync] = react.useState({ kind: "idle" });
10525
+ // 同步成功后弹一张「同步到什么了」的卡片。用户 2026-11-26 要求:
10526
+ // 「同步计费信息成功显示一个弹窗 里面显示同步到了什么内容」
10527
+ const [pricingModal, setPricingModal] = react.useState(false);
10528
+ const [calendarModal, setCalendarModal] = react.useState(false);
10529
+ // 失败时也要有一份结果可展示(成功那份在 calendarSync.result 里)
10530
+ const [calendarSyncResult, setCalendarSyncResult] = react.useState(null);
10531
+ // 节假日同步的实时进度(服务端 ?calendarProgress=1 轮出来的)。
10532
+ // 走模型要 10 秒左右,纯静止的「同步中…」看着像卡死。
10533
+ const [calendarProgress, setCalendarProgress] = react.useState(null);
8665
10534
  // 数据诊断(设置页 → 「数据诊断」→ 点一下出表):
8666
10535
  // idle/loading/ok/error 四态 + 一份已经拼好的纯文本。只读,不写任何设置。
8667
10536
  const [diagReport, setDiagReport] = react.useState({ kind: "idle", text: "" });
@@ -8762,23 +10631,60 @@ function UsageCostLine({ useProjection, sessionId }) {
8762
10631
  : "";
8763
10632
  return "已同步 " + calendar.count + " 天 · " + stamp.slice(5) + pending;
8764
10633
  }
8765
- if (calendarSync.kind === "syncing") return "正在同步…";
10634
+ // 走模型时是「搜索 + 抓公告全文 + 解析」,实测约 10 秒;写出来免得看着像卡死。
10635
+ if (calendarSync.kind === "syncing") return calendarSync.text || "正在同步…";
8766
10636
  return "尚未同步,正在用插件内置表。";
8767
10637
  })();
10638
+ // 同步期间每 400ms 问一次进度。setTimeout 递归而不用 setInterval:
10639
+ // 一次请求挂住时不会堆出几条并发;组件卸载立刻停。
10640
+ react.useEffect(() => {
10641
+ if (calendarSync.kind !== "syncing") {
10642
+ setCalendarProgress(null);
10643
+ return;
10644
+ }
10645
+ let alive = true;
10646
+ let timer = null;
10647
+ const tick = async () => {
10648
+ try {
10649
+ const res = await fetch("/balance-api?calendarProgress=1", { headers: { accept: "application/json" } });
10650
+ const data = await res.json();
10651
+ // ⚠️ 必须校验 running 是布尔:旧版服务端不认这个路由,会回一份完整余额状态,
10652
+ // 它的 ok 同样是 true —— 不校验就把它当进度用,进度条永远停在 0(已实测)。
10653
+ if (alive && data && data.ok === true && typeof data.running === "boolean") {
10654
+ setCalendarProgress(data);
10655
+ }
10656
+ } catch {
10657
+ /* 进度拿不到不影响同步本身,下一拍再试 */
10658
+ }
10659
+ if (alive) timer = setTimeout(tick, 400);
10660
+ };
10661
+ void tick();
10662
+ return () => {
10663
+ alive = false;
10664
+ if (timer !== null) clearTimeout(timer);
10665
+ };
10666
+ }, [calendarSync.kind]);
10667
+
8768
10668
  const onSyncCalendar = async () => {
8769
10669
  if (calendarBusy) return;
8770
- setCalendarSync({ kind: "syncing", text: "正在同步…" });
10670
+ setCalendarSync({ kind: "syncing", text: "正在搜索国务院公告并解析,约 10 秒…" });
8771
10671
  try {
8772
10672
  const data = await syncCalendar();
8773
10673
  if (data && data.ok === true) {
8774
10674
  // 成功不另拼一句文案:syncCalendar() 内部已经 adoptCalendar(data) 刷新了缓存,
8775
10675
  // calendarSummary 会带着新的同步时刻自己重渲染;这里只把状态切成 ok(绿色)。
8776
- setCalendarSync({ kind: "ok", text: "" });
10676
+ // 另存一份结果给弹窗用(同步到哪几年、加了多少天、这次花了多少 token)。
10677
+ setCalendarSync({ kind: "ok", text: "", result: data });
10678
+ setCalendarModal(true);
8777
10679
  } else {
8778
10680
  setCalendarSync({
8779
10681
  kind: "error",
8780
10682
  text: (data && data.error) || "同步失败,继续使用本地数据。",
8781
10683
  });
10684
+ // 失败也弹窗:服务端已经把「模型为什么没成」「流结构」「chunk 数」「候选模型」都带回来了,
10685
+ // 只塞进指针文字一行根本看不出来。弹窗里逐项列。
10686
+ setCalendarSyncResult(data ?? null);
10687
+ setCalendarModal(true);
8782
10688
  }
8783
10689
  } catch (error) {
8784
10690
  setCalendarSync({
@@ -8827,6 +10733,72 @@ function UsageCostLine({ useProjection, sessionId }) {
8827
10733
  });
8828
10734
  };
8829
10735
 
10736
+ // 一键同步官方价与时段。用 POST:它写配置、还可能调模型(花 token),
10737
+ // GET 带副作用不符合语义,也不该被浏览器预取。
10738
+ // 同步花了多少钱。usage = { inputTokens, outputTokens, costCny, model, calls }
10739
+ // 金额小到 0.0001 级,固定四位;token 加千分位便于一眼判断量级。
10740
+ const syncCostText = (usage) => {
10741
+ if (!usage || typeof usage !== "object") return "未消耗 token";
10742
+ const inTok = Number(usage.inputTokens ?? 0);
10743
+ const outTok = Number(usage.outputTokens ?? 0);
10744
+ const cny = Number(usage.costCny ?? 0);
10745
+ const n = (v) => String(Math.round(v)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
10746
+ return "≈ " + n(inTok) + " 输入 + " + n(outTok) + " 输出 token ≈ ¥" + cny.toFixed(4)
10747
+ + (Number(usage.calls ?? 0) > 1 ? "(" + usage.calls + " 次调用)" : "");
10748
+ };
10749
+
10750
+ const onSyncPricing = () => {
10751
+ if (pricingSync.kind === "syncing") return;
10752
+ setPricingSync({ kind: "syncing", text: "正在抓官网并解析,约 5 秒…" });
10753
+ void (async () => {
10754
+ try {
10755
+ const res = await fetch("/balance-api?sync=1", {
10756
+ method: "POST",
10757
+ headers: { "Content-Type": "application/json" },
10758
+ body: "{}",
10759
+ });
10760
+ const data = await res.json();
10761
+ if (data?.ok === true) {
10762
+ setPricingSync({
10763
+ kind: "ok",
10764
+ how: data.how ?? "",
10765
+ model: data.model ?? "",
10766
+ parsed: data.parsed ?? null,
10767
+ usage: data.usage ?? null,
10768
+ modelSkipReason: data.modelSkipReason ?? "",
10769
+ chunkShape: data.chunkShape ?? "",
10770
+ at: Date.now(),
10771
+ });
10772
+ setPricingModal(true);
10773
+ // 服务端已经写盘了,本地缓存跟上,界面立刻显示新价
10774
+ if (data.settings) {
10775
+ settingsCache = {
10776
+ ...settingsCache,
10777
+ value: { ...SETTINGS_DEFAULTS, ...data.settings },
10778
+ version: settingsCache.version,
10779
+ };
10780
+ applyPeakWindowsText(settingsCache.value.peakWindowsText);
10781
+ emitSettings();
10782
+ }
10783
+ } else if (res.status === 405) {
10784
+ setPricingSync({
10785
+ kind: "error",
10786
+ error: "同步接口还没加载",
10787
+ hint: "界面已经是新版,但插件服务端要重启 DSH 才会加载新代码。重启后再点一次即可。",
10788
+ });
10789
+ } else {
10790
+ setPricingSync({
10791
+ kind: "error",
10792
+ error: data?.error ?? ("HTTP " + res.status),
10793
+ hint: data?.hint ?? "",
10794
+ });
10795
+ }
10796
+ } catch (error) {
10797
+ setPricingSync({ kind: "error", error: error instanceof Error ? error.message : String(error) });
10798
+ }
10799
+ })();
10800
+ };
10801
+
8830
10802
  // 数据诊断:打一次 `?diag=1`,把关键字段拼成纯文本摆出来。
8831
10803
  // 刻意每次都重新请求(不缓存)—— 用户点它的时机就是「刚刚好像不对」,
8832
10804
  // 拿缓存等于拿现场之前的数据,反而误导。
@@ -9008,7 +10980,10 @@ function UsageCostLine({ useProjection, sessionId }) {
9008
10980
  + "请执行 " + (updateCheck.command || "dsh plugin install balance-dsh@" + updateCheck.to)
9009
10981
  + "(或 设置 → 插件 里的更新)后再重启。";
9010
10982
  }
9011
- return "已更新到 " + updateCheck.to + ",重启 DeepSeek Harness 后生效。";
10983
+ // 2026-11-27:更新时会清理旧版本残留的 lib/*.js,拿掉几个就如实说几个。
10984
+ const cleaned = Array.isArray(updateCheck.removed) ? updateCheck.removed.length : 0;
10985
+ const cleanNote = cleaned > 0 ? "(已清理 " + cleaned + " 个旧文件)" : "";
10986
+ return "已更新到 " + updateCheck.to + cleanNote + ",重启 DeepSeek Harness 后生效。";
9012
10987
  }
9013
10988
  if (updateCheck.kind === "error") return "检查失败:" + updateCheck.error + "(可稍后重试)";
9014
10989
  if (updateCheck.kind === "ok") {
@@ -9119,32 +11094,43 @@ function UsageCostLine({ useProjection, sessionId }) {
9119
11094
  };
9120
11095
  // 逐项记录用的 effect 已经上移到早退之前(见「NEW 相关」那段说明)——
9121
11096
  // hook 不能跟在条件 return 后面。这里只留纯计算。
9122
- const row = (key, label, hint, control, extra) => jsx.jsxs("div", {
9123
- className: "balance-settings__row",
9124
- // 顶部「本版新增」横幅靠它定位跳转(querySelector('[data-newtag="key"]'))
9125
- "data-newtag": key,
9126
- children: [
9127
- jsx.jsxs("div", {
9128
- className: "balance-settings__label",
9129
- children: [
9130
- jsx.jsxs("span", {
9131
- className: "balance-settings__label-line",
9132
- children: [
9133
- jsx.jsx("span", { className: "balance-settings__label-text", children: label }),
9134
- isNew(key)
9135
- ? jsx.jsx("span", { className: "balance-settings__new-badge", children: "NEW" })
9136
- : null,
9137
- ],
9138
- }),
9139
- hint ? jsx.jsx("span", { className: "balance-settings__hint", children: hint }) : null,
9140
- ],
9141
- }),
9142
- // extra 是可选的「中间预览」:夹在说明文字和右侧控件之间,
9143
- // 由 margin-left:auto 贴向控件一侧(用户指的那块空白就在这里)。
9144
- extra || null,
9145
- jsx.jsx("div", { className: "balance-settings__control", children: control }),
9146
- ],
9147
- }, key);
11097
+ // ⚠️ below 是**整行下方的全宽内容**,渲染在 row 的**外面**。
11098
+ // 不能塞进 control:control 是 flex:none,宽度由内容决定,一塞进去
11099
+ // control 就变宽,左边 flex:1 的说明文字跟着重排
11100
+ // (2026-11-27 用户:「这个进度条换个地方 要不然导致左边的字一直在动」)。
11101
+ const row = (key, label, hint, control, extra, below) => {
11102
+ const main = jsx.jsxs("div", {
11103
+ className: "balance-settings__row",
11104
+ // 顶部「本版新增」横幅靠它定位跳转(querySelector('[data-newtag="key"]'))
11105
+ "data-newtag": key,
11106
+ children: [
11107
+ jsx.jsxs("div", {
11108
+ className: "balance-settings__label",
11109
+ children: [
11110
+ jsx.jsxs("span", {
11111
+ className: "balance-settings__label-line",
11112
+ children: [
11113
+ jsx.jsx("span", { className: "balance-settings__label-text", children: label }),
11114
+ isNew(key)
11115
+ ? jsx.jsx("span", { className: "balance-settings__new-badge", children: "NEW" })
11116
+ : null,
11117
+ ],
11118
+ }),
11119
+ hint ? jsx.jsx("span", { className: "balance-settings__hint", children: hint }) : null,
11120
+ ],
11121
+ }),
11122
+ // extra 是可选的「中间预览」:夹在说明文字和右侧控件之间,
11123
+ // 由 margin-left:auto 贴向控件一侧(用户指的那块空白就在这里)。
11124
+ extra || null,
11125
+ jsx.jsx("div", { className: "balance-settings__control", children: control }),
11126
+ ],
11127
+ }, key);
11128
+ if (!below) return main;
11129
+ // ⚠️ below 走**数组**返回,不用 react.Fragment。jsx 工厂的第 3 个参数不是 key,
11130
+ // 传进去会被当成一个额外的文本 child 渲染出来,整行的 flex 布局直接崩成竖排
11131
+ // (2026-11-27 用户截图:「法定节假日」一个字一行)。
11132
+ return [main, jsx.jsx("div", { className: "balance-settings__below", children: below }, key + "-below")];
11133
+ };
9148
11134
 
9149
11135
  const toggle = (key, label, onClick) => jsx.jsx("button", {
9150
11136
  type: "button",
@@ -9199,6 +11185,38 @@ function UsageCostLine({ useProjection, sessionId }) {
9199
11185
  );
9200
11186
 
9201
11187
  // 二选一分段控件:用于「余额行外观」这类互斥选项。第 5 参 extra 是可选的行内预览。
11188
+ // 每行自己的「模型 / 免费」小切换。之所以不做一个全局开关:
11189
+ // 价格同步和节假日同步的收益不一样,用户可能只想让一个花钱
11190
+ // (2026-11-26:「就是需要模型还是免费同步」—— 直接放各行上)。
11191
+ // 服务端在 ?config=1 里回 modelSync:{ok,reason}。不可用时「模型」那颗按钮要禁用,
11192
+ // 否则用户点了没反应、或者走一遍再退回免费,完全看不出为什么。
11193
+ const modelSyncOk = settingsCache?.modelSync?.ok !== false;
11194
+ const modelSyncReason = settingsCache?.modelSync?.reason ?? "";
11195
+ const modeMini = (key) => jsx.jsx("div", {
11196
+ className: "balance-settings__mode-mini",
11197
+ role: "radiogroup",
11198
+ "aria-label": "同步方式",
11199
+ children: [
11200
+ { value: "model", label: "模型" },
11201
+ { value: "free", label: "免费" },
11202
+ ].map((opt) => jsx.jsx("button", {
11203
+ key: opt.value,
11204
+ type: "button",
11205
+ role: "radio",
11206
+ "aria-checked": value[key] === opt.value,
11207
+ title: opt.value === "model"
11208
+ ? (modelSyncOk ? "调用模型,读得准,会消耗 token" : (modelSyncReason || "这个环境用不了模型同步"))
11209
+ : "不调用模型,不花钱,官网改版可能读不出来",
11210
+ // 环境没挂载 dsh-llm 时「模型」是真用不了,禁掉并让 title 说明原因
11211
+ disabled: opt.value === "model" && !modelSyncOk,
11212
+ className:
11213
+ "balance-settings__mode-mini-btn balance-settings__mode-mini-btn--" + opt.value +
11214
+ (value[key] === opt.value ? " balance-settings__mode-mini-btn--on" : ""),
11215
+ onClick: () => patch(key, opt.value),
11216
+ children: opt.label,
11217
+ }, opt.value)),
11218
+ });
11219
+
9202
11220
  const choiceRow = (key, label, hint, options, extra) => row(key, label, hint, jsx.jsx("div", {
9203
11221
  className: "balance-settings__segmented",
9204
11222
  role: "radiogroup",
@@ -9231,13 +11249,17 @@ function UsageCostLine({ useProjection, sessionId }) {
9231
11249
  }),
9232
11250
  });
9233
11251
  // note:分组级说明(可选),渲染在分组标题下方、行上方,用来说明这组的口径/适用范围
9234
- const group = (key, title, rows, note) => jsx.jsxs("div", {
11252
+ // note 可以是一句话,也可以是 { text, tone: "warn" }(警告用琥珀色,别和普通说明混在一起)。
11253
+ const group = (key, title, rows, note) => {
11254
+ const noteText = note !== null && typeof note === "object" ? note.text : note;
11255
+ const noteWarn = note !== null && typeof note === "object" && note.tone === "warn";
11256
+ return jsx.jsxs("div", {
9235
11257
  className: "balance-settings__group",
9236
11258
  children: [
9237
11259
  jsx.jsx("div", { className: "balance-settings__group-title", children: title }),
9238
- note
11260
+ noteText
9239
11261
  ? jsx.jsxs("div", {
9240
- className: "balance-settings__group-note",
11262
+ className: "balance-settings__group-note" + (noteWarn ? " balance-settings__group-note--warn" : ""),
9241
11263
  children: [
9242
11264
  // 同顶部告示那颗:宽高必须等于 viewBox 的 16,14/16 的非整数缩放会把描边抹糊。
9243
11265
  jsx.jsxs("svg", {
@@ -9255,13 +11277,14 @@ function UsageCostLine({ useProjection, sessionId }) {
9255
11277
  jsx.jsx("circle", { cx: 8, cy: 4.9, r: 0.85, fill: "currentColor", stroke: "none" }),
9256
11278
  ],
9257
11279
  }),
9258
- jsx.jsx("span", { className: "balance-settings__group-note-text", children: note }),
11280
+ jsx.jsx("span", { className: "balance-settings__group-note-text", children: noteText }),
9259
11281
  ],
9260
11282
  })
9261
11283
  : null,
9262
11284
  ...rows,
9263
11285
  ],
9264
- }, key);
11286
+ }, key);
11287
+ };
9265
11288
 
9266
11289
  // 自定义价格已从界面移除:价格本来就跟随官方内置价表(官方调价时更新插件即可),
9267
11290
  // 普通用户没有自己填的必要。服务端仍支持 settings.priceByModel 覆盖价,
@@ -9302,29 +11325,6 @@ function UsageCostLine({ useProjection, sessionId }) {
9302
11325
  openSettings ? jsx.jsxs("div", {
9303
11326
  className: "balance-settings__body",
9304
11327
  children: [
9305
- // 「本版新增」横幅:只在有条目新功能未过期时出现。
9306
- // 它不依赖侧栏入口 —— 用户关闭「侧边栏显示本插件」、或从 DSH「插件」
9307
- // 页直接进来时,这是唯一能看到"有新功能"的地方(2026-10-31 用户提问)。
9308
- pendingNew.length > 0
9309
- ? jsx.jsxs("div", {
9310
- className: "balance-settings__newcue",
9311
- children: [
9312
- jsx.jsx("span", { className: "balance-settings__newcue-badge", children: "NEW" }),
9313
- jsx.jsx("span", {
9314
- className: "balance-settings__newcue-text",
9315
- children: "本版新增:" + pendingNew
9316
- .map((item) => NEW_TAG_LABELS[item.key] || item.key)
9317
- .join(" · "),
9318
- }),
9319
- jsx.jsx("button", {
9320
- type: "button",
9321
- className: "balance-settings__newcue-btn",
9322
- onClick: () => focusNewRow(pendingNew[0].key),
9323
- children: "去看看",
9324
- }),
9325
- ],
9326
- })
9327
- : null,
9328
11328
  // 顶部告示:计费范围限制放在最前面,打开设置第一眼就看到,
9329
11329
  // 不用翻到「计费」分组才发现。
9330
11330
  jsx.jsxs("div", {
@@ -9354,6 +11354,29 @@ function UsageCostLine({ useProjection, sessionId }) {
9354
11354
  }),
9355
11355
  ],
9356
11356
  }),
11357
+ // 「本版新增」横幅:只在有条目新功能未过期时出现。
11358
+ // 它不依赖侧栏入口 —— 用户关闭「侧边栏显示本插件」、或从 DSH「插件」
11359
+ // 页直接进来时,这是唯一能看到"有新功能"的地方(2026-10-31 用户提问)。
11360
+ pendingNew.length > 0
11361
+ ? jsx.jsxs("div", {
11362
+ className: "balance-settings__newcue",
11363
+ children: [
11364
+ jsx.jsx("span", { className: "balance-settings__newcue-badge", children: "NEW" }),
11365
+ jsx.jsx("span", {
11366
+ className: "balance-settings__newcue-text",
11367
+ children: "本版新增:" + pendingNew
11368
+ .map((item) => NEW_TAG_LABELS[item.key] || item.key)
11369
+ .join(" · "),
11370
+ }),
11371
+ jsx.jsx("button", {
11372
+ type: "button",
11373
+ className: "balance-settings__newcue-btn",
11374
+ onClick: () => focusNewRow(pendingNew[0].key),
11375
+ children: "去看看",
11376
+ }),
11377
+ ],
11378
+ })
11379
+ : null,
9357
11380
  // 版本与更新:放在最前面(用户要"往上放一点")。
9358
11381
  // 检查、更新、结果说明都在这一块,底部只留保存状态与「恢复默认」。
9359
11382
  jsx.jsxs("div", {
@@ -9434,56 +11457,142 @@ function UsageCostLine({ useProjection, sessionId }) {
9434
11457
  ],
9435
11458
  }),
9436
11459
 
9437
- // 节假日同步紧跟在「版本与更新」下面:两者都是「后台自动补一次 + 可手动触发」,
9438
- // 放一起比塞在「计费」末尾好找。数据本身仍然决定算钱口径,只是入口挪了位置。
9439
- group("calendar", "节假日数据", [
9440
- row(
9441
- "calendar",
9442
- "同步状态",
9443
- "法定节假日与调休从国务院公告同步。插件每 30 天自动同步一次,这里可以手动立即更新。",
9444
- jsx.jsxs("div", {
9445
- className: "balance-settings__calendar",
9446
- children: [
9447
- jsx.jsx("span", {
9448
- className:
9449
- "balance-settings__calendar-note" +
9450
- (calendarSync.kind === "error"
9451
- ? " balance-settings__calendar-note--error"
9452
- : calendarSync.kind === "ok"
9453
- ? " balance-settings__calendar-note--ok"
9454
- : calendar.fetchedAt > 0
9455
- ? ""
9456
- : " balance-settings__calendar-note--warn"),
9457
- children: calendarSummary,
9458
- }),
9459
- jsx.jsx("button", {
9460
- type: "button",
9461
- className: "balance-settings__btn",
9462
- onClick: onSyncCalendar,
9463
- disabled: calendarBusy,
9464
- children: calendarBusy ? "同步中…" : "立即同步",
11460
+ // 两个同步都是「去官方拉当前口径」,单起一类放最前 —— 它们决定算钱对不对,
11461
+ // 比下面的余额参数重要得多。
11462
+ group("sync", "官方同步", [
11463
+ row(
11464
+ "syncedPricingAt",
11465
+ "价格与时段",
11466
+ jsx.jsxs("span", {
11467
+ children: [
11468
+ "抓一次官网,把最新价与时段覆盖到本地配置。",
11469
+ pricingSync.kind === "error"
11470
+ ? jsx.jsx("span", {
11471
+ className: "balance-settings__hint-error",
11472
+ children: "✕ 同步失败:" + pricingSync.error + (pricingSync.hint ? "(" + pricingSync.hint + ")" : "") + "。现有配置未改动。",
11473
+ })
11474
+ : null,
11475
+ ],
11476
+ }),
11477
+ jsx.jsxs("div", { className: "balance-settings__row-actions", children: [
11478
+ modeMini("syncModePricing"),
11479
+ jsx.jsx("button", {
11480
+ type: "button",
11481
+ className: "balance-settings__btn balance-settings__btn--primary",
11482
+ onClick: onSyncPricing,
11483
+ disabled: pricingSync.kind === "syncing",
11484
+ children: pricingSync.kind === "syncing" ? "同步中…" : "立即同步",
11485
+ }),
11486
+ ] }),
11487
+ ),
11488
+ // 节假日同样决定算钱口径(法定节假日全天按空闲价),和价格同步并排。
11489
+ row(
11490
+ "calendar",
11491
+ "法定节假日",
11492
+ jsx.jsxs("span", {
11493
+ children: [
11494
+ "同步当年放假与调休日期,全天按空闲价计费。",
11495
+ calendar.fetchedAt > 0
11496
+ ? null
11497
+ : jsx.jsx("span", {
11498
+ className: "balance-settings__hint-warn",
11499
+ children: "⚠️ 还没同步过,先用内置日历",
9465
11500
  }),
9466
- ],
11501
+ ],
11502
+ }),
11503
+ jsx.jsxs("div", {
11504
+ className: "balance-settings__calendar",
11505
+ children: [
11506
+ modeMini("syncModeCalendar"),
11507
+ jsx.jsx("span", {
11508
+ className:
11509
+ "balance-settings__calendar-note" +
11510
+ (calendarSync.kind === "error"
11511
+ ? " balance-settings__calendar-note--error"
11512
+ : calendarSync.kind === "ok"
11513
+ ? " balance-settings__calendar-note--ok"
11514
+ : calendar.fetchedAt > 0
11515
+ ? ""
11516
+ : " balance-settings__calendar-note--warn"),
11517
+ children: calendarSummary,
9467
11518
  }),
9468
- ),
9469
- ]),
11519
+ jsx.jsx("button", {
11520
+ type: "button",
11521
+ className: "balance-settings__btn balance-settings__btn--primary",
11522
+ onClick: onSyncCalendar,
11523
+ disabled: calendarBusy,
11524
+ children: calendarBusy ? "同步中…" : "立即同步",
11525
+ }),
11526
+ ],
11527
+ }),
11528
+ // 只在同步中出现;渲染在整行**下面**(row 的 below 参数),
11529
+ // 不占右侧 control 的宽度 —— 否则进度条一出现就把 control 撑宽、
11530
+ // 左边说明文字整段重排(2026-11-27 用户:「换个地方 要不然导致左边的字一直在动」)。
11531
+ calendarSync.kind === "syncing"
11532
+ ? jsx.jsxs("div", {
11533
+ className: "balance-settings__progress",
11534
+ children: [
11535
+ jsx.jsx("div", {
11536
+ className: "balance-settings__progress-track",
11537
+ children: jsx.jsx("div", {
11538
+ className:
11539
+ "balance-settings__progress-fill" +
11540
+ (calendarProgressPct(calendarProgress) > 0 || calendarProgress?.total > 0
11541
+ ? ""
11542
+ : " balance-settings__progress-fill--indeterminate"),
11543
+ style:
11544
+ calendarProgressPct(calendarProgress) > 0 || calendarProgress?.total > 0
11545
+ ? { width: calendarProgressPct(calendarProgress) + "%" }
11546
+ : undefined,
11547
+ }),
11548
+ }),
11549
+ jsx.jsx("span", {
11550
+ className: "balance-settings__progress-label",
11551
+ children: (() => {
11552
+ const p = calendarProgress;
11553
+ if (p == null || p.label == null || p.label === "") {
11554
+ return calendarSync.text || "正在同步…";
11555
+ }
11556
+ const total = Number(p.total) || 0;
11557
+ const done = Number(p.done) || 0;
11558
+ if (total <= 1) return p.label;
11559
+ const cur = p.phase === "done" ? done : Math.min(total, done + 1);
11560
+ return String(cur) + "/" + String(total) + " · " + p.label;
11561
+ })(),
11562
+ }),
11563
+ ],
11564
+ })
11565
+ : null,
11566
+ ),
11567
+ ], (() => {
11568
+ // 提示条跟两个开关的组合走:只说当下真会发生的事。
11569
+ const p = value.syncModePricing === "free" ? "free" : "model";
11570
+ const c2 = value.syncModeCalendar === "free" ? "free" : "model";
11571
+ if (p === "free" && c2 === "free") {
11572
+ return { text: "两行都用免费模式,不调用模型、不产生任何消耗。代价是官网改版后可能读不出来。" };
11573
+ }
11574
+ if (p === "model" && c2 === "model") {
11575
+ return {
11576
+ text: "两行都走模型,会产生少量 token 消耗(合计折合不到 ¥0.02)。",
11577
+ tone: "warn",
11578
+ };
11579
+ }
11580
+ return {
11581
+ text: (p === "model" ? "价格" : "节假日") + "那行走模型,会产生少量 token 消耗;另一行走免费模式,不花钱。",
11582
+ tone: "warn",
11583
+ };
11584
+ })()),
9470
11585
 
9471
- group("balance", "余额", [
11586
+ group("balance", "余额", [
9472
11587
  numberRow("refreshIntervalSec", "余额刷新间隔", "轮询间隔;对话产生新消耗时也会顺带刷新。", 5, 3600, "秒"),
9473
11588
  numberRow("lowBalanceThreshold", "低余额警示阈值", "余额低于该值时金额转为琥珀色。", 0, 100000, "元"),
9474
- row("apiKey", "API Key", "官方账号未登录或读不到余额时的回退凭据;留空则只用官方账号。",
9475
- jsx.jsx("input", {
9476
- className: "balance-settings__input",
9477
- style: { width: "280px" },
9478
- type: "password",
9479
- autoComplete: "off",
9480
- placeholder: "sk-…(留空 = 不设置)",
9481
- value: value.apiKey == null ? "" : value.apiKey,
9482
- onChange: (event) => patch("apiKey", event.target.value),
9483
- })),
11589
+ // 「API Key」输入框已按用户要求撤掉(2026-11-27:「这个选项删除 不需要了」)。
11590
+ // 服务端的 apiKey 字段与回退链路一律不动:已保存过的值仍能用于
11591
+ // 「官方账号读不到余额」的兜底,只是不再在界面上暴露与编辑。
9484
11592
  ]),
9485
11593
 
9486
- group("display", "界面显示", [
11594
+ // 侧边栏那排:全是「展开侧边栏后长什么样」,和对话区无关,所以和下面拆开
11595
+ group("sidebar", "侧边栏", [
9487
11596
  toggleRow("showBalanceRow", "侧边栏余额行", "展开侧边栏时底部紧挨设置齿轮的那一行。"),
9488
11597
  choiceRow("footerStyle", "余额行样式", "新版:上方一行文字信息 + 扁刻度条;旧版:钱包图标 + 「余额」 + 金额的纯文字行。", [
9489
11598
  { value: "timeline", label: "新版" },
@@ -9504,6 +11613,13 @@ function UsageCostLine({ useProjection, sessionId }) {
9504
11613
  value.footerStyle === "timeline"
9505
11614
  ? toggleRow("refreshWave", "右键刷新浪潮", "右键余额时,金额会被一道白光从左往右擦出来(和输入区「本会话消耗」同一个动效)。")
9506
11615
  : null,
11616
+ value.footerStyle === "classic"
11617
+ ? toggleRow("showPeriodLabel", "高峰 / 空闲标签", "旧版余额行里「金额 • 时段」的时段部分;关掉后只留金额。")
11618
+ : null,
11619
+ ]),
11620
+
11621
+ // 对话区那排:消耗浮窗、它的加载动效、以及收起侧边栏后那颗圆钮
11622
+ group("conversation", "对话界面", [
9507
11623
  toggleRow("showUsagePill", "会话消耗行", "对话界面右下角的小浮窗:一行两列(「本会话消耗估算」+ 金额),点开是明细浮层。"),
9508
11624
  // 两种加载动效互斥,用分段按钮选(和「余额行外观」同一个控件,视觉一致)。
9509
11625
  // 选项文字用「样式1 / 样式2」而不是效果名,所以旁边直接播一个真预览 ——
@@ -9552,38 +11668,32 @@ function UsageCostLine({ useProjection, sessionId }) {
9552
11668
  ],
9553
11669
  }, "p-cur"),
9554
11670
  })),
9555
- value.footerStyle === "classic"
9556
- ? toggleRow("showPeriodLabel", "高峰 / 空闲标签", "旧版余额行里「金额 • 时段」的时段部分;关掉后只留金额。")
9557
- : null,
9558
- ]),
9559
11671
 
9560
- group("fab", "收起态圆钮", [
11672
+ // 收起侧边栏后那颗悬浮圆钮 —— 它出现在对话区左下角,属于这一组
9561
11673
  toggleRow("showFab", "显示圆钮", "收起侧边栏时左下角的悬浮圆形余额。"),
9562
- numberRow("fabSize", "直径", "圆钮大小;圆内字号按比例缩放。", 32, 120, "px"),
9563
- numberRow("fabLeft", "距左缘", "数值越大越靠右;收起态卡片左下角等距,所以它同时也是距底边的距离。", 0, 600, "px"),
11674
+ numberRow("fabSize", "圆钮直径", "圆钮大小;圆内字号按比例缩放。", 32, 120, "px"),
11675
+ numberRow("fabLeft", "圆钮距左缘", "数值越大越靠右;收起态卡片左下角等距,所以它同时也是距底边的距离。", 0, 600, "px"),
9564
11676
  ]),
9565
11677
 
9566
- group("stats", "用量统计", [
11678
+ // 这四个都是「扫描多少 / 记多少」的性能旋钮,和界面无关,单独一组
11679
+ group("stats", "性能与缓存", [
9567
11680
  numberRow("todaySessionLimit", "今日消耗扫描上限", "启动时最多统计今天动过的多少个会话(多开对话、多跑子代理时调大,越大越全也可能越慢)。", 10, 2000, "个"),
9568
11681
  numberRow("statsSessionLimit", "扫描会话数上限", "统计面板最多回看多少个历史会话(越大越慢)。", 10, 2000, "个"),
9569
11682
  numberRow("statsCacheSec", "统计缓存时长", "统计结果缓存多久;0 = 每次重新扫描。", 0, 3600, "秒"),
9570
- ]),
9571
-
9572
- group("billing", "计费", [
9573
- // 官方改时段就等于改「哪几个小时翻倍」。留成可编辑项,
9574
- // 以后即使没人改代码,用户自己也能跟上官方口径。
9575
- textRow(
9576
- "peakWindowsText",
9577
- "高峰时段",
9578
- "工作日北京时间的这些时段按高峰计价。格式 9-12, 14-18(官方当前值)。写错了自动沿用上一组有效值。",
9579
- "9-12, 14-18",
11683
+ numberRow(
11684
+ "aggCacheMax",
11685
+ "聚合缓存条数上限",
11686
+ "最多记住多少个会话算过的结果。超过就从最旧的开始丢 —— 丢掉的不会丢数据,只是下次打开那个会话要重算一遍。会话多、把上面两个上限调大的人可以调高。",
11687
+ 100,
11688
+ 5000,
11689
+ "条",
9580
11690
  ),
9581
- numberRow("peakMultiplier", "高峰时段倍率", "官方为 2(高峰价 = 空闲价 × 倍率)。", 1, 10, "倍"),
9582
11691
  ]),
9583
11692
 
9584
- // 数据诊断排在最后:它是排障入口,不是日常设置,
9585
- // 出问题时往下翻一屏就能找到,平时不占视线。只读,不写任何设置。
11693
+ // 数据诊断排在最后:它是排障入口,不是日常设置,出问题时往下翻一屏就能找到,
11694
+ // 平时不占视线。只读,不写任何设置。
9586
11695
  group("diag", "数据诊断", [
11696
+
9587
11697
  row(
9588
11698
  "diag",
9589
11699
  "生成诊断报告",
@@ -9677,6 +11787,243 @@ function UsageCostLine({ useProjection, sessionId }) {
9677
11787
  ],
9678
11788
  }) : null,
9679
11789
 
11790
+ // 同步成功后弹出一张「同步到了什么」的卡片。用户 2026-11-26:
11791
+ // 「同步计费信息成功显示一个弹窗 里面显示同步到了什么内容」
11792
+ // 复用官方 Modal:设置卡片在 slot 里,自己画遮罩要处理层叠上下文,麻烦且易被裁。
11793
+ tipModal && pricingModal && pricingSync.kind === "ok"
11794
+ ? jsx.jsx(tipModal, {
11795
+ open: true,
11796
+ title: "价格与时段已同步",
11797
+ closeLabel: "知道了",
11798
+ onClose: () => setPricingModal(false),
11799
+ children: jsx.jsxs("div", {
11800
+ className: "balance-settings__sync",
11801
+ children: [
11802
+ jsx.jsxs("div", {
11803
+ className: "balance-settings__sync-grid",
11804
+ children: [
11805
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "高峰时段" }),
11806
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: (pricingSync.parsed?.peakWindowsText ?? "—") + "(工作日北京时间)" }),
11807
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "高峰倍率" }),
11808
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "×" + (pricingSync.parsed?.peakMultiplier ?? "—") + "(高峰价 = 空闲价 × 倍率)" }),
11809
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "flash 输入" }),
11810
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "未命中 ¥" + (pricingSync.parsed?.priceFlash?.inputCnyPerMillion ?? "—") + " · 命中 ¥" + (pricingSync.parsed?.priceFlash?.cacheReadCnyPerMillion ?? "—") + " / 百万 tokens" }),
11811
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "flash 输出" }),
11812
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "¥" + (pricingSync.parsed?.priceFlash?.outputCnyPerMillion ?? "—") + " / 百万 tokens" }),
11813
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "pro 输入" }),
11814
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "未命中 ¥" + (pricingSync.parsed?.pricePro?.inputCnyPerMillion ?? "—") + " · 命中 ¥" + (pricingSync.parsed?.pricePro?.cacheReadCnyPerMillion ?? "—") + " / 百万 tokens" }),
11815
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "pro 输出" }),
11816
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "¥" + (pricingSync.parsed?.pricePro?.outputCnyPerMillion ?? "—") + " / 百万 tokens" }),
11817
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "解析方式" }),
11818
+ jsx.jsx("span", {
11819
+ className: "balance-settings__sync-val" + (pricingSync.how === "model" ? " balance-settings__sync-val--warn" : ""),
11820
+ children:
11821
+ pricingSync.how === "model"
11822
+ ? [
11823
+ "模型解析",
11824
+ // 模型名单独一块、独占一行:整串 "deepseek-official/deepseek-v4-flash"
11825
+ // 太长,跟着「模型解析」挤会从 "v4-" 后面硬断成两截。
11826
+ jsx.jsx("span", { className: "balance-settings__sync-sub", children: "(" + (pricingSync.model || "未知模型") + ")" }, "model"),
11827
+ ]
11828
+ : "没走模型(退回内置规则,未消耗 token)",
11829
+ }),
11830
+ // 选了模型却没走成 —— 把服务端给的原因原样摆出来,别让人对着「没走模型」猜
11831
+ pricingSync.how !== "model" && pricingSync.modelSkipReason
11832
+ ? jsx.jsxs("div", {
11833
+ style: { display: "contents" },
11834
+ children: [
11835
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型没跑成" }),
11836
+ jsx.jsx("span", {
11837
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
11838
+ style: { wordBreak: "break-all", lineHeight: "17px" },
11839
+ children: pricingSync.modelSkipReason,
11840
+ }),
11841
+ ],
11842
+ })
11843
+ : null,
11844
+ pricingSync.how !== "model" && pricingSync.modelSkipReason !== "" && pricingSync.chunkShape
11845
+ ? jsx.jsxs("div", {
11846
+ style: { display: "contents" },
11847
+ children: [
11848
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "流结构" }),
11849
+ jsx.jsx("span", {
11850
+ className: "balance-settings__sync-val",
11851
+ style: { wordBreak: "break-all", lineHeight: "16px", fontSize: "10.5px" },
11852
+ children: pricingSync.chunkShape,
11853
+ }),
11854
+ ],
11855
+ })
11856
+ : null,
11857
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "本次消耗" }),
11858
+ jsx.jsx("span", {
11859
+ className: "balance-settings__sync-val" + (pricingSync.usage ? " balance-settings__sync-val--cost" : ""),
11860
+ children: syncCostText(pricingSync.usage),
11861
+ }),
11862
+ ],
11863
+ }),
11864
+ jsx.jsx("div", {
11865
+ className: "balance-settings__sync-note",
11866
+ children: "已写入本地配置,升级插件不会覆盖。这些是目录价,展示时按上面倍率区分高峰 / 空闲。",
11867
+ }),
11868
+ ],
11869
+ }),
11870
+ })
11871
+ : null,
11872
+
11873
+ // 节假日同步成功后同样弹一张:同步到哪几年、加了多少天、这次花了多少钱。
11874
+ // 用户 2026-11-26:「这个也加一个弹窗 并且给两个同步都加一个计费」。
11875
+ // 失败时也弹窗,把服务端的诊断逐项摆出来 —— 否则用户只能看到行内一行「连不上」。
11876
+ tipModal && calendarModal && calendarSync.kind === "error"
11877
+ ? jsx.jsx(tipModal, {
11878
+ open: true,
11879
+ title: "节假日同步没成功",
11880
+ closeLabel: "知道了",
11881
+ onClose: () => setCalendarModal(false),
11882
+ children: jsx.jsxs("div", {
11883
+ className: "balance-settings__sync-grid",
11884
+ children: [
11885
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "结果" }),
11886
+ jsx.jsx("span", { className: "balance-settings__sync-val balance-settings__sync-val--warn", children: calendarSync.text || "同步失败" }),
11887
+ ...(calendarSyncResult?.modelSkipReason
11888
+ ? [
11889
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型没跑成" }),
11890
+ jsx.jsx("span", {
11891
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
11892
+ style: { wordBreak: "break-all", lineHeight: "17px" },
11893
+ children: calendarSyncResult.modelSkipReason,
11894
+ }),
11895
+ ]
11896
+ : []),
11897
+ ...(calendarSyncResult?.chunkCount != null
11898
+ ? [
11899
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "收到 chunk" }),
11900
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: String(calendarSyncResult.chunkCount) }),
11901
+ ]
11902
+ : []),
11903
+ ...(calendarSyncResult?.chunkShape
11904
+ ? [
11905
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "流结构" }),
11906
+ jsx.jsx("span", {
11907
+ className: "balance-settings__sync-val",
11908
+ style: { wordBreak: "break-all", lineHeight: "16px", fontSize: "10.5px" },
11909
+ children: calendarSyncResult.chunkShape,
11910
+ }),
11911
+ ]
11912
+ : []),
11913
+ ...(calendarSyncResult?.candidates
11914
+ ? [
11915
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "候选模型" }),
11916
+ jsx.jsx("span", {
11917
+ className: "balance-settings__sync-val",
11918
+ style: { wordBreak: "break-all", lineHeight: "16px", fontSize: "10.5px" },
11919
+ children: calendarSyncResult.candidates,
11920
+ }),
11921
+ ]
11922
+ : []),
11923
+ ...(calendarSyncResult?.modelListRaw
11924
+ ? [
11925
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型列表" }),
11926
+ jsx.jsx("span", {
11927
+ className: "balance-settings__sync-val",
11928
+ style: { wordBreak: "break-all", lineHeight: "15px", fontSize: "10px" },
11929
+ children: calendarSyncResult.modelListRaw,
11930
+ }),
11931
+ ]
11932
+ : []),
11933
+ ...(Array.isArray(calendarSyncResult?.failedYears) && calendarSyncResult.failedYears.length > 0
11934
+ ? [
11935
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "失败年份" }),
11936
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: calendarSyncResult.failedYears.join(" / ") }),
11937
+ ]
11938
+ : []),
11939
+ ],
11940
+ }),
11941
+ })
11942
+ : null,
11943
+ tipModal && calendarModal && calendarSync.kind === "ok"
11944
+ ? jsx.jsx(tipModal, {
11945
+ open: true,
11946
+ // 标题必须反映真实结果:只要还有年份没拿到(failedYears 或 pending),
11947
+ // 就不能写「已同步」—— 2026-11-26 用户看到「已同步」同时看到「模型没跑成」,
11948
+ // 两句互相打脸。
11949
+ title: (Array.isArray(calendarSync.result?.failedYears) && calendarSync.result.failedYears.length > 0)
11950
+ ? "法定节假日部分同步"
11951
+ : "法定节假日已同步",
11952
+ closeLabel: "知道了",
11953
+ onClose: () => setCalendarModal(false),
11954
+ children: jsx.jsxs("div", {
11955
+ className: "balance-settings__sync",
11956
+ children: [
11957
+ jsx.jsxs("div", {
11958
+ className: "balance-settings__sync-grid",
11959
+ children: [
11960
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "同步年份" }),
11961
+ jsx.jsx("span", {
11962
+ className: "balance-settings__sync-val",
11963
+ children: Array.isArray(calendarSync.result?.years) && calendarSync.result.years.length > 0
11964
+ ? calendarSync.result.years.join(" / ")
11965
+ : "没有变化",
11966
+ }),
11967
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "新增天数" }),
11968
+ jsx.jsx("span", {
11969
+ className: "balance-settings__sync-val",
11970
+ children: Number(calendarSync.result?.added ?? 0) > 0
11971
+ ? calendarSync.result.added + " 天"
11972
+ : "0 天(已是最新)",
11973
+ }),
11974
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "日历总量" }),
11975
+ jsx.jsx("span", {
11976
+ className: "balance-settings__sync-val",
11977
+ children: (calendar.count ?? 0) + " 天"
11978
+ + (Array.isArray(calendar.missing) && calendar.missing.length > 0
11979
+ ? "(" + calendar.missing.join(" / ") + " 待公布)"
11980
+ : ""),
11981
+ }),
11982
+ // 失败年份要进弹窗:光有「模型没跑成」看不出是哪一年没拿到。
11983
+ ...(Array.isArray(calendarSync.result?.failedYears) && calendarSync.result.failedYears.length > 0
11984
+ ? [
11985
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "失败年份" }),
11986
+ jsx.jsx("span", {
11987
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
11988
+ children: calendarSync.result.failedYears.join(" / ") + "(沿用本地数据)",
11989
+ }),
11990
+ ]
11991
+ : []),
11992
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "数据来源" }),
11993
+ jsx.jsx("span", {
11994
+ className: "balance-settings__sync-val",
11995
+ children: calendarSync.result?.usage
11996
+ ? "模型搜索国务院公告"
11997
+ : "没走模型(取的是第三方 JSON,未消耗 token)",
11998
+ }),
11999
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "本次消耗" }),
12000
+ jsx.jsx("span", {
12001
+ className: "balance-settings__sync-val" + (calendarSync.result?.usage ? " balance-settings__sync-val--cost" : ""),
12002
+ children: syncCostText(calendarSync.result?.usage),
12003
+ }),
12004
+ // 选了模型却没花钱,一定有个原因 —— 别让用户对着「未消耗 token」猜。
12005
+ // 用数组展开而不是 Fragment:项目的 jsx 工厂里没有 Fragment,别赌。
12006
+ ...(calendarSync.result?.modelSkipReason
12007
+ ? [
12008
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型没跑成" }),
12009
+ jsx.jsx("span", {
12010
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
12011
+ style: { wordBreak: "break-all", lineHeight: "17px" },
12012
+ children: calendarSync.result.modelSkipReason,
12013
+ }),
12014
+ ]
12015
+ : []),
12016
+ ],
12017
+ }),
12018
+ jsx.jsx("div", {
12019
+ className: "balance-settings__sync-note",
12020
+ children: "法定节假日全天按空闲价计费,调休上班的周末按工作日峰谷算。已写入本地配置,升级插件不会覆盖。",
12021
+ }),
12022
+ ],
12023
+ }),
12024
+ })
12025
+ : null,
12026
+
9680
12027
  // 关掉侧边栏入口后的提醒:直接用 DSH 官方 Modal 渲染。
9681
12028
  tipModal && sidebarTip
9682
12029
  ? jsx.jsx(tipModal, {