balance-dsh 2.3.5 → 2.3.7

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 +5 -6
  2. package/lib/client.js +3046 -236
  3. package/lib/index.js +2306 -101
  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
 
@@ -634,6 +634,14 @@ window.__ModuleLoader__.load({
634
634
  box-shadow:0 0 5px 1.5px rgba(34,197,94,.26),0 0 20px 3px rgba(34,197,94,.34)}
635
635
  .balance-footer--stacked .balance-footer__value--low:hover{
636
636
  box-shadow:0 0 5px 1.5px rgba(217,119,6,.26),0 0 20px 3px rgba(217,119,6,.34)}
637
+ /* 上面两条把泛光色**写死**成绿 / 橙,所以默认那条(绿)会落到所有没显式覆盖的状态上:
638
+ 余额耗尽那颗「充值」胶囊是红的(--topup),悬停时却冒出绿光
639
+ (2026-11-27 用户截图:「这个泛光颜色不对」)。红胶囊必须配红光。
640
+ ⚠️ 以后再加状态色(--empty 这类)也一定要在这里补一条,别指望默认那条会跟着变。 */
641
+ .balance-footer--stacked .balance-footer__value--topup:hover,
642
+ .balance-footer--stacked .balance-footer__value--empty:hover,
643
+ .balance-footer--stacked .balance-footer__value--error:hover{
644
+ box-shadow:0 0 5px 1.5px rgba(229,72,77,.26),0 0 20px 3px rgba(229,72,77,.34)}
637
645
  .balance-footer__value--healthy:hover{background:rgba(34,197,94,.22)}
638
646
  .balance-footer__value--low:hover{background:rgba(217,119,6,.22)}
639
647
  /* 旧版布局:胶囊靠右 —— 这是备份 v1.3.1 里的原始写法(margin-left:auto)。
@@ -702,20 +710,26 @@ window.__ModuleLoader__.load({
702
710
  /* 旧版金额胶囊里的分隔点:两侧各 5px,柔化到 50% 不透明,不抢金额 */
703
711
  .balance-footer__sep{flex:none;margin:0 5px;opacity:.5;font-weight:400}
704
712
  .balance-footer__period-inline{font-weight:500;white-space:nowrap}
705
- .balance-footer__period-inline--refreshing{color:var(--dsw-alias-label-secondary)}
713
+ .balance-footer__period-inline--refreshing{color:var(--dsw-alias-label-secondary,#b9b9bd)}
706
714
  .balance-footer__period-inline--peak{color:var(--dsw-alias-state-error-primary,#e5484d)}
707
715
  .balance-footer__period-inline--offpeak{color:var(--dsw-alias-state-success-primary)}
708
716
  /* 时段刻度条:色带固定 = 一整天,指针随时刻从左走到右。
709
717
  结构:[meta 行(今日/时段/剩余)] + [轨道(边框) → 裁剪层(1px 内缩 → 泛光 + 色带) + 指针]。
710
718
  轨道刻意做扁(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}
719
+ /* 容器必须 overflow:visible:hover 的 scale + box-shadow 泛光要能溢出这块,
720
+ 原来 hidden 会把放大出来的边缘和整圈光晕裁掉(2026-11-26 用户:
721
+ 「鼠标放上去的整体放大一点 然后泛光」)。
722
+ 裁剪下沉到文字行(.balance-footer__timeline-meta)—— 真正会横向溢出的是它(可折行、
723
+ 「剩 1d20h」字数会变),这才是那条「不压到金额上」要防的东西;
724
+ 刻度条受 flex 限制本来就不会超出。色带圆角仍由内部的 .balance-footer__timeline-clip 自己裁。 */
725
+ .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
726
  /* meta 行:等宽数字,三项之间用中点分隔感靠 gap 制造。
713
727
  三项都 flex:none、都 nowrap,所以这一行只会随内容变宽、永不主动收缩 ——
714
728
  「今日 ¥1234.56」比「今日 ¥14.34」宽两三个数字位,余额胶囊又同时要宽度,
715
729
  两者硬碰硬时右侧胶囊会被挤出容器裁掉(余额四位数 + 消费四位数就能复现)。
716
730
  所以给它 max-width + flex-wrap:空间不够时三项自己折行,块变高(--stacked 是
717
731
  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}
732
+ .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
733
  .balance-footer__timeline-meta-item{flex:none;white-space:nowrap}
720
734
  /* 「今日 ¥x」独占第一行(flex-basis:100%)并居中,与下面「空闲 剩 3h57m」那一行左对齐成组。
721
735
  inline-flex 是为了把「今日」/「¥」/ 滚动数字排成一行(基线对齐,小数点不会上下错)。
@@ -816,7 +830,7 @@ window.__ModuleLoader__.load({
816
830
  ⚠️ 这里不再用 keyframes:5px 的假位移看着仍是"跳一下再归位",
817
831
  用户 2026-10-31 明确要「滑动过去」。真正的滑动由 JS 量出实际位移再补 ——
818
832
  见 usePrePaintEffect 里给 label 写 style 的那段(transition 由它临时加上)。 */
819
- .balance-footer__today-label{display:inline-block}
833
+ .balance-footer__today-label{display:inline-block;font-weight:500}
820
834
  /* ¥ 与数字之间的呼吸:¥ 是宽字符,紧贴数字会显得糊在一起
821
835
  (2026-10-31 用户指出「数字是不是太靠近¥了」)。2px 在 11px 字号下刚刚好,
822
836
  再多就会被读成两个独立的词。 */
@@ -918,8 +932,17 @@ window.__ModuleLoader__.load({
918
932
  会撑到内容高度,overflow 永远不触发),再配 overflow-y:auto。 */
919
933
  .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
934
  .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)}
935
+ .balance-panel-page__title{margin:0;font-size:18px;line-height:26px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8)}
936
+ .balance-panel-page__desc{margin:0;font-size:13px;line-height:20px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
937
+ /* 余额读取失败:原来是一行红字,在侧栏底部显得很单薄,也不占位、
938
+ 余额胶囊该在的位置空着。现在复用 .balance-footer__value 的盒子(min-width / 圆角 / 居中 /
939
+ 盒模型全部继承),只换配色;尺寸单独钉死,保证与正常余额胶囊同高、不会把整块顶一下。
940
+ 正常胶囊:font-size:16px + line-height:1 + padding:7px 上下 = 30px 高。
941
+ 错误文案 6 个字按 16px 排会到 124px 宽,所以字号降到 13px、用 height 把高度锁回 30px。 */
942
+ .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}
943
+ .balance-footer__value--error:hover{transform:none;background:rgba(229,72,77,.15)}
944
+ /* 精简竖排态:基座被覆盖成 90px / 6-11 padding / 13px 字,这里等比跟上并保持同一高度 */
945
+ .balance-footer--compact.balance-footer--stacked .balance-footer__value--error{min-width:0;height:26px;padding:0 9px;font-size:11px}
923
946
  .balance-footer__error{color:var(--dsw-alias-state-error-primary)}
924
947
  .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
948
  .balance-topup:hover{text-decoration:underline}
@@ -932,7 +955,7 @@ window.__ModuleLoader__.load({
932
955
  默认是 superellipse(1.5)——不覆盖的话 border-radius:50% 会被渲染成"圆角方形"
933
956
  (squircle),根本不是圆(2026-09-28 用户反馈「很奇怪啊」,截图是 squircle)。
934
957
  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)}
958
+ .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
959
  .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
960
  .balance-fab:active{transform:scale(.95)}
938
961
  /* 金额偏长时(如 ¥1234.56)自动收一号字,免得 60px 圆里挤爆 */
@@ -956,7 +979,7 @@ window.__ModuleLoader__.load({
956
979
  圆钮的 inset 0 1px 0 #fff 26% 与 inset 0 -1px 1px #fff 8% 在 60px 圆里
957
980
  刚好读成玻璃高光,但拉成 81×148 的矩形后,两条 inset 会在内侧连成一整圈亮边,
958
981
  再叠上 border,看起来就是"内外两层描边"。矩形只要一条淡边 + 外投影。 */
959
- border:1px solid color-mix(in srgb,var(--dsw-alias-label-primary) 9%,transparent);
982
+ border:1px solid color-mix(in srgb,var(--dsw-alias-label-primary,#e6e6e8) 9%,transparent);
960
983
  box-shadow:0 4px 16px rgba(0,0,0,.24);
961
984
  }
962
985
  /* ⚠️ hover 也必须重写 box-shadow 和 border-color:.balance-fab:hover 里还有一整套
@@ -964,7 +987,7 @@ window.__ModuleLoader__.load({
964
987
  否则鼠标一移上去那圈内亮边又回来了。 */
965
988
  .balance-fab--rect:hover{
966
989
  transform:scale(1.03);
967
- border-color:color-mix(in srgb,var(--dsw-alias-label-primary) 14%,transparent);
990
+ border-color:color-mix(in srgb,var(--dsw-alias-label-primary,#e6e6e8) 14%,transparent);
968
991
  box-shadow:0 6px 20px rgba(0,0,0,.3);
969
992
  }
970
993
  .balance-fab--rect:active{transform:scale(.97)}
@@ -1038,9 +1061,9 @@ window.__ModuleLoader__.load({
1038
1061
  圆角是 --dsw-radius-sm(小圆角矩形),不是 999px 胶囊;也不要加
1039
1062
  corner-shape:round —— 原生 hover/展开态就是这个小圆角背景,写成胶囊对不上。 */
1040
1063
  .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)}
1064
+ .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
1065
  .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)}
1066
+ .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
1067
  .balance-usage-label{text-overflow:ellipsis;min-width:0;overflow:hidden}
1045
1068
  /* 金额那一段单独成类。**宽度必须恒定**:这段一变宽变窄,composer dock 那一行就重排,
1046
1069
  输入框会被顶得上下跳(2026-10-30 用户实测反馈)。
@@ -1062,7 +1085,7 @@ window.__ModuleLoader__.load({
1062
1085
  /* 智能体团队(Agent Teams)小圆片:只在 roster 里有人时才挂。
1063
1086
  高度 16px(行高 22px,纵向放得下、不会把整行撑高),字号 11px 跟随 DSH 的次要信息档;
1064
1087
  背景用很低的白(.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}
1088
+ .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
1089
  /* ═══ 右下角小浮窗(2026-11-02 第十轮起,第十一轮按用户三轮反馈定形)═════
1067
1090
  用户第一轮原话:「把这段改成小浮窗显示在对话界面右下角 然后分列显示 上面显示本会话消耗文本
1068
1091
  下一列为今日消耗 并保留所有动画 因为当前因为需要预留加载胶囊 导致数字离得太远了」。
@@ -1097,7 +1120,7 @@ window.__ModuleLoader__.load({
1097
1120
  max-width:none;
1098
1121
  background:var(--dsw-specific-sidebar-fill,rgba(27,27,28,.92));
1099
1122
  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);
1123
+ color:var(--dsw-alias-label-tertiary,#9a9a9e);
1101
1124
  -webkit-backdrop-filter:blur(10px) saturate(1.15);backdrop-filter:blur(10px) saturate(1.15);
1102
1125
  /* ⚠️ 内联写 transition 会把整条覆盖掉(transition 不支持合并),所以淡出用的
1103
1126
  opacity 过渡只能加在这条 CSS 里(2026-11-03 用户:「隐藏的时候淡出」)。 */
@@ -1129,7 +1152,7 @@ window.__ModuleLoader__.load({
1129
1152
  .balance-float--enter{animation:balance-float-emerge .28s cubic-bezier(.2,.85,.3,1) both;transform-origin:50% 100%}
1130
1153
  /* 第一行:说明文字。两行竖排后**不许再定宽**(定宽就会在窄金额时把卡片撑成两边留白),
1131
1154
  只保留不换行 + 超长省略 —— 卡片的宽度由两行里更宽的那一行决定。 */
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)}
1155
+ .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
1156
  /* 第二行:团队圆片 + 金额。圆片与金额之间 6px,整行在卡片里居中。
1134
1157
  ⚠️ **高度必须钉死成 1lh**(2026-11-02 第二十一轮:「切到正在运行的对话,加载完之后小浮窗轻微上移几格」)。
1135
1158
  卡片是 bottom 钉在输入卡片底边上的,**任何一行变高都会把整张卡片往上顶**:
@@ -1157,7 +1180,7 @@ window.__ModuleLoader__.load({
1157
1180
  ⚠️ 水平居中靠 flex(justify-content:center),不许用 translateX 硬拽。 */
1158
1181
  .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
1182
  .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)}
1183
+ .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
1184
  /* 金额那一格:预留 **9ch** 兜住等待态那颗加载胶囊(2026-11-02 用户:「是不是可以让加载胶囊长一点了」)。
1162
1185
  实测 14px 字下 1ch ≈ 8.21px → 6.4ch 只有 52.5px,在 101px 宽的卡片里显得又短又胖;
1163
1186
  9ch ≈ 73.9px,正好和上面那行「本会话消耗估算」(77px)等宽对齐 ——
@@ -1436,16 +1459,16 @@ window.__ModuleLoader__.load({
1436
1459
  .balance-usage-approx{position:relative;top:-.12em;margin-right:.12em}
1437
1460
  @keyframes balance-calc-reveal{from{clip-path:inset(0 100% 0 0)}to{clip-path:inset(0 -4px 0 0)}}
1438
1461
  /* ── 消耗明细浮层:规格照抄 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}
1462
+ .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}
1463
+ .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
1464
  .balance-usage-panel__title--second{margin-top:16px}
1442
1465
  .balance-usage-panel__rule{border-top:.5px solid var(--dsw-alias-border-l2);margin-bottom:10px}
1443
1466
  .balance-usage-panel__value{font-variant-numeric:tabular-nums}
1444
1467
  .balance-usage-panel__label{display:inline-flex;align-items:center;gap:6px;min-width:0}
1445
1468
  .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)}
1469
+ .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
1470
  .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}
1471
+ .balance-usage-panel__details dd{color:var(--dsw-alias-label-secondary,#b9b9bd);font-variant-numeric:tabular-nums;text-align:right}
1449
1472
  /* ── 跨会话统计浮层(余额元素的子级,向右/向上展开) ── */
1450
1473
  .balance-stats-anchor{position:relative;display:flex;min-width:0;overflow:visible}
1451
1474
  .balance-stats-anchor--wide{width:100%}
@@ -1477,7 +1500,7 @@ window.__ModuleLoader__.load({
1477
1500
  .balance-stats-anchor--compact .balance-fab{position:fixed}
1478
1501
  .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
1502
  .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))}
1503
+ .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
1504
  /* 滚动条对齐 DSH 设置窗口:宽度 12px,滑块靠 transparent 边框内缩到 4px(永远不贴 24px 圆角),
1482
1505
  轨道上下各留 10px,颜色沿用 DSH 自己的 --dsh-scrollbar-thumb 变量。 */
1483
1506
  .balance-stats-panel::-webkit-scrollbar{width:12px;height:12px}
@@ -1493,8 +1516,8 @@ window.__ModuleLoader__.load({
1493
1516
  .balance-stats-header{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:22px 14px 12px 24px}
1494
1517
  .balance-stats-body{display:flex;flex-direction:column;min-width:0;padding:0 24px}
1495
1518
  .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}
1519
+ .balance-stats-subtitle{margin:4px 0 0;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:12px}
1520
+ .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
1521
  .balance-stats-close:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.12))}
1499
1522
  .balance-stats-error{padding:12px;border-radius:10px;color:var(--dsw-alias-state-error-primary,#e5484d);background:rgba(229,72,77,.10)}
1500
1523
  /* 加载态:一条**实时推进**的进度条 + 已用时(2026-11-24 用户:「加载时添加一个实时的加载条」)。
@@ -1509,14 +1532,16 @@ window.__ModuleLoader__.load({
1509
1532
  底环是暗的完整圆,上面一段亮弧自己转,同时弧长从 20 → 62 → 20 呼吸,
1510
1533
  看起来是"一圈在跑"而不是"一个缺口在转"。
1511
1534
  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)}
1535
+ .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
1536
  .balance-stats-spinner{display:block;width:30px;height:30px;animation:balance-stats-spin .95s linear infinite}
1514
1537
  .balance-stats-spinner__track{fill:none;stroke:var(--dsw-alias-border-l2,rgba(127,127,127,.22));stroke-width:2.5}
1515
1538
  .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
1539
  @keyframes balance-stats-spin{to{transform:rotate(360deg)}}
1517
1540
  @keyframes balance-stats-arc{0%{stroke-dasharray:20 62}50%{stroke-dasharray:62 20}100%{stroke-dasharray:20 62}}
1518
1541
  .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}
1542
+ .balance-stats-progress__elapsed{color:var(--dsw-alias-label-tertiary,var(--dsw-alias-label-secondary,#b9b9bd));font-size:11px;line-height:1}
1543
+ /* 左:概览卡 2×2;右:热力图(auto,宽度由格子数决定)。热力图一直在右上角,
1544
+ 2026-11-26 用户:「之前热力图不是在右上角的吗 要这么大干什么」。 */
1520
1545
  .balance-stats-top{display:grid;grid-template-columns:minmax(0,1fr) auto;gap:8px;margin-bottom:8px}
1521
1546
  .balance-stats-grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:8px}
1522
1547
  /* 分组数为奇数时(「按模型」「时段拆分」条件渲染可能缺席),最后一个横跨整行,避免半空行 */
@@ -1525,13 +1550,13 @@ window.__ModuleLoader__.load({
1525
1550
  .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
1551
  .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
1552
  @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}
1553
+ .balance-stats-card__label{display:block;margin-bottom:6px;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:12px}
1554
+ .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
1555
  .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
1556
  .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%}
1557
+ .balance-stats-legend{display:flex;align-items:center;gap:4px;color:var(--dsw-alias-label-secondary,#b9b9bd);font-size:11px;font-weight:400}
1558
+ .balance-heatmap-wrap{display:flex;justify-content:center;min-width:0;overflow:hidden;padding:4px 2px 8px}
1559
+ .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
1560
  .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
1561
  .balance-heatmap-cell[aria-label]{cursor:default}
1537
1562
  .balance-heatmap-cell[aria-label]:hover{transform:scale(1.18);filter:brightness(1.14)}
@@ -1545,27 +1570,363 @@ window.__ModuleLoader__.load({
1545
1570
  .balance-heatmap-cell--3{background:rgba(34,197,94,.68)}
1546
1571
  .balance-heatmap-cell--4{background:rgba(22,163,74,.95)}
1547
1572
  .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}
1573
+ .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
1574
  /* 底部操作区:官方用量 / 去充值走原生平台视口(带平台凭据、无需网页登录);
1550
1575
  更多账号信息对齐 DSH 原生账号卡片,开平台首页(外部窗口,原生视口只认 usage / top-up) */
1551
1576
  .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))}
1577
+ .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
1578
  .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)}
1579
+ .balance-stats-link--primary{border-color:transparent;color:#fff;background:#4d6bfe;font-weight:600}
1555
1580
  /* ⚠️ hover 不要跟随 --dsw-alias-state-business-primary-hover(2026-10-31:
1556
1581
  「按钮颜色是不是搞反了 怎么鼠标放上去这么显眼」)。DSH 深色主题里那个变量是**提亮**的,
1557
1582
  hover 反而比静止更抢眼,读起来像"反了"。这里固定往黑里兑 12% 做加深,
1558
1583
  不依赖主题的 hover 语义;base 本身仍走主题变量,换主题整体色相跟着变。 */
1559
- .balance-stats-link--primary:hover{background:color-mix(in srgb,var(--dsw-alias-state-business-primary,#4d6bfe) 88%,#000)}
1584
+ .balance-stats-link--primary:hover{background:#3f5bef;color:#fff}
1560
1585
  .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}
1586
+ .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}
1587
+ .balance-stats-group__hint{color:var(--dsw-alias-label-secondary,#b9b9bd);font-weight:400;font-variant-numeric:tabular-nums}
1563
1588
  .balance-stats-row{display:flex;align-items:baseline;justify-content:space-between;gap:12px;min-width:0;padding:6px 0;font-size:12px}
1564
1589
  .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}
1590
+ .balance-stats-row__name{min-width:0;overflow:hidden;color:var(--dsw-alias-label-primary,#e6e6e8);text-overflow:ellipsis;white-space:nowrap}
1591
+ .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
1592
  @media(max-width:900px){.balance-stats-top{grid-template-columns:minmax(0,1fr)}.balance-stats-grid{grid-template-columns:minmax(0,1fr)}}
1568
1593
  @media(max-width:760px){.balance-stats-layer{padding:10px}}
1594
+ /* ── 时段条 / 今日消耗 的「上滑小窗」(2026-11-26)─────────────────────────
1595
+ 两个独立 popover,各自锚在点它的那一块上方:
1596
+ · .balance-footer__today → 今日各对话花了多少
1597
+ · .balance-footer__timeline* → 今日余额时间线
1598
+ 原来是整行一个热区(单击=统计面板),现在按 closest() 分流,见 rowInteractions。 */
1599
+ /* 可交互区域:hover 时轻微放大 + 泛光(2026-11-26 用户:「高亮有问题呢 不要高亮了
1600
+ 鼠标放上去的整体放大一点 然后泛光」)。原来那套蓝色描边胶囊(::after 圈 + :has 双向
1601
+ 联动 + 打开时常亮)整段撤掉,那圈蓝框就是这次说的「高亮」。
1602
+ · 今日 ¥x → .balance-footer__timeline-meta-item--today → 开「今日消耗明细」
1603
+ · 空闲 剩 3h57m → .balance-footer__timeline-meta-group → 开「余额时间线」
1604
+ · 刻度条 → .balance-footer__timeline-track → 开「余额时间线」 */
1605
+ /* 文字行和刻度条是两种东西,hover 反馈也要分开给(2026-11-26 用户:
1606
+ 「文字的话 就文字高亮 不要显示胶囊圈起来 很奇怪」)。
1607
+ ⚠️ 文字上绝不能加 border-radius + box-shadow —— 那会沿文字外框画出一圈胶囊光晕,
1608
+ 看着像给「空闲 剩 3h57m」套了个框。 */
1609
+ .balance-footer__timeline-meta-item--today,
1610
+ .balance-footer__timeline-meta-group{transition:color .16s ease}
1611
+ /* ⚠️ hover 时 meta 行要临时放开裁剪:刻度条 scale(1.04) 会顶出 meta 的 overflow:hidden
1612
+ (meta-group 在 meta 里面)。非 hover 时仍然 hidden —— 那才是「不压到金额上」要防的。 */
1613
+ .balance-footer__timeline:hover .balance-footer__timeline-meta,
1614
+ .balance-footer__timeline:has(.balance-footer__today--active) .balance-footer__timeline-meta,
1615
+ .balance-footer__timeline:has(.balance-footer__timeline--active) .balance-footer__timeline-meta{overflow:visible}
1616
+ /* 不放大,改成**整块一个胶囊底**(2026-11-27 用户:「算了 不要放大了 鼠标放上去显示一个整体的胶囊吧」)。
1617
+ 「今日 ¥x」「空闲 剩 8h23m」「时段条」三行现在开的是同一个面板,所以它们是一个入口,
1618
+ 鼠标落在任意一块、或面板开着时,同一层圆角底把三行一起罩住。
1619
+ ⚠️ 用 ::before 绝对定位画底,不加 padding —— 加内边距会改变这块的实际尺寸,
1620
+ 而它是 flex 里按剩余宽度伸缩的,一改就把上面的金额行挤动。
1621
+ ⚠️ z-index:-1 + isolation:isolate:底色落在内容之下、卡片之上,
1622
+ 不会盖住文字,也不会穿透到侧栏背景后面。
1623
+ ⚠️ 只有底色,没有 box-shadow 光晕 —— 沿文字外框画光会自动成一圈胶囊圈,
1624
+ 那条 2026-11-26 已经否定过一次。 */
1625
+ .balance-footer__timeline{isolation:isolate}
1626
+ .balance-footer__timeline::before{
1627
+ content:"";position:absolute;inset:-3px -4px;z-index:-1;
1628
+ border-radius:11px;background:transparent;pointer-events:none;
1629
+ transition:background-color .16s ease}
1630
+ .balance-footer__timeline:hover::before,
1631
+ .balance-footer__timeline:has(.balance-footer__today--active)::before,
1632
+ .balance-footer__timeline:has(.balance-footer__timeline--active)::before{
1633
+ background:rgba(127,127,127,.13)}
1634
+ /* 可点的光标提示 */
1635
+ .balance-footer__timeline-meta-item--today,
1636
+ .balance-footer__timeline-meta-group{cursor:pointer;outline:none}
1637
+ .balance-footer__timeline-meta-item--today:focus,
1638
+ .balance-footer__timeline-meta-item--today:focus-visible{cursor:pointer;outline:none}
1639
+ @media(prefers-reduced-motion:reduce){
1640
+ .balance-footer__timeline-meta-item--today,
1641
+ .balance-footer__timeline-meta-group{transition:none}
1642
+ .balance-footer__timeline-track{transition:none}
1643
+ .balance-footer__timeline::before{transition:none}}
1644
+ .balance-pop{box-sizing:border-box;position:fixed;z-index:10050;display:flex;flex-direction:column;
1645
+ width:min(330px,calc(100vw - 20px));
1646
+ /* 高度上限放宽(2026-11-27 用户:「可以长很多 太短显示不全」):原来是 60vh/420px,
1647
+ 时段表带图 + 明细两层,会话一多就被裁在卡里、只剩滚动条。现在放到 80vh/640px,
1648
+ 大多数情况一屏能看全;真超出还是走 body 内滚动,不会顶出视口。 */
1649
+ max-height:min(80vh,640px);overflow:hidden;padding:0;
1650
+ border:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));border-radius:12px;
1651
+ background:var(--dsw-alias-bg-layer-1,#232324);box-shadow:0 14px 36px rgba(0,0,0,.45);
1652
+ animation:balance-pop-in .17s cubic-bezier(.22,.72,.28,1) both}
1653
+ @keyframes balance-pop-in{from{opacity:0;transform:translateY(9px) scale(.975)}to{opacity:1;transform:none}}
1654
+ @keyframes balance-pop-out{from{opacity:1;transform:none}to{opacity:0;transform:translateY(6px) scale(.985)}}
1655
+ .balance-pop--closing{pointer-events:none;animation:balance-pop-out .13s ease-in both}
1656
+ /* 小三角指回被点的那一块;左右位置由 JS 写进 --balance-pop-arrow */
1657
+ .balance-pop::after{content:"";position:absolute;left:var(--balance-pop-arrow,50%);bottom:-6px;width:11px;height:11px;
1658
+ margin-left:-5.5px;background:inherit;border-right:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));
1659
+ border-bottom:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));transform:rotate(45deg)}
1660
+ /* 翻到 anchor 下方时三角翻个面(改上下两条边,比旋转 180° 干净) */
1661
+ .balance-pop--below::after{bottom:auto;top:-6px;border-right:0;border-bottom:0;
1662
+ border-left:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22));
1663
+ border-top:1px solid var(--dsw-alias-border-l2,rgba(127,127,127,.22))}
1664
+ .balance-pop__head{display:flex;flex:none;align-items:center;justify-content:space-between;gap:10px;
1665
+ padding:11px 12px 8px 14px}
1666
+ .balance-pop__title{margin:0;font-size:12.5px;font-weight:600;line-height:16px;color:var(--dsw-alias-label-primary,#e6e6e8)}
1667
+ /* 副标题提亮一档:最新一行金额是这个浮窗最常看的数字,
1668
+ 原来和「3 个时段有消耗」同一个灰度,看不出主次。 */
1669
+ .balance-pop__sub{margin:2px 0 0;font-size:11.5px;line-height:15px;color:var(--dsw-alias-label-secondary,#b9b9bd);
1670
+ font-variant-numeric:tabular-nums}
1671
+ .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}
1672
+ /* 右上角控件容器:和关闭按钮平齐、靠右聚在一起 */
1673
+ .balance-pop__head-extra{flex:none;margin-left:auto;display:inline-flex;align-items:center}
1674
+ /* 尺寸放大一档(2026-11-27 用户:「太小了 改大一点」)。
1675
+ 22px 高 + 16×9 滑块在这张卡里看着像一个标点,
1676
+ 现在 26px 高 + 24×13 滑块,和右侧关闭按钮同高。 */
1677
+ .balance-pop__switch{flex:none;display:inline-flex;align-items:center;gap:6px;height:26px;padding:0 10px 0 9px;
1678
+ border:0;border-radius:999px;background:transparent;color:var(--dsw-alias-label-secondary,#b9b9bd);
1679
+ font-size:11.5px;line-height:1;cursor:pointer}
1680
+ /* 悬停底色也跟着走胶囊:方框配胶囊滑块看着就是两个形状拼在一起 */
1681
+ .balance-pop__switch:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
1682
+ /* 26×14 滑块 + 12px 圆点:上下各留 1px。之前 13px 高、圆点 10px、
1683
+ 上下各 1.5px,在小尺寸下抗锯齿会把下边抹得更重,看着就像圆点偏下
1684
+ (2026-11-27 用户:「白点怎么靠下」)。现在用整数像素对齐。 */
1685
+ .balance-pop__switch-dot{position:relative;flex:none;width:26px;height:14px;border-radius:999px;
1686
+ background:rgba(127,127,127,.4);transition:background .16s ease}
1687
+ .balance-pop__switch-dot::after{content:"";position:absolute;top:1px;left:1px;width:12px;height:12px;border-radius:50%;
1688
+ background:#fff;box-shadow:0 1px 2px rgba(0,0,0,.35);
1689
+ transition:transform .16s cubic-bezier(.4,0,.2,1)}
1690
+ .balance-pop__switch--on{color:var(--dsw-alias-label-primary,#e6e6e8)}
1691
+ .balance-pop__switch--on .balance-pop__switch-dot{background:var(--dsw-alias-state-success-primary,#22c55e)}
1692
+ .balance-pop__switch--on .balance-pop__switch-dot::after{transform:translateX(12px)}
1693
+ @media (prefers-reduced-motion:reduce){
1694
+ .balance-pop__switch-dot,.balance-pop__switch-dot::after{transition:none}
1695
+ }
1696
+ .balance-pop__close{flex:none;display:inline-flex;align-items:center;justify-content:center;width:22px;height:22px;
1697
+ padding:0;border:0;border-radius:6px;background:transparent;color:var(--dsw-alias-label-secondary,#b9b9bd);
1698
+ font-size:15px;line-height:1;cursor:pointer}
1699
+ .balance-pop__close:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.14))}
1700
+ /* 时间线浮窗单独加宽(2026-11-26 用户:「左右拉长一点」)。330 是明细列表的宽度,别一起改。 */
1701
+ .balance-pop--wide{width:min(498px,calc(100vw - 20px))}
1702
+ /* 图 + 明细合并后内容明显变高,会话一多会把卡片顶出视口 —— 限高并让 body 自己滚 */
1703
+ .balance-pop__body{flex:1 1 auto;min-height:0;max-height:min(60vh,460px);overflow-y:auto;padding:0 8px 8px}
1704
+ .balance-pop__body::-webkit-scrollbar{width:9px}
1705
+ .balance-pop__body::-webkit-scrollbar-thumb{border:3px solid transparent;background-clip:padding-box;
1706
+ border-radius:5px;background-color:rgba(127,127,127,.35)}
1707
+ /* 会话明细一行:名字(可省略)+ 金额 */
1708
+ .balance-pop__row{display:flex;align-items:baseline;gap:8px;min-width:0;padding:6px 6px;border-radius:7px;font-size:12px}
1709
+ .balance-pop__row:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.08))}
1710
+ /* 两列网格(2026-11-27 用户:「每行显示两个」):会话一格,组头 / 两条计费项整行。
1711
+ ⚠️ 一律用子选择器(大于号)限定**直接子元素** —— 组内缩进行(.balance-pop__row--nested)在
1712
+ .balance-pop__group-block 里面,不该被拉进两行式格子布局。 */
1713
+ .balance-pop__grid{display:grid;grid-template-columns:1fr 1fr;column-gap:10px;row-gap:1px;min-width:0}
1714
+ .balance-pop__grid > .balance-pop__group-block,
1715
+ .balance-pop__grid > .balance-pop__row--full{grid-column:1 / -1}
1716
+ /* 今天只有一条会话时独占整行,别留半格空白(--one 由 JSX 按 rows.length 挂) */
1717
+ .balance-pop__grid--one > .balance-pop__row{grid-column:1 / -1}
1718
+ /* 一格里的会话行:标题占满整格一行,token 与金额在第二行左右分列。
1719
+ ⚠️ 别退回「swatch + 标题 + token + 金额」四段横排:半宽只有 ~145px,
1720
+ token(46px) + 金额(52px) + 三段 gap 一占,标题只剩 ~25px,等于只剩一个省略号。
1721
+ 两行式下标题能拿到整格宽度,token 和金额各占第 2 行一头。 */
1722
+ .balance-pop__grid > .balance-pop__row:not(.balance-pop__row--full){
1723
+ display:grid;grid-template-columns:3px minmax(0,1fr) auto;grid-template-rows:auto auto;
1724
+ column-gap:6px;row-gap:1px;align-items:center;
1725
+ }
1726
+ .balance-pop__grid > .balance-pop__row:not(.balance-pop__row--full) > .balance-pop__swatch{grid-column:1;grid-row:1 / span 2;align-self:center}
1727
+ .balance-pop__grid > .balance-pop__row:not(.balance-pop__row--full) > .balance-pop__name{grid-column:2 / span 2;grid-row:1}
1728
+ .balance-pop__grid > .balance-pop__row:not(.balance-pop__row--full) > .balance-pop__meta{grid-column:2;grid-row:2;justify-self:start}
1729
+ .balance-pop__grid > .balance-pop__row:not(.balance-pop__row--full) > .balance-pop__amount{grid-column:3;grid-row:2;justify-self:end;min-width:0}
1730
+ /* 独占整行时回到原来的一行四段(半宽才需要两行),并且按单列压一档(见 --nested 那条) */
1731
+ .balance-pop__grid--one > .balance-pop__row:not(.balance-pop__row--full){
1732
+ display:flex;align-items:baseline;gap:8px;padding:3px 6px;font-size:11.5px}
1733
+ .balance-pop__name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
1734
+ color:var(--dsw-alias-label-primary,#e6e6e8)}
1735
+ .balance-pop__meta{flex:none;color:var(--dsw-alias-label-tertiary,#9a9a9e);font-size:10.5px;font-variant-numeric:tabular-nums}
1736
+ .balance-pop__amount{flex:none;min-width:62px;text-align:right;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8);
1737
+ font-variant-numeric:tabular-nums}
1738
+ /* 会话行前的小色条:按金额排序后给个视觉锚点 */
1739
+ .balance-pop__swatch{flex:none;width:3px;height:11px;border-radius:2px;background:rgba(77,107,254,.85)}
1740
+ /* 单列行的色块收一档(2026-11-27 用户:「左边的色块也要调整大小」):
1741
+ 单列行高从 26px 压到 20px(见下面那条 padding),色块按同一比例从 3×11 收到 3×8
1742
+ —— 占行高 40.7% → 39%,跟改前视觉一致。两列格子里的色块保持 3×11:
1743
+ 那格里行本来就是两行高,跟单列不是一个尺度。 */
1744
+ .balance-pop__row--nested > .balance-pop__swatch,
1745
+ .balance-pop__grid--one > .balance-pop__row:not(.balance-pop__row--full) > .balance-pop__swatch{
1746
+ width:3px;height:8px;border-radius:1.5px}
1747
+ .balance-pop__swatch--plugin{background:rgba(127,127,127,.55)}
1748
+ /* 父级分组栏(2026-11-27:「如果父级是一样的 添加一个展开和收起的栏」):
1749
+ 同一项目目录下有多个会话时,上面多一行组头,点它展开 / 收起组内的会话行。
1750
+ ⚠️ 组头用 div、不用 button:面板在 flex 列里,button 自带 UA 的
1751
+ font/padding/边框会把它顶成 30px 以上,还会把箭头挤歪。
1752
+ role/tabIndex 只是为了键盘可达,点击走 onClick。 */
1753
+ .balance-pop__group{display:flex;align-items:baseline;gap:6px;min-width:0;padding:5px 6px 4px;border-radius:7px;
1754
+ font-size:11.5px;line-height:16px;color:var(--dsw-alias-label-secondary,#b9b9bd);cursor:pointer;user-select:none}
1755
+ .balance-pop__group:hover{background:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.08))}
1756
+ /* 箭头用 CSS 三角画,不用 ▸ 字符:那个字符在很多字体里被渲染成一个点,
1757
+ 在高 DPI 下几乎看不见(预览图里就是个小方块)。 */
1758
+ .balance-pop__group-caret{flex:none;align-self:center;display:inline-flex;align-items:center;justify-content:center;
1759
+ width:10px;height:10px;color:var(--dsw-alias-label-tertiary,#9a9aa0);
1760
+ transition:transform .12s ease;transform-origin:50% 50%}
1761
+ .balance-pop__group-caret::before{content:"";display:block;width:0;height:0;
1762
+ border-left:4px solid currentColor;border-top:3.5px solid transparent;border-bottom:3.5px solid transparent}
1763
+ .balance-pop__group--open .balance-pop__group-caret{transform:rotate(90deg)}
1764
+ .balance-pop__group-name{flex:1 1 auto;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
1765
+ font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8)}
1766
+ .balance-pop__group-meta{flex:none;font-size:10.5px;font-variant-numeric:tabular-nums;
1767
+ color:var(--dsw-alias-label-tertiary,#9a9aa0)}
1768
+ /* 组内会话行缩进一档,视觉上挂到组头下面。
1769
+ 单列压一档(2026-11-27 用户:「如果是单列的话 每块小一点 左边的色块也要调整大小」):
1770
+ 两列格子是被半宽逼出来的紧凑排法,单列沿用同样的 padding 就变成一行一个、又高又稀 ——
1771
+ 行高 26px 降到 20px(padding 上下 6 → 3、字号 12 → 11.5),缩进仍是 19px。
1772
+ ⚠️ 别再往下压:padding 2px 时行高只剩 18.5px,两行会对成一坨(实测过)。 */
1773
+ .balance-pop__row--nested{padding:3px 6px 3px 19px;font-size:11.5px}
1774
+ /* 网页工具费那一行的色块:与同步费的蓝区分开 */
1775
+ .balance-pop__swatch--web{background:var(--dsw-alias-state-warning-primary,#d97706)}
1776
+ .balance-pop__empty{padding:18px 12px;text-align:center;font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1777
+ /* 时间线曲线 */
1778
+ /* 图与明细之间的分隔线(两个浮窗合并后的接缝) */
1779
+ .balance-pop__hr{height:.5px;margin:8px 0 6px;background:var(--dsw-alias-border-l1,rgba(127,127,127,.16))}
1780
+ /* 合并面板里那句「N 个会话 · 合计 …(会话 … + 同步 …)」,
1781
+ 用来解释累计与会话合计的差额,别让它贴着上一行图 */
1782
+ .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}
1783
+ .balance-pop__chart{position:relative;padding:2px 2px 0}
1784
+ .balance-pop__svg{display:block;width:100%;height:auto;overflow:visible}
1785
+ /* 图表要能接键盘(方向键逐分钟),所以挂了 tabIndex —— 于是浏览器给 SVG 画了一圈
1786
+ 焦点框,在深色卡片上是整整一道白边(2026-11-27 用户截图「怎么回事」)。
1787
+ 键盘用户另有可见反馈:胶囊本身会跟着动,不需要这圈 outline。 */
1788
+ .balance-pop__svg:focus,.balance-pop__svg:focus-visible{outline:none}
1789
+ /* 曲线语言(2026-11-26 用户给了参考图:绿线 + 虚分隔 + 右侧金额,
1790
+ 不要红绿色块带、不要图例)。 */
1791
+ .balance-pop__axis{font-size:9px;fill:var(--dsw-alias-label-tertiary,#9a9a9e);font-variant-numeric:tabular-nums}
1792
+ /* 纵轴金额刻度提亮(2026-11-27 用户:「顶部的刻度是不是太不明显了」)。
1793
+ 原来 9.5px + label-secondary,在深色色带上基本涂开;
1794
+ 现在提到 10.5px、primary 色、加一档字重,数字才读得出来。 */
1795
+ /* ⚠️ stroke-width 不能太粗:11px 字的笔画才 1px 宽,描边沿轮廓内外各扩一半,
1796
+ 3px 描边会把字形内部也填满 —— 整个「¥15」变成一块黑瘩瘩,
1797
+ 在深色背景上看上去就是「消失了」(2026-11-27 用户:「bug了 怎么消失了」)。
1798
+ 现在 2px:比原来的 2.4px 还细一点,但描边色从 .55 提到 .82,对比反而更强。 */
1799
+ .balance-pop__axis--value{fill:#ffffff;font-size:11px;font-weight:600;letter-spacing:.2px;
1800
+ paint-order:stroke;stroke:rgba(0,0,0,.82);stroke-width:2px;stroke-linejoin:round}
1801
+ /* 峰谷切换处的虚竖线(09:00 / 12:00 / 14:00 / 18:00) */
1802
+ /* 峰谷底色:高峰暖橙、空闲淡绿。只给 fill、不给 opacity ——
1803
+ 色带铺在面积图下面,opacity 会连曲线一起压暗。 */
1804
+
1805
+ .balance-pop__band--peak{fill:rgba(226,152,88,.105)}
1806
+ .balance-pop__band--offpeak{fill:rgba(46,168,118,.075)}
1807
+ .balance-pop__grid{stroke:rgba(255,255,255,.22);stroke-width:1}
1808
+ /* 横向金额刻度线:比竖向分界线淡一档,免得和峰谷分界抢注意力 */
1809
+ .balance-pop__grid-h{stroke:rgba(255,255,255,.09);stroke-width:1;stroke-dasharray:2 4}
1810
+ /* 曲线下方极淡的绿雾,别做成实心块 */
1811
+ .balance-pop__area{fill:rgba(34,197,94,.10)}
1812
+ /* ── 打开时**不做**入场动画(2026-11-27 用户:「打开的时候不要动画了」)──
1813
+ 要的是 y 轴档位变化时的缩放:¥1 → ¥2 → ¥5,整张图从旧高度展开到新高度,
1814
+ 看的是"刻度换档"这个动作,不是"窗口弹出来"。
1815
+ 做法:金额上界变了就给绘图组换 key 重挂,并从旧比例 scaleY 展开到 1。
1816
+ --balance-zfrom 由上一档 / 这一档算出来(¥1→¥2 就是 .5,¥2→¥5 是 .4)。 */
1817
+ /* y 轴数字换档淡入:位置直接到位(文字不能 scaleY,会变形),只淡入。 */
1818
+ /* 换档时数字从上方滚下来(而不是干巴巴淡入)。
1819
+ 用 both 收尾在 transform:none:常驻节点留下 transform 会让小字号发虚。
1820
+ 数值本身不变档位也不换 key,只在 targetMaxY 变时重挂一次。 */
1821
+ @media (prefers-reduced-motion:reduce){
1822
+ .balance-pop__tip{transition:none}
1823
+ }
1824
+ @keyframes balance-pop-ylabelroll{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:none}}
1825
+ /* ⚠️ 动画**不能**写在基础类上。写在上面等于「每次节点挂载都自动播一遍」,
1826
+ 而 y 轴数字每次打开浮窗都是新挂载 → 一打开就滚一下
1827
+ (2026-11-27 用户:「打开浮窗的时候 这个数字为什么也会动 这个数字的动画
1828
+ 只在缩放的时候有」)。现在只有档位真的变了才挂 --anim。 */
1829
+ .balance-pop__axis--value{animation:none}
1830
+ .balance-pop__axis--value--anim{animation:balance-pop-ylabelroll .34s cubic-bezier(.33,0,.2,1) both}
1831
+ @media (prefers-reduced-motion:reduce){
1832
+ .balance-pop__axis--value--anim{animation:none}
1833
+ }
1834
+ /* 换档不做 transform:会把描边、圆点一起拉变形。
1835
+ 改成逐帧插值纵轴上限(见 animMaxY):坐标平滑变化、形状不变
1836
+ (2026-11-27 用户:「我说的压只是效果 不是真的东西都变形了」)。 */
1837
+ @media (prefers-reduced-motion:reduce){
1838
+ .balance-pop__plot{animation:none}
1839
+ }
1840
+ .balance-pop__line{fill:none;stroke:var(--dsw-alias-state-success-primary,#22c55e);stroke-width:1.8;
1841
+ stroke-linejoin:round;stroke-linecap:round}
1842
+ /* 当前时刻:白竖线 + 绿点 */
1843
+ /* 悬停:一条细竖线 + 一个白点,跟着鼠标走 */
1844
+ .balance-pop__hover-line{stroke:rgba(255,255,255,.42);stroke-width:1;stroke-dasharray:2 2;pointer-events:none}
1845
+ /* 5 分钟采样点:线色的低调版本(不用 opacity —— 色带那边踩过,opacity 会连带影响兄弟节点观感) */
1846
+ .balance-pop__hover-dot{fill:#fff;stroke:var(--dsw-alias-bg-layer-1,#232324);stroke-width:1.6;pointer-events:none}
1847
+ /* 悬停提示:绝对定位在图表容器里,translateX(-50%) 居中,两端由 JS 夹回来 */
1848
+ /* 两行(2026-11-26 用户:「这个第二行显示」):上行累计、下行本小时。
1849
+ 两行都做 space-between,金额那一列自然对齐;min-width 让短的那行不至于把数字拉回去。 */
1850
+ .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;
1851
+ /* 宽度真正自适应内容(原来 128px 下限拿掉,短内容也能收紧) */
1852
+ width:max-content;
1853
+ color:var(--dsw-alias-label-primary,#e6e6e8);
1854
+ /* ⚠️ transition-property 必须**常驻**,只让 duration 走变量。
1855
+ 之前是 inline 整串 transition 在 none 和长串之间切换,同一帧里
1856
+ transition-property 变了、left 也变了,浏览器经常**不启动过渡** ——
1857
+ 表现就是「没动画」(2026-11-27 用户:「没动画啊 你加在哪了」)。
1858
+ 现在 property 不动、时长由 --tip-dur 控制,跟手写 0ms 即可。 */
1859
+ /* 宽度不做过渡(2026-11-27 用户:「就自适应长短吧 不要动画了」)。
1860
+ 之前尝试过 interpolate-size 与 FLIP,前者在本机不生效、后者会与
1861
+ 「-100%」随宽度变化叠加成中途抽动,已全部撤掉。
1862
+ 位秶过渡照旧:跟手 0ms,归位按距离。 */
1863
+ transition-property:left,top,transform;
1864
+ transition-duration:var(--tip-dur,0ms);
1865
+ transition-timing-function:cubic-bezier(.4,0,.2,1)}
1866
+ .balance-pop__tip-row{display:flex;align-items:center;justify-content:space-between;gap:10px}
1867
+ .balance-pop__tip-left{flex:none;display:inline-flex;align-items:baseline;gap:5px}
1868
+ .balance-pop__tip-tag{flex:none;font-size:10px;color:var(--dsw-alias-label-tertiary,#9a9aa0)}
1869
+ .balance-pop__tip-time{color:var(--dsw-alias-label-tertiary,#9a9aa0);font-variant-numeric:tabular-nums}
1870
+ .balance-pop__tip-cost{font-variant-numeric:tabular-nums;font-weight:600}
1871
+ /* 第三格:鼠标所在那个小时的消耗合计(2026-11-26 用户:「黑胶囊里面加一个当前小时的总消耗」)。
1872
+ 三级色 + 更细的分隔,别和左边的累计抢注意力。 */
1873
+ .balance-pop__tip-hour{color:var(--dsw-alias-label-tertiary,#9a9aa0);font-weight:400}
1874
+ .balance-pop__tip-hourcost{font-variant-numeric:tabular-nums;font-weight:600;color:var(--dsw-alias-label-secondary,#c9c9cd)}
1875
+ /* 还没到的时段:金额位换成「暂未产生消耗」。
1876
+ 弱化到 tertiary 且不加粗 —— 它是一句说明,不是一笔钱(2026-11-26 用户:
1877
+ 「鼠标移到没到的时间点上显示 0 暂未产生消耗」)。
1878
+ white-space 已经是 nowrap,这里只用字号压一点点,免得把胶囊撑太宽。 */
1879
+ /* ⚠️ 字号必须和正常态一致(都 10.5px)。原来 pending 写了 10px,而
1880
+ 归位瞬间第二行从「暂未产生消耗」切回「¥x.xx」,行高从 15.5 变回 16.3,
1881
+ 两行相加胶囊矮/高 1.5px —— 看上去就是「自动归位时窗口高度闪一下」
1882
+ (2026-11-27 用户)。要缩小字就整体缩,不能只缩一种状态。 */
1883
+ .balance-pop__tip-hourcost--pending{font-weight:400;color:var(--dsw-alias-label-tertiary,#9a9aa0)}
1884
+ /* 位数变化时「¥ 被顶出去」(2026-11-26 用户:「我的意思是数字给¥顶到左边 有动画
1885
+ 不是这种整体滑动」)。
1886
+ ⚠️ 金额列是右对齐的,所以位数一变,**右缘固定、左缘(¥)瞬间挪位**——
1887
+ 要平滑的正是这个左缘。整体 translateX 做不到(右缘会跟着抖),
1888
+ 得用 scaleX 并且把原点钉在右缘:压缩态的左缘停在旧位置,展开到 1 就是新位置。
1889
+ ⚠️ 动画里**绝对不能有 opacity** —— 之前 from 带 opacity:.35,数字先变淡再变实,
1890
+ 看着就是闪(用户:「变的时候 不要闪啊 为什么数字会闪啊」)。全程不透明。
1891
+ 触发条件仍然是「整数位数变化」(见 JSX key 里的 indexOf(".")),同位数内静默换值。 */
1892
+ .balance-pop__tip-cost,
1893
+ .balance-pop__tip-hourcost{display:inline-block;transform-origin:right center;animation:balance-pop-tip-push .16s cubic-bezier(.22,.72,.28,1) both}
1894
+ @keyframes balance-pop-tip-push{from{transform:scaleX(.9)}to{transform:scaleX(1)}}
1895
+ @media(prefers-reduced-motion:reduce){.balance-pop__tip-cost,.balance-pop__tip-hourcost{animation:none}}
1896
+ /* 面板行的悬停提示(2026-11-27:「我说的小浮窗是鼠标悬停时显示的码」)。
1897
+ ⚠️ 这三处原来挂的是**原生 title** → 灰底方框、裸 UUID、配色/圆角/层级都不归主题管
1898
+ (同日用户:「这个小浮窗的样式不对」)。当时把 title 全删了,结果**功能一起没了**
1899
+ (用户:「这个小浮窗直接不显示了」)—— 删样式不等于删功能,正确解法是自绘。
1900
+ 固定定位 + portal 到 body:面板本身 overflow:hidden,贴着行下方渲染会被裁掉。
1901
+ z-index 必须**高于 .balance-pop 的 10050**,否则被面板压住。 */
1902
+ .balance-pop__code-tip{box-sizing:border-box;position:fixed;z-index:10060;
1903
+ max-width:min(340px,calc(100vw - 24px));padding:5px 9px;
1904
+ border:1px solid var(--dsw-alias-border-l2,#45454d);border-radius:6px;
1905
+ background:var(--dsw-alias-bg-module-platform,#27272b);
1906
+ box-shadow:0 6px 18px rgba(0,0,0,.28);
1907
+ color:var(--dsw-alias-label-primary,#f4f4f5);
1908
+ font-size:11px;line-height:1.45;white-space:normal;
1909
+ pointer-events:none;animation:balance-heatmap-tooltip-in .12s ease-out both}
1910
+ .balance-pop__code-tip--above{transform:translateY(-100%)}
1911
+ .balance-pop__code-tip-title{display:block;font-weight:500;overflow:hidden;
1912
+ text-overflow:ellipsis;white-space:nowrap}
1913
+ .balance-pop__code-tip-sub{display:block;margin-top:2px;font-size:10.5px;
1914
+ color:var(--dsw-alias-label-tertiary,#9a9aa0);font-variant-numeric:tabular-nums;
1915
+ word-break:break-all}
1916
+ /* 当前时刻的白条:两层 drop-shadow 做泛光(近处锐、远处散)。
1917
+ 2026-11-26 用户:「白条可以添加泛光效果」。 */
1918
+ .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))}
1919
+ .balance-pop__dot{fill:var(--dsw-alias-state-success-primary,#22c55e);
1920
+ stroke:var(--dsw-alias-bg-layer-1,#232324);stroke-width:1.4}
1921
+ /* 此刻绿点的外圈:空心 + **泛光**(2026-11-27 用户:「泛光的」)。
1922
+ 写法照「此刻白线」那条来:两层 drop-shadow,一层贴边描轮廓、一层大半径铺光晕,
1923
+ 才会看着像「亮着」而不是一条灰圈。 */
1924
+ /* 白色泛光环(2026-11-27 用户:「光圈改成白色」)。和「此刻白线」同色系,
1925
+ 绿点本身已经是绿的,圈再绿就分不出层次。 */
1926
+ .balance-pop__dot-ring{fill:none;stroke:rgba(255,255,255,.9);
1927
+ stroke-width:1.15;stroke-opacity:.95;pointer-events:none;
1928
+ filter:drop-shadow(0 0 2.5px rgba(255,255,255,.75)) drop-shadow(0 0 7px rgba(255,255,255,.34))}
1929
+ @media(prefers-reduced-motion:reduce){.balance-pop,.balance-pop--closing{animation:none}}
1569
1930
  @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
1931
  /* ── 展开态底部一行:[设置齿轮][余额胶囊],余额在设置右边 ──
1571
1932
  全部使用稳定锚点,不依赖 CSS Modules hash 类名(DSH 升级后仍有效):
@@ -1590,18 +1951,27 @@ window.__ModuleLoader__.load({
1590
1951
  变量缺失时仍然可读,不会变成透明文字。开关/按钮的真圆角要显式 corner-shape:round,
1591
1952
  否则会被 DSH 主题的全局 superellipse 画成方圆角。 */
1592
1953
  .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)}
1954
+ /* 设置卡片里所有带 padding 的块统一 border-box。
1955
+ DSH 页面**没有**全局 border-box(而 .balance-settings 自己写了),
1956
+ 而这些块是 flex column 的子项,被 stretch 拉到父宽之后再加 padding,
1957
+ content-box 下左右各多出 24px —— 直接溢出卡片,压在相邻行上,
1958
+ 看上去就像「显示在最上层」(2026-11-27 用户:「我说的最顶层时显示在最上层」)。 */
1959
+ .balance-settings__head,.balance-settings__body,.balance-settings__group,
1960
+ .balance-settings__notice,.balance-settings__newcue,.balance-settings__group-note,
1961
+ .balance-settings__row,.balance-settings__below,.balance-settings__actions,
1962
+ .balance-settings__sync-grid,.balance-settings__label,.balance-settings__progress{box-sizing:border-box}
1593
1963
  .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)}
1964
+ .balance-settings__title{font-size:14px;font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8)}
1965
+ .balance-settings__version{font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e);font-variant-numeric:tabular-nums}
1966
+ .balance-settings__desc{margin:4px 0 0;font-size:12px;line-height:18px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1597
1967
  .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
1968
  /* 第一个分组紧接折叠头,顶线和额外内边距都去掉,避免双线 */
1599
1969
  .balance-settings__body > .balance-settings__group:first-child{margin-top:0;padding-top:0;border-top:0}
1600
1970
  /* 分组标题:左侧一道 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)}
1971
+ .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
1972
  /* 顶部告示条:设置页最前面的一条范围声明。底色/边框比分组说明再重一档,
1603
1973
  文字提到 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)}
1974
+ .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
1975
  .balance-settings__notice-icon{flex:none;display:block;margin-top:1px;color:var(--dsw-alias-brand-primary,#4d6bfe)}
1606
1976
  .balance-settings__notice-text{min-width:0}
1607
1977
  /* 「本版新增」横幅:不依赖侧栏入口也能知道有新功能。
@@ -1609,8 +1979,8 @@ window.__ModuleLoader__.load({
1609
1979
  或者从 DSH「插件」页直接进来时,这是唯一的提示(2026-10-31 用户问
1610
1980
  「如果用户没打开这个设置页面入口 怎么提示用户有新功能」)。
1611
1981
  用品牌色实心胶囊当引子 + 一行白字说明 + 右侧跳转按钮,视觉上比告示条更"新"。 */
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}
1982
+ .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)}
1983
+ .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
1984
  .balance-settings__newcue-text{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
1615
1985
  .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
1986
  .balance-settings__newcue-btn:hover{background:color-mix(in srgb,var(--dsw-alias-brand-primary,#4d6bfe) 28%,transparent)}
@@ -1637,14 +2007,14 @@ window.__ModuleLoader__.load({
1637
2007
  @media (prefers-reduced-motion:reduce){.balance-settings__row--flash::before{display:none}}
1638
2008
  /* 分组说明条:不是灰小字,而是带图标的淡蓝提示条——要一眼看见「仅支持 DeepSeek Harness」。
1639
2009
  底色用品牌色 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)}
2010
+ .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
2011
  .balance-settings__group-note-icon{flex:none;display:block;margin-top:.5px;color:var(--dsw-alias-brand-primary,#4d6bfe);opacity:.9}
1642
2012
  .balance-settings__group-note-text{min-width:0}
1643
2013
  .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
2014
  .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
2015
  .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
2016
  .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}
2017
+ .balance-settings__chevron{flex:none;color:var(--dsw-alias-label-tertiary,#9a9a9e);transition:transform .16s ease}
1648
2018
  .balance-settings[data-open="true"] .balance-settings__chevron{transform:rotate(180deg)}
1649
2019
  .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
2020
  /* 标签行:文字 + NEW 徽标并排 */
@@ -1665,32 +2035,143 @@ window.__ModuleLoader__.load({
1665
2035
  @media (prefers-reduced-motion:reduce){.balance-settings__new-badge{animation:none;box-shadow:0 0 5px color-mix(in srgb,#4d6bfe 28%,transparent)}}
1666
2036
  .balance-settings__row{display:flex;align-items:center;justify-content:space-between;gap:16px;padding:11px 0}
1667
2037
  /* 行与行之间用半像素淡线分开,避免几行文字堆成一片 */
2038
+ /* row 下方的全宽内容(节假日同步进度条)。必须渲染在 row 外面:
2039
+ 塞进 .balance-settings__control 里时,control 是 flex:none、宽度由内容决定,
2040
+ 进度条一出现就把它撑宽,左边 flex:1 的说明文字跟着换行重排
2041
+ (2026-11-27 用户:「这个进度条换个地方 要不然导致左边的字一直在动」)。 */
2042
+ .balance-settings__below{padding:0 0 11px}
2043
+ /* 中间插了 below 之后,相邻兄弟选择器断了一节,补回来 */
2044
+ .balance-settings__below + .balance-settings__row{border-top:.5px solid var(--dsw-alias-border-l1,rgba(127,127,127,.12))}
1668
2045
  .balance-settings__row + .balance-settings__row{border-top:.5px solid var(--dsw-alias-border-l1,rgba(127,127,127,.12))}
1669
2046
  .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)}
2047
+ .balance-settings__label-text{font-size:13px;line-height:19px;color:var(--dsw-alias-label-primary,#e6e6e8)}
2048
+ /* 注意提示(橙)。配色要弱一档:
2049
+ 底色从 12% 降到 6%、边框 34% → 20%、图标也从原色降到 80%。
2050
+ 2026-11-27 用户:「这个提示的颜色改成啥了 饱和度这么高」。
2051
+ 原因是上一轮把半透明底改成实心底(为了不透出下层),
2052
+ 12% 混在深色底上原本看着很淡,变实心后就是一块橙板。 */
2053
+ /* 底色直接去掉(改成 6% 透明橙,实际就是几乎看不出来)。
2054
+ 2026-11-27 用户第二次:「不还是一样吗」—— 6% 橙混进实心深色底,
2055
+ 算出来是 #2a2118,在深灰背景上仍然是明显的一块棕橙。
2056
+ 只要底色是不透明的,再少的橙也是「一块色卡」;要弱就得让它半透明。
2057
+ 这里下层就是卡片自己的底,透出去不会压到别的元素,和 notice 那条不一样。 */
2058
+ /* 提醒类提示也用和普通提示完全相同的配色。
2059
+ 2026-11-27 用户拿一条普通提示截图说「改成这种颜色」。
2060
+ 之前为了「注意」需要单独给橙色(#d97706),两轮降饱和都被嫌显眼——
2061
+ 底色不透明时再少的橙也是一块色卡,改成半透明又和整个卡片不搭。
2062
+ 现在彻底同色,区别只留在文字内容上。 */
2063
+
2064
+ /* 「注意」提示用橙色。
2065
+ 2026-11-27 用户:「这个之前的颜色恢复回去」。
2066
+ 恢复的是最初那一套:**半透明**的 12% 橙底 + 34% 橙边 + 橙类白字。
2067
+ 中间几轮都是因为「最顶层」那个问题把 transparent 改成了实心底,
2068
+ 12% 橙一变实心就是一块橙板(他随后说「饱和度这么高」)。
2069
+ 底色回到半透明就恢复原样,和「最顶层」无关。 */
2070
+ .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)}
2071
+ .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}
2072
+ .balance-settings__hint-error{display:block;margin-top:3px;color:#e5484d;font-weight:600}
2073
+ /* 同步两行的模式说明(2026-11-27):从组级提示拆下来的,各自跟在所属行说明文字后面。
2074
+ 必须 display:block 另起一行 —— 和上一句 inline 拼在一起会变成一长串。
2075
+ ⚠️ **要有框**(用户:「提示框成圆角矩形」):纯文字看不出这是条提示,和普通说明混在一起。
2076
+ 样式跟 notice / newcue / group-note 同一套 —— 8px 圆角、.5px 26% 边、10% 半透明底
2077
+ (半透明,不是 var(--dsw-alias-base) 实心;实心在深色底上会变成一块色卡)。
2078
+ 宽度用 fit-content **收缩到内容宽**:这两句长短不一,拉满整行会变成两条大色带压过正文。
2079
+ ⚠️ width:fit-content + padding 必须配 box-sizing:border-box,否则溢出父宽(DSH 没有全局 border-box)。 */
2080
+ .balance-settings__hint-mode{
2081
+ display:block;box-sizing:border-box;width:fit-content;max-width:100%;
2082
+ margin-top:6px;padding:4px 10px;border-radius:var(--dsw-radius-md,8px);
2083
+ border:.5px solid color-mix(in srgb,#d97706 26%,transparent);
2084
+ background:color-mix(in srgb,#d97706 10%,transparent);
2085
+ font-size:12px;line-height:18px;color:#f2ab55}
2086
+ .balance-settings__hint-mode--free{
2087
+ border-color:color-mix(in srgb,#9a9a9e 26%,transparent);
2088
+ background:color-mix(in srgb,#9a9a9e 10%,transparent);
2089
+ color:#b9b9bd}
2090
+ .balance-settings__sync-grid{display:grid;grid-template-columns:auto 1fr;gap:7px 16px;font-size:12px;line-height:1.5;align-items:baseline}
2091
+ .balance-settings__sync-key{color:#9a9a9e;white-space:nowrap}
2092
+ .balance-settings__sync-val{color:#e8e8ea}
2093
+ .balance-settings__sync-val--warn{color:#d97706;font-weight:600}
2094
+ .balance-settings__sync-val--cost{color:#4d6bfe;font-weight:600;font-variant-numeric:tabular-nums}
2095
+ /* 「模型解析」下面那一行模型名。独占一行,避免和标签挤在一起被从 "v4-" 中间切断。 */
2096
+ .balance-settings__sync-sub{display:block;margin-top:1px;font-size:11px;font-weight:400;line-height:16px;color:#9a9a9e;word-break:break-all}
2097
+ .balance-settings__row-actions{display:flex;align-items:center;gap:8px;justify-content:flex-end}
2098
+ /* 进度条压成一行(track 左 + label 右):竖排时 track 2px + gap 4px + label 15px = 27px,
2099
+ 同步过程中整块卡片会明显抽一下。横排只占 13px,且 label 靠右不挤标题。
2100
+ ⚠️ 它住在 .balance-settings__below 里(块级、不是 flex 子项),所以**不许**再写
2101
+ order / flex —— 2026-11-27 就是靠「flex:1 0 100%」把它当成「能在行内换行的第 4 项」,
2102
+ 结果参数传错位置时它挤进 .balance-settings__row,把左边说明文字压成一列竖排单字。 */
2103
+ .balance-settings__progress{display:flex;align-items:center;gap:8px;margin-top:5px;min-height:13px}
2104
+ /* 轨道很细:它是「还在动」的提示,不该抢走金额和按钮的注意力 */
2105
+ .balance-settings__progress-track{flex:1 1 auto;min-width:40px;height:2px;border-radius:2px;background:rgba(255,255,255,.08);overflow:hidden}
2106
+ .balance-settings__progress-fill{height:100%;border-radius:2px;background:rgba(255,255,255,.55);transition:width .35s ease}
2107
+ /* 拿不到总步数时的兜底:来回扫的滑块。比一条永远为 0 的空轨道诚实。 */
2108
+ .balance-settings__progress-fill--indeterminate{width:35%;animation:balance-progress-scan 1.2s ease-in-out infinite}
2109
+ @keyframes balance-progress-scan{0%{transform:translateX(-100%)}100%{transform:translateX(300%)}}
2110
+ .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}
2111
+ /* 弹窗里那份(2026-11-27 进度条从行内搬进来):轨道粗一档、阶段文案在轨道**上方**左对齐。
2112
+ label 在 DOM 里仍排在轨道后面,靠 order:-1 提到前面 —— 别再靠调换 JSX 顺序改,
2113
+ 行内那份万一回来还要用同一套 DOM。 */
2114
+ .balance-settings__progress--dialog{flex-direction:column;align-items:stretch;gap:6px;margin-top:0;min-height:0}
2115
+ .balance-settings__progress--dialog .balance-settings__progress-track{height:6px;border-radius:3px;background:rgba(255,255,255,.10)}
2116
+ .balance-settings__progress--dialog .balance-settings__progress-fill{border-radius:3px;background:rgba(255,255,255,.62)}
2117
+ .balance-settings__progress--dialog .balance-settings__progress-label{order:-1;flex:0 0 auto;font-size:11.5px;line-height:16px;text-align:left}
2118
+ /* 同步弹窗(自绘,不依赖 primitives.Modal)。
2119
+ fixed + portal 到 body:设置卡片挂在 slot 里,自己画遮罩会被祖先的层叠上下文裁掉。
2120
+ ⚠️ 2026-11-27 第二轮:进度态与结果态**共用这一个壳**(用户:「两个同步的弹窗用一个窗口
2121
+ 不要加载完就换窗口」)。所以宽度一次定死 460px —— 两份内容共用一个壳,壳就不许再变宽变窄,
2122
+ 否则「换内容」还是会被看成「换窗口」。结果可能很长(失败时十几行诊断),
2123
+ max-height + 内容区自滚,标题与按钮钉住不动。 */
2124
+ .balance-sync-mask{position:fixed;left:0;top:0;right:0;bottom:0;z-index:2147483000;display:flex;align-items:center;justify-content:center;background:rgba(0,0,0,.48)}
2125
+ .balance-sync-dialog{box-sizing:border-box;width:min(460px,calc(100vw - 48px));max-height:calc(100vh - 64px);padding:18px 20px 16px;border-radius:14px;background:#232324;border:1px solid rgba(255,255,255,.08);box-shadow:0 18px 48px rgba(0,0,0,.45);color:#e8e8ea;text-align:left;display:flex;flex-direction:column}
2126
+ .balance-sync-dialog__title{flex:none;font-size:14px;font-weight:600;line-height:20px;margin-bottom:14px}
2127
+ .balance-sync-dialog__running{flex:none}
2128
+ .balance-sync-dialog__body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;margin-right:-8px;padding-right:8px}
2129
+ .balance-sync-dialog__note{flex:none;margin-top:14px;font-size:13.5px;line-height:1.65;font-weight:600;color:#f2ab55}
2130
+ .balance-sync-dialog__actions{flex:none;margin-top:16px;display:flex;justify-content:flex-end}
2131
+ .balance-sync-dialog__btn{box-sizing:border-box;appearance:none;border:1px solid rgba(255,255,255,.14);background:rgba(255,255,255,.08);color:#e8e8ea;font-family:inherit;font-size:12px;line-height:18px;padding:5px 14px;border-radius:8px;cursor:pointer}
2132
+ .balance-sync-dialog__btn:hover{background:rgba(255,255,255,.14)}
2133
+ .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}
2134
+ .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}
2135
+ .balance-settings__mode-mini-btn:hover{color:#e8e8ea}
2136
+ .balance-settings__mode-mini-btn--on{background:rgba(255,255,255,.14);color:#e8e8ea;font-weight:600}
2137
+ /* 环境没挂载 dsh-llm 时「模型」是真点不了,灰掉并禁用指针,别让人以为能点 */
2138
+ /* 选中态按「要不要花钱」分色:「模型」走模型、会扣 token → 橙;
2139
+ 「免费」不调模型 → 绿。两个都是半透明底,不压其他元素。
2140
+ 2026-11-27 用户:「并且给按钮添加颜色 如果是需要token的就显示橙色」。 */
2141
+ .balance-settings__mode-mini-btn--on.balance-settings__mode-mini-btn--model{background:color-mix(in srgb,#d97706 26%,transparent);color:#f2ab55}
2142
+ .balance-settings__mode-mini-btn--on.balance-settings__mode-mini-btn--free{background:color-mix(in srgb,#22c55e 22%,transparent);color:#63dc92}
2143
+ .balance-settings__mode-mini-btn:disabled{opacity:.38;cursor:not-allowed}
2144
+ .balance-settings__mode-mini-btn:disabled:hover{color:#9a9a9e}
2145
+ .balance-settings__sync-note{margin-top:13px;font-size:11px;line-height:1.6;color:#9a9a9e}
2146
+ .balance-settings__hint{font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1672
2147
  .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)}
2148
+ .balance-settings__unit{font-size:12px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1674
2149
  /* 文本类输入:数字框那套 96px + 右对齐会把「9-12, 14-18」截掉,单独放宽并左对齐 */
1675
2150
  .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 规则):
2151
+ .balance-settings__input--text::placeholder{color:var(--dsw-alias-label-tertiary,#9a9a9e)}/* 输入框底色照抄 DSH 官方设置页(dsh-client-ui-settings-models 的 input 规则):
1677
2152
  那边用 --dsw-alias-bg-layer-1,不是 layer-3。深色主题下三层分别是
1678
2153
  bg-layer-1 #232324 / bg-layer-2 #2c2c2e / bg-layer-3 #353638,页面底 bg-base #151517 —
1679
2154
  用 layer-3 比底色亮 32 级,在设置卡片里就是一块发闷的灰板(用户反馈「那个框的颜色太灰了」)。
1680
2155
  layer-1 只亮 14 级,和官方观感一致;浅色主题下 layer-1 = #fff 与底色同色,
1681
2156
  层次完全靠 .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}
2157
+ .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
2158
  .balance-settings__input:focus-visible{outline:none;border-color:var(--dsw-alias-state-business-primary,#4d6bfe)}
1684
2159
  .balance-settings__input--wide{width:100%;max-width:340px;min-width:0;text-align:left}
1685
2160
  /* 关掉侧边栏入口后的提醒:壳用 DSH 官方 Modal,这里只留正文排版。 */
1686
- .balance-tip-body{margin:0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary)}
2161
+ .balance-tip-body{margin:0;font-size:13px;line-height:1.7;color:var(--dsw-alias-label-secondary,#b9b9bd)}
1687
2162
  /* 节假日数据行:右侧是「状态文案 + 立即同步」两段,窄屏时自动换行靠右。 */
1688
2163
  .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)}
2164
+ /* 「立即同步」和「同步中…」字数相同但标点不等宽,实测差 4px ——
2165
+ 而 control 是 flex:none、宽度由内容决定,这 4px 会一路传到左边 label 的宽度上,
2166
+ 说明文字就在换行边界上来回跳。把按钮宽度钉死,两种文案一样宽。 */
2167
+ .balance-settings__calendar .balance-settings__btn{min-width:78px}
2168
+ /* 状态文字(已同步 106 天 · 11-26 21:11)和「模型/免费」挤一行会互相压位置,
2169
+ 所以让它独占第二行、右对齐。order 把三样排成「切换 + 同步按钮」在上、状态在下。 */
2170
+ .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}
2171
+ .balance-settings__calendar-note--warn{color:var(--dsw-alias-state-warning-primary,#d97706)}
1691
2172
  .balance-settings__calendar-note--ok{color:var(--dsw-alias-state-success-primary,#22c55e)}
1692
2173
  .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}
2174
+ .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
2175
  .balance-tip-ok:hover{opacity:.88}
1695
2176
  .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
2177
  .balance-settings__toggle[aria-checked="true"]{background:var(--dsw-alias-brand-primary,#4d6bfe)}
@@ -1698,9 +2179,9 @@ window.__ModuleLoader__.load({
1698
2179
  .balance-settings__toggle[aria-checked="true"]::after{background:var(--dsw-alias-label-primary-foreground,#fff);transform:translateX(16px)}
1699
2180
  /* 二选一分段控件(余额行外观 新版/旧版) */
1700
2181
  .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)}
2182
+ .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)}
2183
+ .balance-settings__segment:hover{color:var(--dsw-alias-label-primary,#e6e6e8)}
2184
+ .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
2185
  /* 「消耗行加载动效」那一行的实时预览(2026-10-31 用户要求:「在介绍栏预览给用户看红圈位置」)。
1705
2186
  直接复用消耗行的真实类名(.balance-usage-mist / .balance-usage-calc),
1706
2187
  所以这里看到的就是输入框下方真会出现的那个效果 —— 两边永远不会走样,改一处两边一起变。
@@ -1711,14 +2192,14 @@ window.__ModuleLoader__.load({
1711
2192
  窄屏整块隐藏:640px 以下 label 已经被挤得很窄,再加预览会把文字压断。 */
1712
2193
  .balance-settings__preview{display:flex;align-items:center;margin-left:auto;margin-right:8px;flex:none}
1713
2194
  .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}
2195
+ .balance-settings__preview-tag{font-size:9.5px;line-height:1;color:var(--dsw-alias-label-tertiary,#9a9a9e);white-space:nowrap}
1715
2196
  /* 预览里要把「本会话消耗」这几个字一起画出来 —— 只放一条光带的话看不出这是哪一行,
1716
2197
  真实的那颗胶囊就是「本会话消耗 + 效果」,预览得对得上(2026-10-31 用户:「这个不应该显示对话消耗吗」)。
1717
2198
  胶囊宽度取 81px:真身是 min-width:10.6ch(13px 字号下约 80.8px),预览要是收成 44px,
1718
2199
  光团被裁得更狠、纵向那点涌动就看不出来了 —— 预览跟着真身的尺寸走才不会骗人。
1719
2200
  stage 的 min-width 钉住两种样式的宽度差(「计算中」那颗比光胶囊宽),切样式时右侧按钮不会左右挪。 */
1720
2201
  .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}
2202
+ .balance-settings__preview-text{font-size:10.5px;line-height:14px;color:var(--dsw-alias-label-tertiary,#9a9a9e);white-space:nowrap}
1722
2203
  .balance-settings__preview-stage .balance-usage-mist{min-width:0;width:81px}
1723
2204
  /* .balance-usage-calc 本身只定了尺寸和圆角,字号/行高/nowrap 是从消耗行的 .balance-usage-line 继承来的
1724
2205
  —— 预览里没有那层,不补这三行「计算中」会折成「计算 / 中」两行并撑破胶囊。 */
@@ -1733,41 +2214,52 @@ window.__ModuleLoader__.load({
1733
2214
  .balance-settings__update--newer{border-color:color-mix(in srgb,#4d6bfe 42%,transparent);background:color-mix(in srgb,#4d6bfe 14%,transparent)}
1734
2215
  .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
2216
  .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}
2217
+ .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)}
2218
+ .balance-settings__update-ver{font-weight:600;color:var(--dsw-alias-label-primary,#e6e6e8);font-variant-numeric:tabular-nums}
1738
2219
  /* 新版徽标:实心品牌色胶囊,形状必须是正圆角(DSH 全局把圆角改成 superellipse 了) */
1739
2220
  .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
2221
  .balance-settings__update-btns{display:flex;align-items:center;gap:6px;flex:none}
1741
2222
  /* 查询中的进度文案:跟按钮同一行、排在左边,灰一点,不跟主文案抢注意力。 */
1742
- .balance-settings__update-busy{flex:none;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary);white-space:nowrap}
2223
+ .balance-settings__update-busy{flex:none;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e);white-space:nowrap}
1743
2224
  /* 标题行左侧的状态话(目前只有「已是最新版本。」)—— 成功绿,前面一个细分隔点,
1744
2225
  与「版本 2.0.2」拉开层次但不抢眼。 */
1745
2226
  .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)}
2227
+ .balance-settings__update-inline::before{content:"·";margin:0 2px 0 0;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
2228
+ .balance-settings__update-note{margin:7px 0 0;font-size:11.5px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1748
2229
  .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
2230
  /* 数据诊断:按钮组 + 报告块。
1750
2231
  报告是等宽文本、要能整段选中复制,所以 pre + user-select:text;
1751
2232
  放不下时自己滚(max-height 限制高度,别把设置页撑到几屏长)。 */
1752
2233
  .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}
2234
+ .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
2235
  .balance-settings__diag--error{color:var(--dsw-alias-state-error-primary,#e5484d)}
1755
2236
  .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)}
2237
+ .balance-settings__diag-warn{color:var(--dsw-alias-state-warning-primary,#d97706)}
1757
2238
  .balance-settings__diag-ok{color:var(--dsw-alias-state-success-primary,#3fb950)}
1758
2239
  .balance-settings__diag-head{font-weight:600}
1759
2240
  .balance-settings__diag-fix{margin:8px 0 0;font-size:12px;line-height:17px}
1760
2241
  .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)}
2242
+ .balance-settings__diag-fix--warn{color:var(--dsw-alias-state-warning-primary,#d97706)}
2243
+ .balance-settings__status{flex:1;min-width:0;font-size:12px;line-height:17px;color:var(--dsw-alias-label-tertiary,#9a9a9e)}
1763
2244
  .balance-settings__status--error{color:var(--dsw-alias-state-error-primary,#e5484d)}
1764
2245
  .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))}
2246
+ /* 设置面板的按钮不跟主题走(2026-11-27 用户:
2247
+ 「插件的设置界面你是不是保持了 dsh 的风格 导致按钮的颜色显示不出来
2248
+ 可以不用同一个主题的」)。
2249
+ 原来主按钮是 background:label-primary + color:bg-layer-3 ——
2250
+ 这两个变量在某些主题里反差太小(或根本未定义),
2251
+ 字和底一起消失。现在用固定品牌蓝 + 白字,不受主题影响。 */
2252
+ .balance-settings__btn{box-sizing:border-box;flex:none;white-space:nowrap;padding:5px 14px;
2253
+ border:.5px solid rgba(127,127,127,.34);border-radius:var(--dsw-radius-md,8px);
2254
+ background:rgba(127,127,127,.12);color:var(--dsw-alias-label-primary,#e6e6e8);
2255
+ font:inherit;font-size:13px;line-height:1.5;cursor:pointer;
2256
+ transition:background .12s ease,border-color .12s ease,opacity .12s ease}
2257
+ .balance-settings__btn:hover:not(:disabled){background:rgba(127,127,127,.22);border-color:rgba(127,127,127,.5)}
1767
2258
  .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}
2259
+ .balance-settings__btn--primary{border-color:#4d6bfe;background:#4d6bfe;color:#fff;font-weight:600}
2260
+ .balance-settings__btn--primary:hover:not(:disabled){background:#5d79ff;border-color:#5d79ff;color:#fff;opacity:1}
2261
+ .balance-settings__btn--primary:active:not(:disabled){background:#3f5bef;border-color:#3f5bef}
2262
+ .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
2263
  `;
1772
2264
 
1773
2265
  const tagId = "balance/balance-widget.css";
@@ -2407,11 +2899,16 @@ let floatRemeasureHook = null;
2407
2899
  // (2026-10-30 用户要求「对话消耗的数字变动动画跟余额的自动刷新一样」)。
2408
2900
  const ROLL_EMPTY = "\u0000";
2409
2901
  function buildRollCells(fromText, toText) {
2902
+ // ⚠️ 正则必须能吃掉**前导非数字**(¥ / $ 这类货币符号)。
2903
+ // 原来写的是 /^([0-9]*)(\.?)([0-9]*)…/,数字段在开头 —— 喂进来的 real 值是
2904
+ // totalText("¥1.9400"),首字符是 ¥,于是 int/dot/frac 全空、**整个串被当成 tail**。
2905
+ // tail 现在整段一格且 changed 恒 false ⇒ 余额胶囊会一格都不滚、数字硬切。
2906
+ // 拆成 pre(符号)/ int / dot / frac / tail 五段,符号和尾巴各自是静态整格。
2410
2907
  const split = (text) => {
2411
- const m = /^([0-9]*)(\.?)([0-9]*)([\s\S]*)$/.exec(text);
2908
+ const m = /^([^0-9]*)([0-9]*)(\.?)([0-9]*)([\s\S]*)$/.exec(text);
2412
2909
  return m
2413
- ? { int: m[1], dot: m[2], frac: m[3], tail: m[4] }
2414
- : { int: "", dot: "", frac: "", tail: text };
2910
+ ? { pre: m[1], int: m[2], dot: m[3], frac: m[4], tail: m[5] }
2911
+ : { pre: "", int: "", dot: "", frac: "", tail: text };
2415
2912
  };
2416
2913
  const a = split(fromText);
2417
2914
  const b = split(toText);
@@ -2427,7 +2924,6 @@ let floatRemeasureHook = null;
2427
2924
  const padRight = (s, n) => s.padEnd(n, ROLL_EMPTY);
2428
2925
  const intLen = Math.max(a.int.length, b.int.length);
2429
2926
  const fracLen = Math.max(a.frac.length, b.frac.length);
2430
- const tailLen = Math.max(a.tail.length, b.tail.length);
2431
2927
  // 小数点这一格**按新值的形态**决定去留:新值不带小数就是空位(滚走 + --gone 收宽)。
2432
2928
  // 原来是 `a.dot || b.dot` 两边都取「有小数点的那一侧」,于是 99.99 → 100 之后
2433
2929
  // 新值侧仍留着一个小数点,小数位已经收成 0 宽,屏幕上却是 `¥100.`,
@@ -2443,7 +2939,6 @@ let floatRemeasureHook = null;
2443
2939
  [padLeft(a.int, intLen), padLeft(b.int, intLen)],
2444
2940
  ...dotCells,
2445
2941
  [padRight(a.frac, fracLen), padRight(b.frac, fracLen)],
2446
- [padRight(a.tail, tailLen), padRight(b.tail, tailLen)],
2447
2942
  ];
2448
2943
  const cells = [];
2449
2944
  for (const [left, right] of rows) {
@@ -2451,6 +2946,19 @@ let floatRemeasureHook = null;
2451
2946
  cells.push({ from: left[i], to: right[i], changed: left[i] !== right[i] });
2452
2947
  }
2453
2948
  }
2949
+ // ⚠️ 尾巴(" CNY" / " USD" 这类)**整段一格**,绝不逐字符拆
2950
+ // (2026-11-26 用户:「这个滚动是不是有点问题 我刚刚余光看到了」)。
2951
+ // 原来它走和数字一样的逐字符循环," CNY" 就变成「空格 / C / N / Y」四个独立 span:
2952
+ // 每格都是独立的 inline-block,字母之间的字距、抗锯齿、亚像素定位都不再是
2953
+ // 一整段文本的排法,整串看起来有点毛;而且它永远不变,拆了也毫无用处。
2954
+ // 现在它是一格静态 dcell(changed 恒 false → 不滚),宽度随内容自适应。
2955
+ // 前缀(¥ / $)整段一格,永远是静态的;币种不会变,拆字符只会让字距发毛
2956
+ if (a.pre !== "" || b.pre !== "") {
2957
+ cells.unshift({ from: a.pre, to: b.pre, changed: false, whole: true });
2958
+ }
2959
+ if (a.tail !== "" || b.tail !== "") {
2960
+ cells.push({ from: a.tail, to: b.tail, changed: false, whole: true });
2961
+ }
2454
2962
  return cells;
2455
2963
  }
2456
2964
 
@@ -2560,16 +3068,25 @@ let floatRemeasureHook = null;
2560
3068
 
2561
3069
  function renderRollCells(cells, prefix, settled, quick) {
2562
3070
  // 先按从右往左给「会滚的格子」编号:最右边的滚动格延迟 0
2563
- const total = cells.length;
2564
3071
  const staggerMs = quick === true ? COST_ROLL_STAGGER_MS : ROLL_STAGGER_MS;
2565
3072
  const staggerMax = quick === true ? COST_ROLL_STAGGER_MAX : ROLL_STAGGER_MAX;
3073
+ // ⚠️ 只给**会滚的格子**编号,静态格(¥ 前缀、CNY 尾巴)不占号。
3074
+ // 用 cells.length 的话,加了符号格之后每个滚动格的 fromRight 整体偏大一档,
3075
+ // 延迟被白白推后,看起来就是「旁边的格子先滚、它还在原地」。
3076
+ const rollIdx = new Array(cells.length).fill(-1);
3077
+ {
3078
+ let n = 0;
3079
+ for (let k = cells.length - 1; k >= 0; k -= 1) {
3080
+ if (cells[k].changed) rollIdx[k] = n++;
3081
+ }
3082
+ }
2566
3083
  return jsx.jsx("span", {
2567
3084
  className: "balance-footer__roll" + (quick === true ? " balance-footer__roll--quick" : ""),
2568
3085
  children: cells.map((cell, i) => {
2569
3086
  if (!cell.changed) {
2570
3087
  return jsx.jsx("span", { className: "balance-footer__dcell", children: cell.to === ROLL_EMPTY ? "\u00a0" : cell.to }, prefix + i);
2571
3088
  }
2572
- const fromRight = total - 1 - i;
3089
+ const fromRight = rollIdx[i];
2573
3090
  const step = Math.min(fromRight, staggerMax);
2574
3091
  const delay = step * staggerMs;
2575
3092
  const style = delay > 0 ? { animationDelay: delay + "ms" } : undefined;
@@ -2582,6 +3099,9 @@ let floatRemeasureHook = null;
2582
3099
  className: "balance-footer__dcell balance-footer__dcell--roll"
2583
3100
  + (cell.to === ROLL_EMPTY ? " balance-footer__dcell--gone" : "")
2584
3101
  + (settled === true ? " balance-footer__dcell--roll-done" : ""),
3102
+ // ⚠️ dout 必须显式 hidden 自己那份。--roll-done 那条 CSS 已经写了
3103
+ // display:none,这里再兜一层:一旦哪天真丢了那条规则,旧值不会
3104
+ // 和新值叠在同一个位置(用户看到的就是「滚动时有别的数字」)。
2585
3105
  children: [
2586
3106
  // 影子格用「新字符」撑宽;新值是空位时退回旧字符 —— 滚动开始那一刻的宽度
2587
3107
  // 正好等于滚动前,之后由 --gone 的 max-width 动画把它平滑收到 0。
@@ -2693,7 +3213,8 @@ let floatRemeasureHook = null;
2693
3213
  return activePeakWindows;
2694
3214
  }
2695
3215
  // 中国大陆法定节假日与调休(北京时区)。**必须与 lib/index.js 的 CN_CALENDAR 完全一致**
2696
- // (服务端负责算钱、客户端只负责显示时段标签)。来源:国办发明电〔2025〕7号,每年需补录。
3216
+ // (服务端负责算钱、客户端只负责显示时段标签)。2026 来自国办发明电〔2025〕7号,
3217
+ // 2027 来自国务院 2026-11 的次年安排。每年 11 月前后要补录下一年。
2697
3218
  const CN_CALENDAR = {
2698
3219
  // 元旦:1/1-1/3 放假,1/4(周日) 上班
2699
3220
  "2026-01-01": "holiday", "2026-01-02": "holiday", "2026-01-03": "holiday", "2026-01-04": "workday",
@@ -2716,6 +3237,27 @@ let floatRemeasureHook = null;
2716
3237
  // 国庆节:10/1-10/7 放假,10/10(周六) 上班
2717
3238
  "2026-10-01": "holiday", "2026-10-02": "holiday", "2026-10-03": "holiday", "2026-10-04": "holiday",
2718
3239
  "2026-10-05": "holiday", "2026-10-06": "holiday", "2026-10-07": "holiday", "2026-10-10": "workday",
3240
+ // ── 2027 年(国办发明电〔2026〕10 号,2026-11-05 发布,已正式公布才收录)──
3241
+ // 元旦:1/1(五)-1/3(日) 放假,共 3 天(与周末自然相连,无调休)
3242
+ "2027-01-01": "holiday", "2027-01-02": "holiday", "2027-01-03": "holiday",
3243
+ // 春节:2/5(除夕、五)-2/13(正月初八、六) 放假调休,共 9 天;1/31(日)、2/14(日) 上班
3244
+ "2027-01-31": "workday",
3245
+ "2027-02-05": "holiday", "2027-02-06": "holiday", "2027-02-07": "holiday", "2027-02-08": "holiday",
3246
+ "2027-02-09": "holiday", "2027-02-10": "holiday", "2027-02-11": "holiday", "2027-02-12": "holiday",
3247
+ "2027-02-13": "holiday", "2027-02-14": "workday",
3248
+ // 清明节:4/3(六)-4/5(一) 放假,共 3 天(无调休)
3249
+ "2027-04-03": "holiday", "2027-04-04": "holiday", "2027-04-05": "holiday",
3250
+ // 劳动节:5/1(六)-5/5(三) 放假调休,共 5 天;5/8(六) 上班
3251
+ "2027-05-01": "holiday", "2027-05-02": "holiday", "2027-05-03": "holiday", "2027-05-04": "holiday",
3252
+ "2027-05-05": "holiday", "2027-05-08": "workday",
3253
+ // 端午节:6/9(三) 放假,共 1 天(无调休)
3254
+ "2027-06-09": "holiday",
3255
+ // 中秋节:9/15(三) 放假,共 1 天(无调休)
3256
+ "2027-09-15": "holiday",
3257
+ // 国庆节:10/1(五)-10/7(四) 放假调休,共 7 天;9/26(日)、10/9(六) 上班
3258
+ "2027-09-26": "workday",
3259
+ "2027-10-01": "holiday", "2027-10-02": "holiday", "2027-10-03": "holiday", "2027-10-04": "holiday",
3260
+ "2027-10-05": "holiday", "2027-10-06": "holiday", "2027-10-07": "holiday", "2027-10-09": "workday",
2719
3261
  };
2720
3262
 
2721
3263
  // 节假日自动补录:与 lib/index.js 同源、同逻辑(客户端只用来显示时段标签)。
@@ -2770,7 +3312,7 @@ const CN_CALENDAR_SOURCES = [
2770
3312
  * 点关闭按钮 → 捕获阶段先 arm 230ms 打开定时器 → 按钮随即关闭 → 230ms 后又被打开,面板关不掉)。 */
2771
3313
  function isOverlayTarget(target) {
2772
3314
  try {
2773
- return Boolean(target && typeof target.closest === "function" && target.closest(".balance-stats-layer, .balance-platform-layer"));
3315
+ return Boolean(target && typeof target.closest === "function" && target.closest(".balance-stats-layer, .balance-platform-layer, .balance-pop"));
2774
3316
  } catch {
2775
3317
  return false;
2776
3318
  }
@@ -2877,7 +3419,10 @@ const CN_CALENDAR_SOURCES = [
2877
3419
  ["todaySessionLimit", "2.1.0"], // 今日消耗扫描上限:多开对话 / 多跑子代理时把今日汇总算全
2878
3420
  ["showUsagePill", "2.1.6"], // 2.1.6:消耗行搬成对话界面右下角小浮窗(两行:本会话估算 / 金额)
2879
3421
  ["diag", "2.2.6"], // 2.2.6:设置页「数据诊断」—— 一键出结论 + 复制 + 查出问题给「修复」
2880
- ["aggCacheMax", "2.3.5"], // 2.3.5:聚合缓存条数上限(原来写死 320,会话多的人装不下)
3422
+ ["aggCacheMax", "2.3.7"], // 2.3.7:聚合缓存条数上限(原来写死 320,会话多的人装不下)
3423
+ ["syncedPricingAt", "2.3.7"], // 2.3.7:一键同步官方价与时段(官网改价不用等插件发版)
3424
+ ["syncModePricing", "2.3.7"], // 2.3.7:价格同步走模型还是免费
3425
+ ["syncModeCalendar", "2.3.7"], // 2.3.7:节假日同步走模型还是免费
2881
3426
  ]);
2882
3427
 
2883
3428
  /** NEW_TAGS 的 key → 设置项中文名。横幅要写「本版新增:消耗行加载动效」,
@@ -2891,6 +3436,9 @@ const CN_CALENDAR_SOURCES = [
2891
3436
  showUsagePill: "对话右下角消耗浮窗",
2892
3437
  diag: "数据诊断",
2893
3438
  aggCacheMax: "聚合缓存条数上限",
3439
+ syncModePricing: "价格同步方式",
3440
+ syncModeCalendar: "节假日同步方式",
3441
+ syncedPricingAt: "同步官方价格与时段",
2894
3442
  };
2895
3443
 
2896
3444
  /** 模板串里取一张表的三个 NEW 相关字段,缺省一律安全兜底。 */
@@ -3191,6 +3739,12 @@ const CN_CALENDAR_SOURCES = [
3191
3739
  todaySessionLimit: 200,
3192
3740
  statsCacheSec: 300,
3193
3741
  aggCacheMax: 320,
3742
+ syncModePricing: "model",
3743
+ syncModeCalendar: "model",
3744
+ syncedPricingAt: 0,
3745
+ syncedPricingFrom: "",
3746
+ syncedPricingNote: "",
3747
+ priceBaseline: null,
3194
3748
  peakWindowsText: "9-12, 14-18",
3195
3749
  peakMultiplier: 2,
3196
3750
  priceFlash: null,
@@ -3255,9 +3809,13 @@ const CN_CALENDAR_SOURCES = [
3255
3809
  return calendarInFlight;
3256
3810
  }
3257
3811
 
3258
- /** 手动同步:POST 让服务端去拉当年 ±1 年的国务院公告并落盘。 */
3259
- async function syncCalendar() {
3260
- const res = await fetch("/balance-api?calendar=1", {
3812
+ /** 手动同步:POST 让服务端去拉当年 ±1 年的国务院公告并落盘。
3813
+ * `mode` 必须跟着请求走(2026-11-27:「我选的免费怎么还消耗我都token」):
3814
+ * 设置页的开关是 350ms 防抖保存,点完「免费」立刻点同步时保存请求还没落,
3815
+ * 服务端读已保存的设置就会照模型路径烧 token。带在 query 里以眼前的选择为准。 */
3816
+ async function syncCalendar(mode) {
3817
+ const q = mode === "free" || mode === "model" ? "&mode=" + mode : "";
3818
+ const res = await fetch("/balance-api?calendar=1" + q, {
3261
3819
  method: "POST",
3262
3820
  headers: { accept: "application/json" },
3263
3821
  });
@@ -3278,6 +3836,119 @@ const CN_CALENDAR_SOURCES = [
3278
3836
  return calendarCache;
3279
3837
  }
3280
3838
 
3839
+ /** 一年之内的阶段权重。`done` 是 0:那一年已经计进 `done` 计数了,不能再叠一次。 */
3840
+ const CAL_PHASE_WEIGHT = { search: 0.12, fetch: 0.45, parse: 0.85, done: 0 };
3841
+
3842
+ /** 进度百分比。done 是「已经走完几年」,phase 是「当前这一年走到哪一步」。
3843
+ * ⚠️ 必须**单调递增**:早先 done 阶段给了权重 1,于是「2 个年份、第 1 个刚跑完」
3844
+ * 算成 (1+1)/2 = 100%,紧接着第 2 年一开始又算成 (0+0.12)/2 = 6% ——
3845
+ * 进度条从满格猛地退到最左,用户看到的就是「查询下一年会往左跑」。
3846
+ * 现在分母固定为总年数、分子只由「走完几年 + 当前年走到第几步」决定,只会前进。 */
3847
+ function calendarProgressPct(p) {
3848
+ if (p == null) return 0;
3849
+ const total = Number(p.total) || 0;
3850
+ const done = Number(p.done) || 0;
3851
+ if (total <= 0) return 0;
3852
+ if (total <= done) return 100;
3853
+ const w = CAL_PHASE_WEIGHT[p.phase] ?? 0;
3854
+ return Math.min(100, Math.max(0, ((done + w) / total) * 100));
3855
+ }
3856
+
3857
+ /** 同步弹窗(自绘,portal 到 body)。
3858
+ * 为什么不用官方 `primitives.Modal`:2026-11-27 用户报「并没有弹窗啊」——
3859
+ * 这条路在官方 Modal 上查不到原因(模块能 require、导出里确实有 Modal、
3860
+ * 结果弹窗也一直用它)。而「同步中」这张是唯一**必须一开跑就出现**的反馈,
3861
+ * 赌不起,所以自己画:官方 Modal 在不在都不影响它。
3862
+ * Esc / 点遮罩 / 点按钮都只是**收起窗口**,不中断服务端那趟同步。
3863
+ *
3864
+ * ⚠️ 2026-11-27 第二轮:用户「两个同步的弹窗用一个窗口 不要加载完就换窗口」。
3865
+ * 原来是「进度一张自绘窗、结果一张官方 Modal」—— 壳不同、位置不同、大小不同,
3866
+ * 同步一结束就是关一张开一张,看着像换了窗口。现在**壳只此一个**:
3867
+ * `phase === "running"` 时渲染进度条,`phase === "result"` 时渲染 `children`
3868
+ * (结果 / 报错内容)。标题、按钮文案由调用方按阶段给,窗口本体不重建、不换位。
3869
+ * 所以 `open` 要写成「弹窗开关 && kind 不是 idle」,别在结果阶段把它关掉。 */
3870
+ const SyncProgressDialog = (props) => {
3871
+ const open = props.open === true;
3872
+ const onClose = typeof props.onClose === "function" ? props.onClose : () => {};
3873
+ // ⚠️ 同步中**锁住弹窗**(2026-11-27 用户:「不要后台同步 因为有人以为后台同步就可以
3874
+ // 切到对话了 一定告诫用户不要离开这个弹窗」)。原来进度态那颗按钮叫「后台同步」,
3875
+ // 点了就关窗、同步照跑 —— 用户会读成「可以切去对话了」,走了就再也看不到进度和结果。
3876
+ // 现在进度态**根本不给按钮**,Esc 与点遮罩也不关;只有结果态能关(「知道了」)。
3877
+ // 代价是同步期间关不掉窗口,但同步本身有服务端超时,而「误以为能走」是实打实的坑。
3878
+ // ⚠️ result / locked 必须写在 useEffect **之前**(effect 里要用 locked,且 hook 顺序固定)。
3879
+ const result = props.phase === "result";
3880
+ const locked = !result;
3881
+ // hook 必须写在任何 return 之前(铁律 2)。
3882
+ react.useEffect(() => {
3883
+ if (!open || locked) return undefined;
3884
+ const onKey = (event) => {
3885
+ if (event && event.key === "Escape") onClose();
3886
+ };
3887
+ document.addEventListener("keydown", onKey);
3888
+ return () => document.removeEventListener("keydown", onKey);
3889
+ }, [open, locked, onClose]);
3890
+ if (!open) return null;
3891
+ const pct = Number(props.pct) || 0;
3892
+ const scanning = !result && (props.indeterminate === true || pct <= 0);
3893
+ const node = jsx.jsxs("div", {
3894
+ className: "balance-sync-mask",
3895
+ onClick: locked ? undefined : onClose,
3896
+ children: [
3897
+ jsx.jsxs("div", {
3898
+ className: "balance-sync-dialog",
3899
+ onClick: (event) => {
3900
+ if (event && typeof event.stopPropagation === "function") event.stopPropagation();
3901
+ },
3902
+ children: [
3903
+ jsx.jsx("div", { className: "balance-sync-dialog__title", children: props.title || "正在同步" }),
3904
+ // 进度态与结果态**共用这一个壳**,只在中间这段换内容:
3905
+ // 结果可能很长(失败时十几行诊断),所以内容区自己滚,标题和按钮钉住。
3906
+ result
3907
+ ? jsx.jsx("div", { className: "balance-sync-dialog__body", children: props.children })
3908
+ : jsx.jsxs("div", {
3909
+ className: "balance-sync-dialog__running",
3910
+ children: [
3911
+ jsx.jsxs("div", {
3912
+ className: "balance-settings__progress balance-settings__progress--dialog",
3913
+ children: [
3914
+ jsx.jsx("div", {
3915
+ className: "balance-settings__progress-track",
3916
+ children: jsx.jsx("div", {
3917
+ className:
3918
+ "balance-settings__progress-fill"
3919
+ + (scanning ? " balance-settings__progress-fill--indeterminate" : ""),
3920
+ style: scanning ? undefined : { width: pct + "%" },
3921
+ }),
3922
+ }),
3923
+ jsx.jsx("span", {
3924
+ className: "balance-settings__progress-label",
3925
+ children: props.label || "正在同步…",
3926
+ }),
3927
+ ],
3928
+ }),
3929
+ jsx.jsx("div", { className: "balance-sync-dialog__note", children: props.note || "" }),
3930
+ ],
3931
+ }),
3932
+ // 进度态没有按钮:不给「后台同步」这类会被读成「可以走了」的出口。
3933
+ locked
3934
+ ? null
3935
+ : jsx.jsx("div", {
3936
+ className: "balance-sync-dialog__actions",
3937
+ children: jsx.jsx("button", {
3938
+ type: "button",
3939
+ className: "balance-sync-dialog__btn",
3940
+ onClick: onClose,
3941
+ children: props.closeLabel || "知道了",
3942
+ }),
3943
+ }),
3944
+ ],
3945
+ }),
3946
+ ],
3947
+ });
3948
+ // 没有 body(非浏览器环境)时退回内联节点,绝不抛错。
3949
+ return typeof document !== "undefined" && document.body ? createPortal(node, document.body) : node;
3950
+ };
3951
+
3281
3952
  function emitSettings() {
3282
3953
  // 逐个订阅者隔离:设置热更新必须送达所有订阅者。
3283
3954
  for (const listener of settingsListeners) {
@@ -3302,6 +3973,7 @@ const CN_CALENDAR_SOURCES = [
3302
3973
  value: { ...SETTINGS_DEFAULTS, ...data.settings },
3303
3974
  loaded: true,
3304
3975
  version: typeof data.version === "string" ? data.version : settingsCache.version,
3976
+ modelSync: data.modelSync ?? null,
3305
3977
  };
3306
3978
  // 高峰窗口跟着设置走:判定与刻度都得换,否则标签会和实际计费对不上
3307
3979
  applyPeakWindowsText(settingsCache.value.peakWindowsText);
@@ -3346,6 +4018,7 @@ const CN_CALENDAR_SOURCES = [
3346
4018
  value: { ...SETTINGS_DEFAULTS, ...server, ...kept },
3347
4019
  loaded: true,
3348
4020
  version: typeof data.version === "string" ? data.version : settingsCache.version,
4021
+ modelSync: data.modelSync ?? settingsCache.modelSync,
3349
4022
  };
3350
4023
  applyPeakWindowsText(settingsCache.value.peakWindowsText);
3351
4024
  emitSettings();
@@ -3600,6 +4273,28 @@ const CN_CALENDAR_SOURCES = [
3600
4273
  void fetchTodayOnce(false);
3601
4274
  }
3602
4275
 
4276
+ /** `?session=` 带回来的 today 可能**没有** hourly / sessionTitles —— 那两项只有
4277
+ * `?today=1` 那条全量路径才会算。直接采纳它会把手里已有的曲线数据抹掉,
4278
+ * 小窗就从「有曲线」退回「正在汇总」。这里按字段级继承:新值有就用新的,
4279
+ * 没有就留住旧的那份。 */
4280
+ function inheritTodayExtras(next, prev) {
4281
+ if (next == null || typeof next !== "object") return next;
4282
+ if (prev == null || typeof prev !== "object") return next;
4283
+ const out = { ...next };
4284
+ const hasHourly = Array.isArray(next.hourly) && next.hourly.length > 0;
4285
+ if (!hasHourly && Array.isArray(prev.hourly) && prev.hourly.length > 0) out.hourly = prev.hourly;
4286
+ const hasTitles = next.sessionTitles != null && typeof next.sessionTitles === "object"
4287
+ && Object.keys(next.sessionTitles).length > 0;
4288
+ if (!hasTitles && prev.sessionTitles != null && typeof prev.sessionTitles === "object") {
4289
+ out.sessionTitles = prev.sessionTitles;
4290
+ }
4291
+ // bySession 同理:增量路径只带「当前会话那一桶 + 其余原样搬运」,正常情况下是全的,
4292
+ // 但 baseline 是旧快照时可能只有一两个桶 —— 少于旧的就别用它。
4293
+ const nextBuckets = next.bySession && typeof next.bySession === "object" ? Object.keys(next.bySession).length : 0;
4294
+ const prevBuckets = prev.bySession && typeof prev.bySession === "object" ? Object.keys(prev.bySession).length : 0;
4295
+ if (nextBuckets < prevBuckets) out.bySession = prev.bySession;
4296
+ return out;
4297
+ }
3603
4298
  function raiseTodayFromSession(today) {
3604
4299
  if (today == null || typeof today.cost !== "number" || !Number.isFinite(today.cost)) return;
3605
4300
  const prev = todayCache.value;
@@ -3615,7 +4310,7 @@ const CN_CALENDAR_SOURCES = [
3615
4310
  // 现在:新的一天直接采纳服务端口径(它含实时事件,比持久化口径只多不少),
3616
4311
  // 再补一次 `?today=1` 把「其余会话」那部分也拿回来。昨天的账一个字都不搬过来。
3617
4312
  if (prev.date !== today.date) {
3618
- todayCache.value = today;
4313
+ todayCache.value = inheritTodayExtras(today, prev);
3619
4314
  todayCache.at = Date.now();
3620
4315
  todayCache.tried = true;
3621
4316
  todayCache.settled = true;
@@ -3639,7 +4334,7 @@ const CN_CALENDAR_SOURCES = [
3639
4334
  return;
3640
4335
  }
3641
4336
  }
3642
- todayCache.value = today;
4337
+ todayCache.value = inheritTodayExtras(today, prev);
3643
4338
  todayCache.tried = true;
3644
4339
  todayCache.settled = true;
3645
4340
  notifyToday();
@@ -4029,6 +4724,10 @@ const CN_CALENDAR_SOURCES = [
4029
4724
  // 网页搜索 / 抓取:官方 2026-10-17 上线独立计费,¥5 / 千次 = ¥0.005 / 次,
4030
4725
  // 北京时间 2026-11-01 00:00 起开始收费(此前免费)。与 lib/index.js 同名常量保持一致。
4031
4726
  const WEB_TOOL_BILLING_START = Date.parse("2026-11-01T00:00:00+08:00");
4727
+ /** 官方自北京时间 2026-11-18 12:00 起取消「模型调用触发的服务端搜索与网页抓取」的
4728
+ * 工具费,改为只算 token。所以「¥5 / 千次」只对 11-01 ~ 11-18 这段历史有效;
4729
+ * 之后一律不计次(web_fetch 还是本地匿名 HTTP,本来就不经过 DeepSeek API)。 */
4730
+ const WEB_TOOL_FREE_FROM = Date.parse("2026-11-18T12:00:00+08:00");
4032
4731
  // 动效时长:**两态各算各的**(2026-10-31:「收起是收起 展开是展开 动画播放完了
4033
4732
  // 我还不能刷新」)。原来两态共用一个 900(取最大值),展开态白光只有 580ms,
4034
4733
  // 播完之后还要再被锁 320ms —— 用户点下去毫无反应,像卡住了。
@@ -4192,7 +4891,1436 @@ const CN_CALENDAR_SOURCES = [
4192
4891
  });
4193
4892
  }
4194
4893
 
4195
- function UsageStatsPanel({ onClose, panelRef, closing }) {
4894
+ // ─── 两个「上滑小窗」(2026-11-26)──────────────────────────────────────
4895
+ // 用户原话:
4896
+ // 「点击左侧的今日消耗可以上滑一个小窗显示那些对话消耗了多少钱」
4897
+ // 「点击时段条或者空闲时间可以上滑一个小窗显示对应时间线消耗了多少余额(用时间线来表示)」
4898
+ // 原来整行是一个热区(单击=统计面板),现在在 rowInteractions 里按 closest() 分流。
4899
+
4900
+ /** 金额格式化成 ¥x.xxxx:今日明细要看清「哪段对话更贵」,四位小数够用。 */
4901
+ function popMoney(n) {
4902
+ const v = Number(n);
4903
+ if (!Number.isFinite(v)) return "¥0.0000";
4904
+ return "¥" + v.toFixed(4);
4905
+ }
4906
+ /** 悬停金额:固定两位小数(2026-11-26 用户:「只显示到小数点后两位吧」)。
4907
+ * 之前按量级分 4/3/2 位,悬停扫过时位数反复跳、也没人看第四位。
4908
+ * ⚠️ 别改 popMoney 本身 —— 余额行、明细列表都用它,那些地方必须固定 4 位。 */
4909
+ function popMoneyTip(n) {
4910
+ const v = Number(n) || 0;
4911
+ return "¥" + v.toFixed(2);
4912
+ }
4913
+ /** token 数:1234567 → 1.23M,123456 → 123.5k,太小原样。 */
4914
+ function popTokens(n) {
4915
+ const v = Number(n) || 0;
4916
+ if (v >= 1000000) return (v / 1000000).toFixed(2) + "M";
4917
+ if (v >= 10000) return (v / 1000).toFixed(1) + "k";
4918
+ return String(Math.round(v));
4919
+ }
4920
+
4921
+ /** 小窗外壳:定位、三角、头部、Esc / 点外关闭都由它统一处理。
4922
+ * `anchorRect` 是被点那一块的 getBoundingClientRect(),小窗出现在它**上方**
4923
+ * (这就是「上滑」),上方放不下就翻到下面。左右夹在视口内并回填三角位置。 */
4924
+ function PopShell({ anchorRect, title, subtitle, onClose, children, wide, headExtra }) {
4925
+ const ref = react.useRef(null);
4926
+ const [box, setBox] = react.useState(null);
4927
+ const [closing, setClosing] = react.useState(false);
4928
+ // ⚠️ 关闭是**延迟**的(130ms 淡出),所以定时器必须能被取消,否则会出现
4929
+ // 「有时候点不开」:开着 → 点一下(mousedown 触发 requestClose,排了个 130ms 后的
4930
+ // onClose;同一次点击的 click 又把状态 toggle 成 null)→ 130ms 内再点一下想打开,
4931
+ // 状态确实变成 {rect} 了,**然后上一次那个定时器到点执行 onClose,把它关掉**
4932
+ // (2026-11-27 用户:「有时候点不开时段表」)。
4933
+ // 定时器存进 ref,组件卸载就清掉;重开时是新实例,旧定时器不会再打到新状态上。
4934
+ const closeTimerRef = react.useRef(null);
4935
+ const requestClose = react.useCallback(() => {
4936
+ setClosing(true);
4937
+ if (closeTimerRef.current !== null) clearTimeout(closeTimerRef.current);
4938
+ closeTimerRef.current = setTimeout(() => {
4939
+ closeTimerRef.current = null;
4940
+ onClose();
4941
+ }, 130);
4942
+ }, [onClose]);
4943
+ react.useEffect(() => () => {
4944
+ if (closeTimerRef.current !== null) {
4945
+ clearTimeout(closeTimerRef.current);
4946
+ closeTimerRef.current = null;
4947
+ }
4948
+ }, []);
4949
+ /** 量尺寸 → 算落点。抽出来是为了**能重复调**:
4950
+ * ① 首帧(usePrePaintEffect,paint 之前量,不闪);
4951
+ * ② 内容变了之后(ResizeObserver)—— 小窗里正文是异步的
4952
+ * (「正在加载」→ 一堆会话行),高度会变,不重算就会压住下面那一行。
4953
+ * ⚠️ 位置没变时必须返回同一个对象,否则 RO 回调 → setState → 重渲染 →
4954
+ * 尺寸变化 → RO 回调,转成死循环。 */
4955
+ const place = react.useCallback(() => {
4956
+ const el = ref.current;
4957
+ if (el == null) return;
4958
+ const vw = typeof window === "undefined" ? 1200 : window.innerWidth;
4959
+ const vh = typeof window === "undefined" ? 800 : window.innerHeight;
4960
+ const w = el.offsetWidth > 0 ? el.offsetWidth : Math.min(wide ? 498 : 330, vw - 20);
4961
+ const h = el.offsetHeight > 0 ? el.offsetHeight : 260;
4962
+ // ⚠️ `anchorRect` **允许为空**(2026-11-27:「这个小浮窗直接不显示了」)。
4963
+ // 点开时热区可能那一刻量不到矩形:`rectOf` 对 0×0 的元素返回 null,
4964
+ // 折叠中的侧栏、入场动画中途、刚切完会话的那一帧都会这样;
4965
+ // 调用处 `rectOf(el) ?? rectOf(event.currentTarget)` 两个都 null 就传进来 null。
4966
+ // 原来这里第一行是 `if (!anchorRect) return;` —— 于是 box 永远是 null、
4967
+ // 面板永远停在 left:-9999px + visibility:hidden,**看起来就是点了没反应**。
4968
+ // 那个成因当时没能向用户确证,所以不再赌任何一条路径:拿不到锚点就落在
4969
+ // 视口中部偏下,保证**只要组件渲染出来就一定可见、可读、可关**。
4970
+ const num = (v) => typeof v === "number" && Number.isFinite(v);
4971
+ const anchor = anchorRect != null && num(anchorRect.top) && num(anchorRect.bottom)
4972
+ && num(anchorRect.left) && num(anchorRect.width)
4973
+ ? anchorRect
4974
+ : { left: Math.round(vw / 2), width: 0, top: Math.round(vh * 0.62), bottom: Math.round(vh * 0.62) };
4975
+ // GAP 让开小三角(自身 11px、旋转后探出约 6px)+ 4px 呼吸。
4976
+ // 原来 10 太紧,内容一高就贴到 anchor 脸上。
4977
+ const GAP = 12;
4978
+ const wantTop = anchor.top - GAP - h;
4979
+ const above = wantTop >= 8;
4980
+ const top = above ? wantTop : Math.min(vh - h - 8, anchor.bottom + GAP);
4981
+ const cx = anchor.left + anchor.width / 2;
4982
+ const left = Math.max(8, Math.min(vw - w - 8, cx - w / 2));
4983
+ const next = {
4984
+ left: Math.round(left),
4985
+ top: Math.round(Math.max(8, top)),
4986
+ arrow: Math.round(Math.max(10, Math.min(w - 10, cx - left))),
4987
+ above,
4988
+ };
4989
+ setBox((prev) => (prev !== null
4990
+ && prev.left === next.left && prev.top === next.top
4991
+ && prev.arrow === next.arrow && prev.above === next.above
4992
+ ? prev : next));
4993
+ }, [anchorRect, wide]);
4994
+ usePrePaintEffect(() => { place(); return undefined; }, [place]);
4995
+ // 内容高度变化就重量一次(会话行数变、正文从「正在加载」变成列表……)
4996
+ react.useEffect(() => {
4997
+ const el = ref.current;
4998
+ if (el == null || typeof ResizeObserver !== "function") return undefined;
4999
+ const ro = new ResizeObserver(() => { place(); });
5000
+ ro.observe(el);
5001
+ const bodyEl = el.querySelector(".balance-pop__body");
5002
+ if (bodyEl) ro.observe(bodyEl);
5003
+ return () => ro.disconnect();
5004
+ }, [place]);
5005
+ // 窗口尺寸变了(拖窗口 / 侧栏折叠)也要重算,否则小窗会飘到视口外
5006
+ react.useEffect(() => {
5007
+ const onResize = () => place();
5008
+ window.addEventListener("resize", onResize);
5009
+ return () => window.removeEventListener("resize", onResize);
5010
+ }, [place]);
5011
+ react.useEffect(() => {
5012
+ const onKey = (e) => { if (e && e.key === "Escape") requestClose(); };
5013
+ const onDown = (e) => {
5014
+ const el = ref.current;
5015
+ if (el == null || e == null) return;
5016
+ if (el.contains(e.target)) return;
5017
+ // 点在**触发小窗的热区**上时,关闭交给同一轮 click 的 toggle 处理。
5018
+ // 否则 mousedown 先把 closing 置上(并排一个 130ms 的 onClose),click 再 toggle,
5019
+ // 两边各改一次状态 —— 连点时会互相打断,表现就是「有时候点不开」
5020
+ // (2026-11-27 用户反馈)。热区自身的 click 一定会紧跟 mousedown 到来,不会漏。
5021
+ if (typeof e.target.closest === "function"
5022
+ && (e.target.closest(".balance-footer__today") !== null
5023
+ || e.target.closest(".balance-footer__timeline-meta") !== null
5024
+ || e.target.closest(".balance-footer__timeline-track") !== null
5025
+ // 左下角金额胶囊:点它是“刷新余额”,不是“关弹窗”。不放白名单的话,
5026
+ // 一点先把弹窗关掉,看起来就像它自己没了(用户:「我点了下左下角就消失了」)。
5027
+ || e.target.closest(".balance-footer__value") !== null
5028
+ // 胶囊上面还盖着两层(擦除层 / 刷新白光层),点到它们也算点胶囊。
5029
+ || e.target.closest(".balance-footer__reveal") !== null
5030
+ || e.target.closest(".balance-footer__wave") !== null)) {
5031
+ return;
5032
+ }
5033
+ requestClose();
5034
+ };
5035
+ window.addEventListener("keydown", onKey);
5036
+ window.addEventListener("mousedown", onDown, true);
5037
+ return () => {
5038
+ window.removeEventListener("keydown", onKey);
5039
+ window.removeEventListener("mousedown", onDown, true);
5040
+ };
5041
+ }, [requestClose]);
5042
+ // ⚠️ 首帧(box === null)必须是**完整结构**,只差定位 ——
5043
+ // 原来只渲染 title,少了 subtitle 那一行,量出来的高度比真实矮 ~16px,
5044
+ // top 就少减了这 16px,小窗底边正好压住被点的那一行(2026-11-26 截图)。
5045
+ // visibility:hidden 仍然保留,所以这一帧看不到、也不会闪。
5046
+ const style = box === null
5047
+ ? { left: "-9999px", top: "-9999px", visibility: "hidden" }
5048
+ : { left: box.left + "px", top: box.top + "px", "--balance-pop-arrow": box.arrow + "px" };
5049
+ return jsx.jsx("div", {
5050
+ ref,
5051
+ className: "balance-pop" + (closing ? " balance-pop--closing" : "")
5052
+ + (box !== null && !box.above ? " balance-pop--below" : "")
5053
+ + (wide ? " balance-pop--wide" : ""),
5054
+ style,
5055
+ onMouseDown: (e) => e.stopPropagation(),
5056
+ children: [
5057
+ jsx.jsxs("div", {
5058
+ className: "balance-pop__head",
5059
+ children: [
5060
+ jsx.jsxs("div", {
5061
+ style: { minWidth: 0 },
5062
+ children: [
5063
+ jsx.jsx("h3", { className: "balance-pop__title", children: title }),
5064
+ subtitle ? jsx.jsx("p", { className: "balance-pop__sub", children: subtitle }) : null,
5065
+ ],
5066
+ }),
5067
+ // 右上角左侧的额外控件(目前只有时间线的「常显」开关)。
5068
+ headExtra ? jsx.jsx("div", { className: "balance-pop__head-extra", children: headExtra }) : null,
5069
+ jsx.jsx("button", {
5070
+ className: "balance-pop__close",
5071
+ type: "button",
5072
+ onClick: requestClose,
5073
+ "aria-label": "关闭",
5074
+ children: "×",
5075
+ }),
5076
+ ],
5077
+ }),
5078
+ jsx.jsx("div", { className: "balance-pop__body", children }),
5079
+ ],
5080
+ });
5081
+ }
5082
+
5083
+ /** 反推服务端 steps 的切分粒度(分钟)。
5084
+ *
5085
+ * 什么时候需要它:服务端**没给** `stepMin`(旧快照 / 旧服务端 / 某条 return 分支漏发字段),
5086
+ * 而 `step` 号本身又不可能自己说明单位 —— 把 3 分钟粒度的 step 当分钟读,
5087
+ * 一整天的消耗会全挤进前面几分之一,曲线陡升后拉成一条平线。
5088
+ * (2026-11-27 真踩:`readTodaySnapshot` 漏了 `stepMin`,5.8 小时的消耗被压进前 1.95 小时,
5089
+ * 用户原话「好像在加载 导致全集在前面了」。)
5090
+ *
5091
+ * 判据是**逐小时对账**:`hourly[i]` 是第 i 小时的钱、`steps` 是更细的同一份钱,
5092
+ * 按粒度 g 把每个 step 换算成时刻 `step*g` 分钟,落在第 i 小时内的那些加起来就该等于 `hourly[i]`。
5093
+ * 取让这个误差最小的 g。
5094
+ *
5095
+ * ⚠️ 别改成「看最后一个 step 落不落在最后一个有钱的小时里」—— 凌晨判不出来:
5096
+ * 00:30 时 1 分钟(step 30)和 3 分钟(step 10)都能落在第 0 小时里,两种都满足。
5097
+ * 对账用的是**全部 24 小时**的分布,凌晨也有区分度。
5098
+ *
5099
+ * 候选只放能整除 1440 的,且从小到大;误差相同取小的(宁可细一点,别把数据铺到明天去)。 */
5100
+ function inferStepMin(rows, byHour) {
5101
+ const CANDS = [1, 3, 5, 6, 10, 12, 15, 20, 30, 60];
5102
+ if (!Array.isArray(rows) || rows.length === 0) return 1;
5103
+ const hours = Array.isArray(byHour) ? byHour : [];
5104
+ const hourSum = hours.reduce((s, v) => s + (Number(v) || 0), 0);
5105
+ // hourly 也是空的(或全是 0)就没有对账的基准,只能按最细的来
5106
+ if (!(hourSum > 1e-9)) return 1;
5107
+ let best = 1;
5108
+ let bestErr = Infinity;
5109
+ for (const g of CANDS) {
5110
+ const per = new Array(24).fill(0);
5111
+ for (const r of rows) {
5112
+ const h = Math.floor((r.step * g) / 60);
5113
+ if (h >= 0 && h < 24) per[h] += r.cost;
5114
+ }
5115
+ let err = 0;
5116
+ for (let h = 0; h < 24; h += 1) err += Math.abs(per[h] - (Number(hours[h]) || 0));
5117
+ // 相对误差:额大的一天和额小的一天不能用同一个绝对值门槛
5118
+ const rel = err / hourSum;
5119
+ if (rel < bestErr - 1e-9) {
5120
+ bestErr = rel;
5121
+ best = g;
5122
+ }
5123
+ }
5124
+ return best;
5125
+ }
5126
+
5127
+ /** 今日各对话花了多少:按金额降序,末位单列插件自耗(同步费不属于任何会话)。 */
5128
+ function TodayBreakdown({ today, onClose, anchorRect, bare }) {
5129
+ const rows = react.useMemo(() => {
5130
+ const map = today && today.bySession && typeof today.bySession === "object" ? today.bySession : {};
5131
+ const titles = today && today.sessionTitles && typeof today.sessionTitles === "object" ? today.sessionTitles : {};
5132
+ const list = Object.keys(map).map((id) => {
5133
+ const rec = map[id] || {};
5134
+ return {
5135
+ id,
5136
+ title: typeof titles[id] === "string" && titles[id] !== "" ? titles[id] : "(未命名会话)",
5137
+ cost: Number(rec.cost) || 0,
5138
+ tokens: Number(rec.totalTokens) || 0,
5139
+ };
5140
+ });
5141
+ list.sort((a, b) => b.cost - a.cost);
5142
+ return list;
5143
+ }, [today]);
5144
+ // 父级分组栏的展开状态:`{ [父级目录名]: true }` 表示这一组**被收起**。
5145
+ // ⚠️ 只记「被点过」的组 → 新出现的组天然是展开的,不需要初始化。
5146
+ // ⚠️ hooks 必须都在第一个 return 之前(bare 分支在下面 60 行处 early return)。
5147
+ const [collapsedGroups, setCollapsedGroups] = react.useState({});
5148
+ const toggleGroup = react.useCallback((key) => {
5149
+ setCollapsedGroups((prev) => ({ ...prev, [key]: prev[key] !== true }));
5150
+ }, []);
5151
+ // ─── 行的悬停提示(自绘,不用原生 title)──────────────────────────────
5152
+ // 会话行悬停显示**完整标题 + 会话 ID**(2026-11-27 用户:「我说的小浮窗是
5153
+ // 鼠标悬停时显示的码」—— 就是那个 UUID);「插件同步 / 网页工具」悬停显示口径解释。
5154
+ // 位置放在行**下方**、左对齐再夹进视口:行宽就是整个面板,居中对齐会把提示
5155
+ // 甩到面板正中、跟鼠标离得很远。快到窗口底部时翻到行的上方。
5156
+ const [rowTip, setRowTip] = react.useState(null);
5157
+ const showRowTip = react.useCallback((event, title, sub) => {
5158
+ const el = event && event.currentTarget;
5159
+ if (el == null || typeof el.getBoundingClientRect !== "function") return;
5160
+ const r = el.getBoundingClientRect();
5161
+ const vw0 = typeof window === "undefined" ? 1200 : window.innerWidth;
5162
+ const vh0 = typeof window === "undefined" ? 800 : window.innerHeight;
5163
+ const above = r.bottom + 6 > vh0 - 56;
5164
+ setRowTip({
5165
+ title,
5166
+ sub: sub || "",
5167
+ above,
5168
+ top: above ? Math.max(8, r.top - 6) : r.bottom + 6,
5169
+ left: Math.max(8, Math.min(vw0 - 348, r.left)),
5170
+ });
5171
+ }, []);
5172
+ const hideRowTip = react.useCallback(() => setRowTip(null), []);
5173
+ // 父级(会话所在的项目目录):服务端给 `{ [会话键]: { key, label } }`。
5174
+ // 取不到就整表平铺 —— 分组只是展示,缺信息不该影响金额。
5175
+ const parents = today && today.sessionParents && typeof today.sessionParents === "object"
5176
+ ? today.sessionParents
5177
+ : {};
5178
+ /** 按父级归组,并保持「金额降序」这个原有次序:组的次序 = 组内最贵那条的次序。 */
5179
+ const groups = react.useMemo(() => {
5180
+ const list = [];
5181
+ const byKey = new Map();
5182
+ for (const r of rows) {
5183
+ const p = parents[r.id];
5184
+ // ⚠️ 拿不到父级的会话**各自成组**(key 带上自己的 id),不能都塞进同一个 "" 组:
5185
+ // 不然两个无主会话会被当成「同一父级」收进一个折叠栏里,那个栏的名字还没法起。
5186
+ const key = p != null && typeof p.key === "string" && p.key !== "" ? p.key : "?" + r.id;
5187
+ let g = byKey.get(key);
5188
+ if (g === undefined) {
5189
+ g = {
5190
+ key,
5191
+ label: p != null && typeof p.label === "string" ? p.label : "",
5192
+ rows: [],
5193
+ cost: 0,
5194
+ };
5195
+ byKey.set(key, g);
5196
+ list.push(g);
5197
+ }
5198
+ g.rows.push(r);
5199
+ g.cost += r.cost;
5200
+ }
5201
+ return list;
5202
+ }, [rows, parents]);
5203
+ /** 一条会话行。nested=true 时缩进,挂在组头下面。 */
5204
+ const sessionRow = (r, nested) => jsx.jsxs("div", {
5205
+ className: "balance-pop__row" + (nested === true ? " balance-pop__row--nested" : ""),
5206
+ // 悬停给完整标题 + 会话 ID:标题在行内被 ellipsis 截掉时,这里是唯一看全的地方
5207
+ onMouseEnter: (event) => showRowTip(event, r.title, r.id),
5208
+ onMouseLeave: hideRowTip,
5209
+ children: [
5210
+ jsx.jsx("span", { className: "balance-pop__swatch" }),
5211
+ jsx.jsx("span", { className: "balance-pop__name", children: r.title }),
5212
+ jsx.jsx("span", { className: "balance-pop__meta", children: popTokens(r.tokens) }),
5213
+ jsx.jsx("span", { className: "balance-pop__amount", children: popMoney(r.cost) }),
5214
+ ],
5215
+ }, r.id);
5216
+ // 一个父级下只有**一个**会话时不画组头 —— 多一层壳只是噪音,平铺更好读。
5217
+ // 两个以上才折叠:组头写父级名 + 会话数 + 该组合计,点一下收起 / 展开。
5218
+ const groupNodes = groups.map((g) => {
5219
+ if (g.rows.length <= 1) return sessionRow(g.rows[0], false);
5220
+ const open = collapsedGroups[g.key] !== true;
5221
+ return jsx.jsxs("div", {
5222
+ className: "balance-pop__group-block",
5223
+ children: [
5224
+ jsx.jsxs("div", {
5225
+ className: "balance-pop__group" + (open ? " balance-pop__group--open" : ""),
5226
+ role: "button",
5227
+ tabIndex: 0,
5228
+ onClick: () => toggleGroup(g.key),
5229
+ onKeyDown: (e) => {
5230
+ if (e && (e.key === "Enter" || e.key === " ")) {
5231
+ if (typeof e.preventDefault === "function") e.preventDefault();
5232
+ toggleGroup(g.key);
5233
+ }
5234
+ },
5235
+ children: [
5236
+ jsx.jsx("span", { className: "balance-pop__group-caret" }),
5237
+ jsx.jsx("span", {
5238
+ className: "balance-pop__group-name",
5239
+ children: g.label !== "" ? g.label : "其他会话",
5240
+ }),
5241
+ jsx.jsx("span", {
5242
+ className: "balance-pop__group-meta",
5243
+ children: g.rows.length + " 个会话 · " + popMoney(g.cost),
5244
+ }),
5245
+ ],
5246
+ }),
5247
+ open ? g.rows.map((r) => sessionRow(r, true)) : null,
5248
+ ],
5249
+ }, "g:" + g.key);
5250
+ });
5251
+ const pluginCost = Number(today && today.pluginCost) || 0;
5252
+ const pluginCalls = Number(today && today.pluginCalls) || 0;
5253
+ // 网页工具费:同样不在任何会话账上。不单列的话「合计 − 会话 − 同步」会剩一截
5254
+ // 没头没尾的差额,看起来就像数据没刷新(2026-11-27 用户:「怎么显示有延迟」)。
5255
+ const webCost = Number(today && today.webToolCost) || 0;
5256
+ const webCalls = (Number(today && today.webSearchCalls) || 0) + (Number(today && today.webFetchCalls) || 0);
5257
+ const total = Number(today && today.cost) || 0;
5258
+ const sessionTotal = rows.reduce((s, r) => s + r.cost, 0);
5259
+ const subtitle = rows.length + " 个会话 · 合计 " + popMoney(total)
5260
+ + "(会话 " + popMoney(sessionTotal)
5261
+ + (pluginCost > 0 ? " + 同步 " + popMoney(pluginCost) : "")
5262
+ + (webCost > 1e-9 ? " + 工具 " + popMoney(webCost) : "") + ")";
5263
+ const body = rows.length === 0 && pluginCost <= 0
5264
+ ? jsx.jsx("div", { className: "balance-pop__empty", children: "今天还没有消耗" })
5265
+ : jsx.jsxs("div", {
5266
+ // ⚠️ 2026-11-27 用户:「每行显示两个」—— 会话行改成**两列网格**,一屏能多看几条。
5267
+ // 只有「单会话、无组头」的裸会话行才占一格;组头块和下面两条整行计费项
5268
+ // (插件同步 / 网页工具)都靠 CSS `grid-column:1/-1` 横跨整行。
5269
+ // `--one`:今天只有一条会话时让它独占整行,别留半格空白。
5270
+ className: "balance-pop__grid" + (rows.length <= 1 ? " balance-pop__grid--one" : ""),
5271
+ children: [
5272
+ // ⚠️ 这里原来是直接 `rows.map(...)` 平铺。现在改成分组节点:
5273
+ // 同一父级(项目目录)下有多个会话时,先出一行可展开 / 收起的组头,
5274
+ // 组内会话行缩进挂在下面(2026-11-27 用户:「如果父级是一样的
5275
+ // 添加一个展开和收起的栏」)。只有一个会话的父级不画组头。
5276
+ // 会话行本身用 `sessionRow()` 生成,别在 JSX 里再内联一份 ——
5277
+ // 两处渲染同一个行结构,改一处漏一处的坑踩过。
5278
+ groupNodes,
5279
+ // ⚠️ **顺序:网页工具在前、插件同步收尾**(2026-11-27 用户:「插件同步计费默认最低端」)
5280
+ // ——「最低端」是**位置**,不是价格档。原来插件同步在前、网页工具在后,
5281
+ // 两者都在时插件同步就成了倒数第二,和「末位单列插件自耗」的约定不符。
5282
+ // 插件同步是今天所有会话之外的最后一笔(插件自己烧的),放最底下一眼能扫到。
5283
+ webCost > 1e-9
5284
+ ? jsx.jsxs("div", {
5285
+ className: "balance-pop__row balance-pop__row--full",
5286
+ // 原来这里也有原生 title(解释按次计费),同一天被删干净了;
5287
+ // 现在改自绘提示。
5288
+ onMouseEnter: (event) => showRowTip(event, "网页工具",
5289
+ "网页搜索 / 网页抓取按次计费,¥0.005 / 次,不乘峰谷倍率"),
5290
+ onMouseLeave: hideRowTip,
5291
+ children: [
5292
+ jsx.jsx("span", { className: "balance-pop__swatch balance-pop__swatch--web" }),
5293
+ jsx.jsx("span", { className: "balance-pop__name", children: "网页工具" }),
5294
+ jsx.jsx("span", { className: "balance-pop__meta", children: webCalls + " 次" }),
5295
+ jsx.jsx("span", { className: "balance-pop__amount", children: popMoney(webCost) }),
5296
+ ],
5297
+ }, "__web")
5298
+ : null,
5299
+ pluginCost > 0
5300
+ ? jsx.jsxs("div", {
5301
+ className: "balance-pop__row balance-pop__row--full",
5302
+ // 「N 次」是**模型调用次数**,不是「你点了几次同步」(2026-11-27 用户:
5303
+ // 「为什么我点一次同步它算两次」)。节假日同步按年份循环,补几年就调几次模型:
5304
+ // 11 月之后要补「今年 + 明年」两年 → 点一次 = 2 次调用 = 2 笔 token。
5305
+ // 价格同步是一次抓取 + 最多一次模型解析,所以通常只记 1 次。
5306
+ // ⚠️ 这段解释原来在**原生 title** 里(灰框、不跟主题),2026-11-27 先被删干净、
5307
+ // 用户随即报「这个小浮窗直接不显示了」—— 现在改成自绘提示(showRowTip)。
5308
+ onMouseEnter: (event) => showRowTip(event, "插件同步",
5309
+ "「N 次」是模型调用次数:节假日按年份逐年调模型,11 月前后要补今年 + 明年,点一次会记 2 次"),
5310
+ onMouseLeave: hideRowTip,
5311
+ children: [
5312
+ jsx.jsx("span", { className: "balance-pop__swatch balance-pop__swatch--plugin" }),
5313
+ jsx.jsx("span", { className: "balance-pop__name", children: "插件同步" }),
5314
+ jsx.jsx("span", { className: "balance-pop__meta", children: pluginCalls + " 次调用" }),
5315
+ jsx.jsx("span", { className: "balance-pop__amount", children: popMoney(pluginCost) }),
5316
+ ],
5317
+ }, "__plugin")
5318
+ : null,
5319
+ ],
5320
+ });
5321
+ // 悬停提示挂 portal:面板 overflow:hidden,贴行下方渲染会被裁掉。
5322
+ // createPortal 不是 hook,放在 early return 之前之后都安全。
5323
+ const rowTipNode = rowTip === null || typeof document === "undefined"
5324
+ ? null
5325
+ : createPortal(jsx.jsx("div", {
5326
+ className: "balance-pop__code-tip" + (rowTip.above ? " balance-pop__code-tip--above" : ""),
5327
+ style: { top: rowTip.top + "px", left: rowTip.left + "px" },
5328
+ role: "tooltip",
5329
+ children: [
5330
+ jsx.jsx("span", { className: "balance-pop__code-tip-title", children: rowTip.title }),
5331
+ rowTip.sub !== ""
5332
+ ? jsx.jsx("span", { className: "balance-pop__code-tip-sub", children: rowTip.sub })
5333
+ : null,
5334
+ ],
5335
+ }), document.body);
5336
+ // bare:只给内容,不套弹窗壳 —— 合并进「今日消耗时间线」那个面板时用
5337
+ // (2026-11-27 用户:「这两个浮窗合并吧 然后这两个选中改成整体」)。
5338
+ // ⚠️ 必须排在 useMemo 之后:这里 early return,hook 一条都不能漏在前面。
5339
+ // ⚠️ bare 模式也要渲染 subtitle。它写的是「N 个会话 · 合计 ¥x(会话 ¥a + 同步 ¥b)」,
5340
+ // 正是用来解释「累计」和下面几行会话合计之间的差额的。
5341
+ // 少了这一行,用户只会看到累计 ¥2.1399 而明细只加到 ¥2.1250,看着就像
5342
+ // 「插件同步的数据没跟上」(2026-11-27 用户:「这个插件同步的怎么显示有延迟」)。
5343
+ if (bare === true) {
5344
+ return jsx.jsxs("div", {
5345
+ children: [
5346
+ subtitle
5347
+ ? jsx.jsx("p", {
5348
+ className: "balance-pop__sub balance-pop__sub--inline",
5349
+ children: subtitle,
5350
+ })
5351
+ : null,
5352
+ body,
5353
+ rowTipNode,
5354
+ ],
5355
+ });
5356
+ }
5357
+ return jsx.jsx(PopShell, {
5358
+ anchorRect,
5359
+ title: "今日消耗明细",
5360
+ subtitle,
5361
+ onClose,
5362
+ children: [body, rowTipNode],
5363
+ });
5364
+ }
5365
+
5366
+ /** 今日余额时间线:从「今日起始余额」一路降到当前余额,按小时采样。
5367
+ * 起始余额 = 当前余额 + 今日已消耗(反推),所以曲线终点必然落在当前余额上。 */
5368
+ /** 今日**累计消耗**时间线:从 0 一路涨到此刻花了多少(2026-11-26 用户:
5369
+ * 「时间线改成消费的吧」)。原来是余额下降曲线,反推出的起点不够直观,
5370
+ * 而且要先知道余额才能画;改成累计消费后纵轴就是「今天花了多少钱」,自洽。
5371
+ * ⚠️ 金额一律不放图里:小卡片里 SVG 会缩放,`text` 跟着缩,
5372
+ * 一长就挤成一团(用户截图「右上角数字被挡住了」)。金额全走 header 副标题。 */
5373
+ function BalanceTimeline({ today, balance, onClose, anchorRect }) {
5374
+ // ⚠️ 所有 hook 必须排在任何一个 return 之前。
5375
+ // clipId 原来写在「!model.ok 早退」之后:首次渲染 today 还是 null 只跑 1 个 hook,
5376
+ // today 到位后变成 2 个 → React 抛 "Rendered more hooks than during the previous render"
5377
+ // → 整棵组件树挂掉,左下角余额胶囊直接消失(2026-11-26 用户:「bug了 左下角没了」)。
5378
+ const clipId = react.useMemo(() => "balance-pop-clip-" + Math.random().toString(36).slice(2, 9), []);
5379
+ // 鼠标位置的悬停态:{ hour, acc, cost, label }。和 clipId 一样必须排在早退之前。
5380
+ const [hover, setHover] = react.useState(null);
5381
+ // 常显开关(2026-11-27 用户:「在这里添加一个小开关 是否要常显的功能」)。
5382
+ // ⚠️ 存 localStorage、不走插件设置文件:这是纯展示偏好,
5383
+ // 新版本覆盖安装、设置默认值重写都不会改变它(用户:
5384
+ // 「这个功能不跟随插件变动」)。默认开。
5385
+ // 胶囊上一次停在哪个小时:用来算归位动画的时长。
5386
+ // ⚠️ ref 必须和其他 hook 一起排在「if (!model.ok)」之前。
5387
+ // ⚠⚠ 初值只能是常量:这里离 nowHour(约 5180 行)还很远,
5388
+ // 写 nowHour 会撞 TDZ —— const 声明前引用直接 ReferenceError,
5389
+ // BalanceTimeline 一渲染就崩,整个下左角点不开(2026-11-27 用户:
5390
+ // 「现在完全点不开了」)。-1 = 还没定过位。
5391
+ const lastTipHourRef = react.useRef(-1);
5392
+ const [tipAlways, setTipAlwaysBase] = react.useState(() => {
5393
+ try { return localStorage.getItem("balance-tip-always") !== "0"; } catch { return true; }
5394
+ });
5395
+ const setTipAlways = react.useCallback(() => {
5396
+ setTipAlwaysBase((v) => {
5397
+ const next = !v;
5398
+ try { localStorage.setItem("balance-tip-always", next ? "1" : "0"); } catch { /* 私有模式下忽略 */ }
5399
+ return next;
5400
+ });
5401
+ }, []);
5402
+ // y 轴换档的缩放起点(上一档 / 这一档:¥1→¥2 是 .5,¥2→¥5 是 .4)。
5403
+ // ⚠️ 必须和 clipId / hover 一样排在 model.ok 早退**之前**:
5404
+ // 首次渲染 today 还是 null、只跑到早退,数据一到又多出这两个 hook,
5405
+ // React 会抛 Rendered more hooks than during the previous render,
5406
+ // 整个小窗连图表一起消失。这个坑已经踩过两次了。
5407
+ // ── 个人调试:时间加快,直接看挡位缩放动画──
5408
+ // 开关:控制台执行 localStorage.setItem("balance-debug-zoom", "1") 后刷新;
5409
+ // 关 回去用 removeItem。也认 window.__balanceDebugZoom = true。
5410
+ // 开了之后 y 轴上界每 1.6 秒在这几档之间跳,动画连着播,
5411
+ // 不用真等金额涨到跳档。不影响真实数据。
5412
+ const [debugTick, setDebugTick] = react.useState(0);
5413
+ const debugZoom = react.useMemo(() => {
5414
+ try {
5415
+ if (typeof window !== "undefined" && window.__balanceDebugZoom === true) return true;
5416
+ return localStorage.getItem("balance-debug-zoom") === "1";
5417
+ } catch { return false; }
5418
+ }, []);
5419
+ react.useEffect(() => {
5420
+ if (!debugZoom) return undefined;
5421
+ const t = setTimeout(() => setDebugTick((n) => n + 1), 1600);
5422
+ return () => clearTimeout(t);
5423
+ }, [debugZoom, debugTick]);
5424
+ const prevMaxYRef = react.useRef(0);
5425
+ react.useEffect(() => { prevMaxYRef.current = maxY; });
5426
+ const model = react.useMemo(() => {
5427
+ const hourly = Array.isArray(today && today.hourly) ? today.hourly : [];
5428
+ if (hourly.length === 0) {
5429
+ return {
5430
+ ok: false,
5431
+ reason: today == null ? "正在加载今日数据…" : "这一版服务端还没返回按小时的用量,重启 DSH 后可用",
5432
+ };
5433
+ }
5434
+ // ⚠️ 不能拿数组下标当小时。buildHourlySlots 现在是铺满 24 格的密集数组,
5435
+ // 但快照里的旧数据不一定 —— 一律按 slot.hour 归位,缺的小时补 0。
5436
+ const byHour = new Array(24).fill(0);
5437
+ for (const slot of hourly) {
5438
+ const h = Number(slot && slot.hour);
5439
+ if (!Number.isInteger(h) || h < 0 || h > 23) continue;
5440
+ byHour[h] += Number(slot && slot.cost) || 0;
5441
+ }
5442
+ // 分钟级粒度(服务端 byStep):钱**真正发生在哪一格**就落在哪一格。
5443
+ // 原来只有 hourly,只能把整小时的量平均摊成 12 段 —— 长时间没动、10:11 突然花一笔,
5444
+ // 摊完就成了「10:00 起匀速爬坡」,和事实不符
5445
+ // (2026-11-27 用户:「有的时候不用平摊 比如 我很长时间没用 但是在10:11分产生消耗
5446
+ // 就要指定在这个时间段」)。有 steps 就按它落位,没有才退回平摊。
5447
+ // ⚠️ 粒度**以服务端为准**(响应里的 `stepMin`),不写死。2026-11-27 服务端从 1 分钟
5448
+ // 改成 3 分钟(用户:「改成3分钟粒度吧 减轻性能开销」,折线点数 1441 → 481),
5449
+ // 但如果只刷新页面、没重启 DSH,服务端还是旧的 1 分钟 —— 写死 3 会让每一笔
5450
+ // 三倍错位(第 100 分钟的钱跑到第 300 分钟)。
5451
+ // ⚠️ 但**读不到也不能一律按 1 分钟**:服务端的快照路径(readTodaySnapshot)一度漏发
5452
+ // `stepMin`,于是 3 分钟粒度的 step 0~116 被当成「第 0~116 分钟」,
5453
+ // 5.8 小时的消耗全挤进前 1.95 小时 → 曲线陡升后拉成一条平线
5454
+ // (2026-11-27 用户:「好像在加载 导致全集在前面了」)。
5455
+ // 所以读不到就**反推**:拿 steps 按候选粒度铺开,跟 hourly 逐小时对账,取最吻合的那个。
5456
+ const stepMinRaw = Math.round(Number(today && today.stepMin));
5457
+ const rawSteps = (Array.isArray(today && today.steps) ? today.steps : [])
5458
+ .map((it) => ({ step: Math.floor(Number(it && it.step)), cost: Number(it && it.cost) || 0 }))
5459
+ .filter((r) => Number.isInteger(r.step) && r.step >= 0 && Math.abs(r.cost) >= 1e-12);
5460
+ const STEP_MIN = stepMinRaw > 0 && 1440 % stepMinRaw === 0
5461
+ ? stepMinRaw
5462
+ : inferStepMin(rawSteps, byHour);
5463
+ const STEPS_PER_HOUR = Math.round(60 / STEP_MIN);
5464
+ const STEPS = STEPS_PER_HOUR * 24;
5465
+ const stepCost = new Array(STEPS).fill(0);
5466
+ let hasStepData = false;
5467
+ for (const r of rawSteps) {
5468
+ if (r.step >= STEPS) continue;
5469
+ stepCost[r.step] += r.cost;
5470
+ hasStepData = true;
5471
+ }
5472
+ // 差额**按比例**摊到有消耗的小时上:hourly 只统计会话消耗,今日总额里还有同步费用
5473
+ // 这类没记到小时上的钱,不摊的话 hover 到 23:00 的累计会永远比副标题那行「累计 ¥x」少一截。
5474
+ // ⚠️ 绝不能按时钟线性摊(之前那版就是):那样没消耗的小时也会凭空冒出钱,
5475
+ // 05:08 显示「本小时 ¥0.0028」,一点参考意义都没有
5476
+ // (2026-11-26 用户:「如果没有实际消耗的 就不要计算值了 有问题 我要的是仅供参考」)。
5477
+ // 按比例缩放的三个好处:形状不变、总和等于今日总额、0 消耗的小时恒为 0。
5478
+ const dayTotal = Number(today && today.cost) || 0;
5479
+ const hourlySum = byHour.reduce((s, v) => s + v, 0);
5480
+ const scale = hourlySum > 1e-9 && dayTotal > hourlySum + 1e-9 ? dayTotal / hourlySum : 1;
5481
+ let acc = 0;
5482
+ const pts = [{ at: 0, acc: 0 }];
5483
+ if (hasStepData) {
5484
+ // 每一格按**自己的**真实金额累加,不做任何平摊。
5485
+ // ⚠️ 2026-11-27 删掉了原来那条「该小时有 ≥20 格非零就整小时均分」的分支
5486
+ // (用户:「某个时间段突然用的很多 然后某个时间段突然不怎么用了 他应该是呈现一个坡的
5487
+ // 平摊机制是不是会补这个坡」—— 会,那个坡会被抹成匀速直线。实测 05:00 那一小时
5488
+ // 中途差 ¥1.22,占该小时 41%)。那条判据本身是反的:密的时候每格本来就有值、
5489
+ // 连线自然成坡,不需要摊;疏的时候恰恰是「孤立台阶」,而它反而走精确分支。
5490
+ // 差额仍**按比例**放大到有消耗的格上(同步费这类钱没有时刻归属),
5491
+ // 等比缩放不改形状,没消耗的格恒为 0。
5492
+ const stepSum = stepCost.reduce((s, v) => s + v, 0);
5493
+ const stepScale = stepSum > 1e-9 && dayTotal > stepSum + 1e-9 ? dayTotal / stepSum : 1;
5494
+ for (let k = 0; k < STEPS; k += 1) {
5495
+ acc += stepCost[k] * stepScale;
5496
+ pts.push({ at: ((k + 1) * STEP_MIN) / 60, acc });
5497
+ }
5498
+ } else {
5499
+ // 服务端没给 steps(旧版本 / 旧快照 / 粒度对不上):退回整小时平摊。
5500
+ // ⚠️ 它同样不会补没用的时段:byHour[没消耗的小时] = 0,摊 0 还是 0。
5501
+ for (let k = 0; k < STEPS; k += 1) {
5502
+ acc += (byHour[Math.floor(k / STEPS_PER_HOUR)] * scale) / STEPS_PER_HOUR;
5503
+ pts.push({ at: ((k + 1) * STEP_MIN) / 60, acc });
5504
+ }
5505
+ }
5506
+ // ⚠️ 累计终值不能小于今日总额。hourly 全空但 today.cost 有钱的时候
5507
+ // (新的一天刚开、分小时数据还没写进来,或者钱全在 pluginCost 上),
5508
+ // byHour 全是 0 ⇒ acc 恒 0,副标题就会显示「累计 ¥0.0000 · 今天还没有消耗」,
5509
+ // 而实际上有消耗 —— 用户看到的就是「怎么看不到消耗」(2026-11-26)。
5510
+ // 曲线仍然按真实 acc 画(没数据就是贴底的虚线),只有这个标量兜底。
5511
+ const total = Math.max(acc, dayTotal);
5512
+ // 纵轴上界:至少 1 分钱,免得今天零消耗时除 0。
5513
+ // 上界 = 总额**向上取到「还没到的下一级刻度」**,只多抬这一级
5514
+ // (2026-11-27 用户:「不用全显示 刚刚那样挺好的 没到就先别显示 只显示没到的下一级」)。
5515
+ // ¥3.74 → ¥4 → 刻度 1/2/3/4(3.74 已过 3,下一级是 4)
5516
+ // ¥5.00 → ¥5 → 刻度 1..5
5517
+ // ¥5.50 → ¥10 → 5~20 这一档每 5,下一级就是 10,中间没有 6/7/8/9
5518
+ // 早前那版直接抬到档位「边界」(¥3.74 → ¥5),等于把没到的两级也画出来,太满。
5519
+ // ⚠️ 50 以上**每 50 一档**(2026-11-27 用户:「超过50应该就显示100 往后就是50 50的刻度了」)。
5520
+ // 早前是每 100 一档(100/200/300),¥120 会被抬到 ¥200 —— 上面一半是空的,
5521
+ // 曲线整天贴在中线以下。现在 ¥120 → ¥150,只多抬一档。
5522
+ // 边界对齐:t=50 走上一档(return 50);t=50.01 → 100;t=100 → 100;t=101 → 150。
5523
+ // 没有硬性天花板 —— t 多大就抬到多少,只是步长固定 50。
5524
+ const maxY = (() => {
5525
+ const t = total > 1e-9 ? total : 0.01;
5526
+ if (t <= 5) return Math.ceil(t);
5527
+ if (t <= 20) return Math.ceil(t / 5) * 5;
5528
+ if (t <= 50) return Math.ceil(t / 10) * 10;
5529
+ return Math.ceil(t / 50) * 50;
5530
+ })();
5531
+ return { ok: true, pts, total, maxY, hourly: byHour, scale, STEP_MIN, STEPS_PER_HOUR, STEPS, activeHours: byHour.filter((v) => v > 0).length };
5532
+ }, [today]);
5533
+ // ⚠️ 必须在 model 之后(读它的字段)、但在 model.ok 早退之前。
5534
+ // 上一版插在了另一个 useMemo 后面,model 还在临时性死区 →
5535
+ // 一点左下角就崩(用户:「又崩了」)。
5536
+ const DEBUG_MAX_Y = [2, 5, 10, 20, 50, 12, 4];
5537
+ const targetMaxY = model.ok ? (debugZoom ? DEBUG_MAX_Y[debugTick % DEBUG_MAX_Y.length] : model.maxY) : 0;
5538
+ // ── 逐帧插值纵轴上限 ──
5539
+ // ⚠️ 必须排在 model.ok 早退**之前**:否则首次渲染(数据还没到)
5540
+ // 这两个 hook 不跑,数据一到突然多跑两个 → Rendered more hooks than
5541
+ // during the previous render,整个图直接崩(2026-11-27 用户:「bug了」)。
5542
+ const [animMaxY, setAnimMaxY] = react.useState(0);
5543
+ // y 轴数字的滚入动画开关:**首次挂载(打开浮窗)不播**,
5544
+ // 只有金额上界真的换档(缩放)时才允许。
5545
+ // 不这样阻一下的话,CSS 动画会在每次新节点挂载时自动播放。
5546
+ const [labelAnim, setLabelAnim] = react.useState(false);
5547
+ const prevLabelMaxRef = react.useRef(targetMaxY);
5548
+ react.useEffect(() => {
5549
+ const to = targetMaxY;
5550
+ if (to <= 1e-9) return undefined;
5551
+ const from = animMaxY > 1e-9 ? animMaxY : to;
5552
+ if (Math.abs(from - to) < 1e-9) { if (animMaxY !== to) setAnimMaxY(to); return undefined; }
5553
+ const STEPS = 20;
5554
+ let i = 0;
5555
+ let timer = null;
5556
+ const tick = () => {
5557
+ i += 1;
5558
+ const t = i / STEPS;
5559
+ const e = 1 - Math.pow(1 - t, 3); // ease-out,不过冲
5560
+ setAnimMaxY(i >= STEPS ? to : from + (to - from) * e);
5561
+ if (i < STEPS) timer = setTimeout(tick, 26);
5562
+ };
5563
+ timer = setTimeout(tick, 26);
5564
+ return () => clearTimeout(timer);
5565
+ }, [targetMaxY]);
5566
+ // 档位(targetMaxY)真的变了才把数字动画开着;一开就一直开,
5567
+ // 后续靠 key 重挂触发播放。首次挂载时两者相等,不会置 true。
5568
+ react.useEffect(() => {
5569
+ if (prevLabelMaxRef.current === targetMaxY) return;
5570
+ prevLabelMaxRef.current = targetMaxY;
5571
+ setLabelAnim(true);
5572
+ }, [targetMaxY]);
5573
+ // 实际用的上限:插值中用插值值,否则用目标值。
5574
+ // ⚠️ 必须在 animMaxY 之后(上一版在前面 → TDZ)。
5575
+ const maxY = animMaxY > 1e-9 ? animMaxY : (targetMaxY || 1);
5576
+ if (!model.ok) {
5577
+ return jsx.jsx(PopShell, {
5578
+ anchorRect,
5579
+ title: "今日消耗时间线",
5580
+ subtitle: "0:00 → 现在",
5581
+ onClose,
5582
+ children: jsx.jsx("div", { className: "balance-pop__empty", children: model.reason }),
5583
+ });
5584
+ }
5585
+ // W 跟着卡片 498 走(内容宽 ~474),别留太多缩放,1px 线会发虚;
5586
+ // 加宽是为了让「每小时 60 分钟」在横轴上真的分得开(2026-11-27 用户:
5587
+ // 「每小时拆成60份 然后可以拉长一点 显示的全一点」)。
5588
+ const W = 494;
5589
+ // 高度:色块 494 宽。
5590
+ // 124 是「太高了」那版(2.7:1 偏方),100 是更早「扁得厉害」那版(3.5:1)。
5591
+ // 高度 116 → 128(2026-11-27):上面多出来的 12px 给纵轴最顶一档刻度。
5592
+ // 原来 PAD_T = 6,顶档(maxY)的 baseline 只能在 11,11px 字的顶部落在 2px:
5593
+ // 几乎贴着 SVG 上沿,看上去就是「最顶上的刻度被切了一半」
5594
+ // (2026-11-27 用户两次:「最顶上的刻度」「顶上还是这样啊」)。
5595
+ // 128 → 144(2026-11-27 用户:「适当的拉高一点折线图呢」):128 的**绘图区**
5596
+ // 只有 82px(H − FRAME_T 2 − FRAME_B 16 − INSET_Y 28),一天的累计坡挤在
5597
+ // 一条窄带里,坡度和拐点都看不出来。加 16px 后绘图区 98px(+20%),
5598
+ // 高宽比 3.86:1 → 3.43:1。别再往上走 —— 那会踩回「太高了」那版的老印象。
5599
+ // ⚠️ 只有 viewBox 用它("0 0 W H"),SVG 自带等比缩放,改这一个数就够。
5600
+ const H = 144;
5601
+ // 2026-11-26 用户:「外面的框不要了」—— 只剩带圆角的色带本身,
5602
+ // FRAME 现在只表示「绘图区到 SVG 边缘的留白」,不再画任何边框。
5603
+ const FRAME_L = 2;
5604
+ const FRAME_T = 2;
5605
+ const FRAME_R = 2;
5606
+ const FRAME_B = 16; // 下面留给坐标轴
5607
+ const FRAME_W = W - FRAME_L - FRAME_R;
5608
+ const FRAME_H = H - FRAME_T - FRAME_B;
5609
+ // 横向留白由两端刻度定:去掉外框之后色块就是最外层,
5610
+ // 「0:00」「24:00」这两个标签得完整落在可见区里(2026-11-26 用户:
5611
+ // 「保证0点1分和23点59分显示全就行了 可以多一点点 为了显示清除」)。
5612
+ // 16 + 4 让两端标签各留出 ~16px,label 不会贴到卡片边缘。
5613
+ // ⚠️ 26 不是 16:这里同时要容下左侧的金额刻度。
5614
+ // 刻度是 textAnchor="end" 贴在 x = PAD_L - 2,「¥15」在 11px 字下宽约 23px,
5615
+ // 16 只够「¥5」(约 17px)—— 多一位就从画布左边被裁掉。
5616
+ // 用户截图里「¥15」只剩一半,看上去就是「顶部刻度看不清」
5617
+ // (2026-11-27 用户:「顶部的刻度」)。
5618
+ // 26 → 34(2026-11-27):纵轴上界改成「>50 每 50 一档」之后,三位数刻度
5619
+ // (¥100 / ¥150 / ¥200)变成常态,而「¥150」约 29px、「¥200」约 27px,
5620
+ // 26 的留白仍然会把 ¥ 削掉一截(预览图里 ¥200 看着像 £200)。
5621
+ // 34 = 29px 字宽 + 右端 x=32 上留 3px 肉;¥200 左端落在 7px、¥150 落在 5px。
5622
+ const INSET_X = 34;
5623
+ // 上下内缩不对称已不可行:下面要留给时间轴,上面要留给顶档刻度。
5624
+ // 14 让 PAD_T = 16,顶档 baseline 落在 19 左右,字顶离上沿 ~11px,彻底不碰边。
5625
+ const INSET_Y = 14;
5626
+ const PAD_L = FRAME_L + INSET_X;
5627
+ const PAD_T = FRAME_T + INSET_Y;
5628
+ const plotW = FRAME_W - INSET_X * 2;
5629
+ const plotH = FRAME_H - INSET_Y * 2;
5630
+ // ⚠️ 与 xPlot 同式 **必须保持**。曾经 xOf 不内缩、xPlot 内缩 8px,
5631
+ // 两套坐标只在 12:00 重合:用户对着 9 点的分隔线指,悬停读数却是 08:53
5632
+ // (2026-11-27 用户:「这时间不对吧 我都对齐了 怎么是8:51」)。
5633
+ // 现在色块 / 竖分隔线 / 横网格 / 折线 / 绿点 / 轴刻度 全部走这一个坐标。
5634
+ // xOf = 色块的外缘(铺满绘制区,左右各留 PLOT_PAD_X 的肉)
5635
+ // xPlot = 数据座标(折线 / 绿点 / 轴刻度 / 悬停换算 / 分隔线)
5636
+ // 两套坐标只在**色块两端**差 8px,中间的分界全部走 xPlot,
5637
+ // 所以对着分隔线指一定读得准(2026-11-27 用户:「这时间不对吧」)。
5638
+ const xOf = (h) => PAD_L + (Math.max(0, Math.min(24, h)) / 24) * plotW;
5639
+ // 数据图元(曲线 / 圆点 / 竖线 / 刻度)要在两端再内缩 PLOT_PAD_X:
5640
+ // 色块是 8px 圆角,0 点的白点和竖线正好压在圆角上被裁掉一半
5641
+ // (2026-11-26 用户:「0点的时候 被圆角挡住了 可以往左右两边留点余量 保证都在色块内」)。
5642
+ // 内缩值取圆角半径:圆心落在圆角圆心正上/正下方,整颗点都在色块内。
5643
+ // ⚠️ 色带和分隔线仍用 xOf —— 色块必须铺满绘图区,内缩了会露出背景。
5644
+ const PLOT_PAD_X = 8;
5645
+ const xPlot = (h) => PAD_L + PLOT_PAD_X + (Math.max(0, Math.min(24, h)) / 24) * (plotW - PLOT_PAD_X * 2);
5646
+ // 累计消费是**向上长**的:0 贴底、total 贴顶。
5647
+ // 最低点要比裁剪边界高 1px —— 曲线贴底那一段正好落在 clip 边界上,
5648
+ // 1.8px 描边有一半被裁掉,看起来就和升上去那截不是一个颜色。
5649
+ const plotBase = PAD_T + plotH - 1;
5650
+ // 调试档位循环:真实 maxY 不变,只覆盖纵轴上界(连带刻度一起)。
5651
+ const yOf = (v) => {
5652
+ const t = Math.max(0, Math.min(1, v / maxY));
5653
+ return PAD_T + (1 - t) * (plotH - 1);
5654
+ };
5655
+ // 没有任何一个时段有消耗时,曲线是一条贴着底边的水平线,和色块下边框糊在一起 ——
5656
+ // 看着像「图表没数据 / 坏了」(2026-11-26 用户截图问:「这个情况怎么看不到消耗」)。
5657
+ // 这种情况改画虚线:表示「有图,但没有分小时的数据」,而不是「花了 0 元」。
5658
+ // ⚠️ 判据是 activeHours,不是 total —— 钱的分布可能全在 pluginCost 上
5659
+ // (total > 0 但每小时都是 0),这时候贴底的实线同样是在骗人。
5660
+ const isZero = model.activeHours === 0;
5661
+ // 只画已经发生的那一段(终点是「此刻」,不是 24:00)
5662
+ const nowBJT = new Date(Date.now() + 8 * 3600000);
5663
+ const nowHour = nowBJT.getUTCHours() + nowBJT.getUTCMinutes() / 60;
5664
+ const clipped = model.pts.filter((p) => p.at <= nowHour + 1e-9);
5665
+ // ⚠️ 曲线必须画到**此刻**,不能只截到最后一个整点。
5666
+ // pts 是每小时一个点,只 filter 的话终点落在 23:00;而悬停上限是 nowHour(23:52),
5667
+ // 中间那 52 分钟没有线、悬停却有数字 —— 看着就像在算还没发生的钱
5668
+ // (2026-11-26 用户指着 24:00 附近:「怎么还算没有的东西」)。
5669
+ // 这里补一个 at = nowHour 的插值点,线、白点、可悬停范围三者对齐。
5670
+ {
5671
+ const tailAt = Math.max(0, Math.min(24, nowHour));
5672
+ const lastAt = clipped.length > 0 ? clipped[clipped.length - 1].at : -1;
5673
+ if (tailAt > 1e-9 && tailAt - lastAt > 1e-9) {
5674
+ // 索引按**一格**算(STEPS_PER_HOUR 格 = 1 小时,3 分钟粒度下是 20 格)
5675
+ const sp = model.STEPS_PER_HOUR || 20;
5676
+ const kIdx = Math.min(model.STEPS || 480, Math.floor(tailAt * sp));
5677
+ const p0 = model.pts[kIdx] ? model.pts[kIdx].acc : 0;
5678
+ clipped.push({ at: tailAt, acc: p0 });
5679
+ }
5680
+ }
5681
+ // 折线上的采样点标记。曲线是 **3 分钟**一格(见 STEP_MIN)——
5682
+ // 一格一颗的话一小时 20 颗、凌晨那截直接糊成实线,所以只按整点打。
5683
+ // 打点的语义是「这一段有数据」,不是「这里是采样边界」。只打有消耗的小时。
5684
+ // 逐帧插值纵轴上限:每一帧都用真实坐标重算,
5685
+ // 所以描边粗细、圆点大小、文字字号全都不变,变的只是位置。
5686
+ // 用 setTimeout 递归(DSH 里 rAF 会被挂起)。20 帧 × 26ms ≈ 520ms。
5687
+ // transition 需要两个帧:先拿起点渲染一次,下一帧才改成 1。
5688
+ // 不这样做的话,两个值在同一次渲染里写完,浏览器只看到终值、不播过渡。
5689
+ // 两拍:
5690
+ // 1. 先把位移瞬时摆到 yShift、并把 transition 关掉 — — 否则起点这一帧自己就在动,
5691
+ // 看上去是只滑了 1/20 就被拉回 0(用户:「还是一帧一帧的」)。
5692
+ // 2. 下一拍开 transition、改回 0 — — 这一次才是真正要看的那段滚动。
5693
+ const last = clipped.length > 0 ? clipped[clipped.length - 1] : model.pts[0];
5694
+ // 折线在每小时一个采样点,画出来是硬拐角(2026-11-26 用户:「线段有点丑 拐弯太生硬了」)。
5695
+ // 用 Fritsch–Carlson 单调三次插值:普通 Catmull-Rom 会在台阶前后过冲,
5696
+ // 画成「先回弹再冲上去」,而累计消耗只增不减,过冲就是假的。
5697
+ const dl = (() => {
5698
+ const n = clipped.length;
5699
+ if (n === 0) return "";
5700
+ const xs = clipped.map((p) => xPlot(p.at));
5701
+ const ys = clipped.map((p) => yOf(p.acc));
5702
+ // 起点的**水平引线**(2026-11-27 用户:「给初始画平的绿线 这样就不像从下面直接冲出来的感觉」)。
5703
+ // xPlot(0) 落在 PAD_L + PLOT_PAD_X,绘图区最左那 8px 一直是空的,曲线等于在
5704
+ // 离边缘 8px 处凭空冒出来。把首点钉到 PAD_L 正好吃掉这 8px:
5705
+ // 于是先平一小段、再按真实斜率上升,起点落在色块左缘上。
5706
+ // ⚠️ 只改首点的 x,不动 at —— 悬停、打点、颜色带全部按 at 取,不受影响。
5707
+ xs[0] = PAD_L;
5708
+ if (n === 1) return "M" + xs[0].toFixed(2) + " " + ys[0].toFixed(2);
5709
+ const dx = [];
5710
+ const d = [];
5711
+ for (let i = 0; i < n - 1; i += 1) {
5712
+ dx.push(xs[i + 1] - xs[i]);
5713
+ d.push(dx[i] === 0 ? 0 : (ys[i + 1] - ys[i]) / dx[i]);
5714
+ }
5715
+ // 切线:中间取相邻差分的平均,变号(平台/拐点)就压成 0
5716
+ const m = new Array(n);
5717
+ // 起点切线归零 = 水平入弯(2026-11-27 用户:「弯曲地方要点圆过度」)。
5718
+ // 原来是 m[0] = d[0](直接用首段斜率),于是曲线从 0 点冲出来那一下
5719
+ // 是个硬拐角;归零之后首段从平缓加速,接上真实斜率时已经是弧线。
5720
+ // 限制器会把 m[1] 一并压低(a=m[0]/d[0]=0),所以起段不会过冲。
5721
+ m[0] = 0;
5722
+ m[n - 1] = d[n - 2];
5723
+ for (let i = 1; i < n - 1; i += 1) {
5724
+ m[i] = d[i - 1] * d[i] <= 0 ? 0 : (d[i - 1] + d[i]) / 2;
5725
+ }
5726
+ // 限制器:保证 α²+β² ≤ 9,否则陡升段仍会轻微过冲
5727
+ for (let i = 0; i < n - 1; i += 1) {
5728
+ if (d[i] === 0) { m[i] = 0; m[i + 1] = 0; continue; }
5729
+ const a = m[i] / d[i];
5730
+ const b = m[i + 1] / d[i];
5731
+ const sq = a * a + b * b;
5732
+ if (sq > 9) {
5733
+ const t = 3 / Math.sqrt(sq);
5734
+ m[i] = t * a * d[i];
5735
+ m[i + 1] = t * b * d[i];
5736
+ }
5737
+ }
5738
+ let out = "M" + xs[0].toFixed(2) + " " + ys[0].toFixed(2);
5739
+ for (let i = 0; i < n - 1; i += 1) {
5740
+ const h = dx[i] / 3;
5741
+ out += "C" + (xs[i] + h).toFixed(2) + " " + (ys[i] + m[i] * h).toFixed(2)
5742
+ + " " + (xs[i + 1] - h).toFixed(2) + " " + (ys[i + 1] - m[i + 1] * h).toFixed(2)
5743
+ + " " + xs[i + 1].toFixed(2) + " " + ys[i + 1].toFixed(2);
5744
+ }
5745
+ return out;
5746
+ })();
5747
+ // 峰谷色带:逐小时扫 currentPeriod,把连续同类时段合并成一段。
5748
+ // 2026-11-26 用户:「高峰和空闲的颜色呢」—— 光靠虚竖线只能看清分界,
5749
+ // 看不出哪一段是高峰,所以底色要跟上。
5750
+ const dayStart = dayStartOf(Date.now());
5751
+ const bands = [];
5752
+ let prevKind = currentPeriod(dayStart);
5753
+ let segStart = 0;
5754
+ for (let h = 1; h <= 24; h += 1) {
5755
+ const kind = h === 24 ? "" : currentPeriod(dayStart + h * 3600000);
5756
+ if (kind !== prevKind) {
5757
+ bands.push({ from: segStart, to: h, kind: prevKind });
5758
+ segStart = h;
5759
+ if (h < 24) prevKind = kind;
5760
+ }
5761
+ }
5762
+ const dividers = bands.filter((b) => b.to < 24).map((b) => b.to);
5763
+ // y 轴横向刻度:步长**阶梯式**,钱越多格子越疏
5764
+ // (2026-11-27 用户:「加入5块之前每1块为一个刻度 5块之后每5块一个刻度 20之后就改成10块
5765
+ // 一个刻度 50之后就每100一个刻度」)。
5766
+ // 0~5 每 1
5767
+ // 5~20 每 5
5768
+ // 20~50 每 10
5769
+ // 50+ 每 100
5770
+ // 只画网格线,**不在图里写数字** —— 金额一律靠悬停胶囊报,
5771
+ // 画在 SVG 里会连同曲线一起被裁、还会和刻度标签抢空间。
5772
+ // ⚠️ 刻度**数值**用目标档位,不能用插值中的 maxY:插值期间 maxY 每帧都变,
5773
+ // 数值跟着重算就会一直跳(2026-11-27 用户:「就是这种效果 但是数字会跳动」)。
5774
+ // 位置仍然走 yOf(分母是插值中的 maxY),所以刻度是平滑移动的。
5775
+ const yTicks = (() => {
5776
+ const top = targetMaxY || 1;
5777
+ const raw = [];
5778
+ // ⚠️ 用 <= :maxY 已经取整到档位边界(¥3.74 → ¥5),顶档那一条必须画得出来,
5779
+ // 否则轴顶到 5 却只标到 4,用户还是觉得「刻度不全」。
5780
+ const add = (v) => { if (v > 1e-9 && v <= top + 1e-9) raw.push(v); };
5781
+ for (let v = 1; v <= 5; v += 1) add(v);
5782
+ for (let v = 10; v <= 20; v += 5) add(v);
5783
+ for (let v = 30; v <= 50; v += 10) add(v);
5784
+ for (let v = 150; v < top; v += 100) add(v);
5785
+ // 密集处省略:上限一大,1/2/3/4/5 就全挤在底部几十像素里,一堆数字反而
5786
+ // 看不清。按**像素间距**过滤:距上一条不足 MIN_TICK_GAP 就跳过
5787
+ // (2026-11-27 用户:「到密集的时候 可以省略密集处的刻度」)。
5788
+ // 距离用 top(目标档位)算,不用插值中的 maxY,否则每帧过滤结果不一样、又会跳。
5789
+ const MIN_TICK_GAP = 11;
5790
+ const denom = top > 1e-9 ? top : 1;
5791
+ const out = [];
5792
+ let lastY = Infinity;
5793
+ for (const v of raw) {
5794
+ const y = PAD_T + (1 - v / denom) * (plotH - 1);
5795
+ if (Math.abs(y - lastY) < MIN_TICK_GAP) continue;
5796
+ out.push(v);
5797
+ lastY = y;
5798
+ }
5799
+ return out;
5800
+ })();
5801
+ // 左侧**标签**只留两条:顶档 + 接近一半的那档(网格线仍然按 yTicks 全画)。
5802
+ // 2026-11-27 用户:「不用显示所有消耗刻度」—— 四个数字(¥10 ¥5 ¥3 ¥1)挤在
5803
+ // 90px 高的绘图区左边,比曲线本身还抢眼。
5804
+ const yLabels = (() => {
5805
+ const top = targetMaxY || 1;
5806
+ const ticks2 = yTicks;
5807
+ if (ticks2.length === 0) return [top];
5808
+ const half = top / 2;
5809
+ let pick = null;
5810
+ for (const v of ticks2) {
5811
+ if (v >= top - 1e-9) continue;
5812
+ if (pick === null || Math.abs(v - half) < Math.abs(pick - half)) pick = v;
5813
+ }
5814
+ return pick === null ? [top] : [pick, top];
5815
+ })();
5816
+ // 内层圆角 8(比外框的 12 小一档):2026-11-26 用户「算了还是加圆角吧 里面的色块可以延申一点点」。
5817
+ const R = 8;
5818
+ const ticks = [0, 6, 12, 18, 24];
5819
+ // 两端标签往内收几像素:色块从 PAD_L 起,「0:00」用 textAnchor=start 时
5820
+ // 字头正好压在色块边界上,看着像跑出界(2026-11-26 用户:「让时间在色块内」)。
5821
+ const TICK_NUDGE = 6;
5822
+ // 鼠标横向位置 → 小时。preserveAspectRatio=none 只影响绘制,
5823
+ // getBoundingClientRect 拿到的是实际像素宽度,反解回 viewBox 坐标即可。
5824
+ // ⚠️ 只接受有限数字并取整:任何非法值都会渲染成 "01e-9" / "NaN" 这种垃圾
5825
+ const pad2 = (n) => {
5826
+ const v = Math.round(Number(n)) || 0;
5827
+ return v < 10 ? "0" + v : "" + v;
5828
+ };
5829
+ // 当前那个小时的已知消耗。
5830
+ // ⚠️ 现在是按 hourly 直取,不再用 pts 相邻差 —— pts 已经加密到 5 分钟一段,
5831
+ // pts[i+1]-pts[i] 变成「那 5 分钟的一份」,不是整小时了。
5832
+ const currentHourCost = (() => {
5833
+ const i = Math.min(23, Math.max(0, Math.floor(nowHour)));
5834
+ return (model.hourly[i] || 0) * (model.scale || 1);
5835
+ })();
5836
+ const onHoverMove = (event) => {
5837
+ const rect = event.currentTarget.getBoundingClientRect();
5838
+ if (!(rect.width > 0)) return;
5839
+ const userX = ((event.clientX - rect.left) / rect.width) * W;
5840
+ // ⚠️ 必须用 xPlot 的逆,不能用 xOf 的逆。
5841
+ // 绘制时两端各内缩 PLOT_PAD_X(8px,给色块圆角让位),
5842
+ // 反解还按 xOf 算的话:0:00 处的鼠标会被解成 00:37、24:00 处解成 23:22。
5843
+ // 两个后果都撞上过 —— 悬停位置整体偏、以及鼠标放在绿点(此刻)上时
5844
+ // 解出来的 raw 比 nowHour 大,直接被下面那条 range 判定拦掉,
5845
+ // 于是「鼠标放在绿点上没有反应」(2026-11-26 用户)。
5846
+ const raw = ((userX - PAD_L - PLOT_PAD_X) / (plotW - PLOT_PAD_X * 2)) * 24;
5847
+ // 只报**已经发生**的那一段:鼠标滑到「现在」右边就什么都不显示
5848
+ // (2026-11-26 用户:「没到的地方就不要计算了」)。
5849
+ // 曲线本来也只画到此刻(clipped),右边那截是空白,报数等于凭空编一段钱出来。
5850
+ // ⚠️ 范围按**像素**判、并且两端各给 NOW_HIT_PX 热区:
5851
+ // 绿点只有 r=3,要求像素级精准的话鼠标放上去 3px 就没反应
5852
+ // (2026-11-26 用户:「鼠标放在绿点上应该显示当前的今日消耗」)。
5853
+ const NOW_HIT_PX = 6;
5854
+ // 吸附范围(比命中范围小得多)。
5855
+ // ⚠️ 原来判「此刻」直接拿 NOW_HIT_PX=6px,凌晨时 nowHour 很小,
5856
+ // 6px 横跨 0:00~0:24 —— 鼠标停在 00:00 也会被当成此刻,
5857
+ // 于是 00:00 就报出今日总额 ¥0.85,把平摊曲线整个盖掉
5858
+ // (2026-11-26 用户:「我的平摊算法呢」)。
5859
+ // 现在只认绿点附近 2px(≈4 分钟)吸附,再往左老老实实按插值报。
5860
+ const NOW_SNAP_PX = 2;
5861
+ const nowPx = xPlot(nowHour);
5862
+ // 范围放到整条轴(2026-11-26 用户:「鼠标移到没到的时间点上显示 0 暂未产生消耗」)。
5863
+ // 原来右端只到绿点 + 热区,此刻右边整片灰着不能碰 —— 现在能停,只是金额报「还没到」。
5864
+ if (!(userX >= xPlot(0) - NOW_HIT_PX && userX <= xPlot(24) + NOW_HIT_PX)) { setHover(null); return; }
5865
+ // 贴着绿点时直接吸附到此刻(时刻和金额一起吸);右侧保留满命中范围方便把绿点点中
5866
+ const nearNow = userX >= nowPx - NOW_SNAP_PX && userX <= nowPx + NOW_HIT_PX;
5867
+ const hour = nearNow ? nowHour : Math.min(24, Math.max(0, raw));
5868
+ // 记下纵向位置,黑胶囊要跟着鼠标躲曲线(2026-11-26 用户:「还有这个黑胶囊挡住了」)。
5869
+ const userY = ((event.clientY - rect.top) / rect.height) * H;
5870
+ emitHover(hour, userY);
5871
+ };
5872
+ // 按「某个时刻 + 鼠标纵坐标」出胶囊。抽成独立函数是为了让**滚轮/方向键**能复用:
5873
+ // 图宽 474 铺 24 小时,一分钟只占 0.33px —— 鼠标动一像素就跨 3 分钟,
5874
+ // 再宽的卡片也治不好(要 480px 才 3 分钟/px)。所以精确定位交给滚轮/方向键,
5875
+ // 指针只负责落个大概位置(2026-11-27 用户:「怎么还是只能3分钟的看」)。
5876
+ // 构造胶囊数据(纯函数)。抽出来是为了**常显**:鼠标不在图上时
5877
+ // 渲染层直接用 buildHover(nowHour) 算一份「此刻」的,不再需要先把鼠标摆上去。
5878
+ const buildHover = (hour, userY) => {
5879
+ const future = hour > nowHour + 1e-9;
5880
+ // 取**所在的 5 分钟段**(四舍五入到最近的段边界),段内不再插值。
5881
+ // 段内插值是纯猜测:这一小时花了 ¥1.20,但不知道是哪一分钟,
5882
+ // 按 4/60 摊出来是 ¥0.08,跟「已经花了 ¥1.20」完全对不上
5883
+ // (2026-11-27 用户拿着 0:04 的截图问「这个是准确数值是吗」)。
5884
+ // 现在每一格报它自己那一份,误差 ≤ byHour/STEPS_PER_HOUR。
5885
+ // ⚠️ 兜底值必须与 STEP_MIN 同值(3 分钟 ⇒ 20)—— 早前是 12(5 分钟),
5886
+ // 模型里字段缺失时会静默退回粗粒度吸附,胶囊上的时刻就只在整 5 分上跳
5887
+ // (2026-11-27 用户指着「06:54 累计」说「我说的是这个显示每分钟」)。
5888
+ const sp = model.STEPS_PER_HOUR || 20;
5889
+ const stepIdx = Math.min(model.STEPS || 480, Math.max(0, Math.round(hour * sp)));
5890
+ // pts[i] 存的是第 i+1 格**末**的累计(pts[i].at = (i+1)*STEP_MIN/60),
5891
+ // 所以要取 segHour 那一刻的累计,索引是 stepIdx-1 而不是 stepIdx(差一分钟)。
5892
+ const accIdx = stepIdx - 1;
5893
+ const a0 = accIdx >= 0 && model.pts[accIdx] ? model.pts[accIdx].acc : 0;
5894
+ const aPrev = accIdx - 1 >= 0 && model.pts[accIdx - 1] ? model.pts[accIdx - 1].acc : 0;
5895
+ // 这一分钟自己花了多少 = 相邻两个累计之差(2026-11-27 用户:
5896
+ // 「就是这里滑动可以看到每一分钟的消耗 这样显示的可以准确一点」)。
5897
+ // 直接读曲线的差分,所以和画出来的线永远一致,不会出现「胶囊和曲线对不上」。
5898
+ const minuteCost = Math.max(0, a0 - aPrev);
5899
+ // 时刻吸附到**所在的分钟**:06:54 就是 06:54,不再四舍五入到 5 分钟一档
5900
+ // (2026-11-27 用户:「我说的是这个显示每分钟」)。
5901
+ const segHour = stepIdx / sp;
5902
+ const segI0 = Math.min(24, Math.floor(segHour + 1e-9));
5903
+ const segMin = Math.round((segHour - segI0) * 60);
5904
+ // 该小时整小时的钱(不再显示,留着给悬停胶囊以外的用途)
5905
+ const hourCost = (model.hourly[Math.min(23, Math.max(0, Math.floor(hour)))] || 0) * (model.scale || 1);
5906
+ // 第二行是**整小时**汇总(2026-11-27 用户:「小时还是不变」):
5907
+ // 左端标这一段属于哪个整点,跨整点悬停时才看得出来。
5908
+ const hourFrom = Math.min(23, Math.max(0, Math.floor(segHour + 1e-9)));
5909
+ const hourLabel = pad2(hourFrom) + ":00-" + pad2(Math.min(24, hourFrom + 1)) + ":00";
5910
+ // 鼠标压在曲线末端那颗绿点上时,直接报**今日总额**。
5911
+ // ⚠️ 这里不能用 onHoverMove 的 nearNow:抽成 emitHover 之后它不在这个作用域里,
5912
+ // 每次悬停都抛 ReferenceError,setHover 一次都没执行 —— 鼠标放上去什么都不显示(用户:
5913
+ // 「鼠标放在折线图上能看到对应时间的消耗」)。
5914
+ // onHoverMove 在 nearNow 时把 hour 直接定成 nowHour,所以这里比一下就等价。
5915
+ const onNow = Math.abs(hour - nowHour) < 1e-6;
5916
+ // 报的是**累计**(零点到此刻一共花了多少),不是这一小段单独花了多少 ——
5917
+ // 按段拆的话,没记录的时间 hover 上去恒是 ¥0.0000,看着像坏了。
5918
+ // 这一小时自己的消耗另开一格(2026-11-26 用户:「黑胶囊里面加一个当前小时的总消耗」)。
5919
+ return {
5920
+ // hour 是**未吸附**的插值位置,竖线要跟手;hourSnap 是吸附到分钟后的时刻,
5921
+ // 第二行「00:00-01:00」必须按它算 —— 否则 00:59 会被 round 到 01:00(第一行),
5922
+ // 而第二行仍写 00:00-01:00,两行自相矛盾。
5923
+ hour,
5924
+ hourSnap: segHour,
5925
+ // 此刻与未来都报今日总额(未来不会让累计变大)
5926
+ acc: (onNow || future) ? model.total : a0,
5927
+ hourCost: future ? 0 : hourCost,
5928
+ // 第一行的钱 = 截到此刻的累计(与曲线同源);第二行 = 该小时合计
5929
+ minuteCost: future ? 0 : minuteCost,
5930
+ hourLabel,
5931
+ future,
5932
+ // 不再写「此刻」这个词 —— 用户要看的是「当前时间 + 累计」
5933
+ // (2026-11-26:「显示此刻吗 不应该显示当前时间累计」)。
5934
+ // 第一行是**这一分钟**的消耗:时刻 + 这一分钟花了多少
5935
+ // (2026-11-27 用户圈着第二行说「小时还是不变 我说的是第一行的」)。
5936
+ label: pad2(segI0) + ":" + pad2(segMin),
5937
+ y: userY,
5938
+ };
5939
+ };
5940
+ const emitHover = (hour, userY) => { setHover(buildHover(hour, userY)); };
5941
+ // 滚轮 = 逐分钟微调(上 = 往后、下 = 往前),一格一分钟,不受像素密度限制。
5942
+ // 只在胶囊已经开着时生效,并且吞掉默认滚动,否则页面跟着滚。
5943
+ // ⚠️ 不调 preventDefault:React 的 onWheel 是 passive 监听,调了只会报警告、
5944
+ // 拦不住页面滚动。胶囊本来就贴着图表,滚一点点不影响阅读。
5945
+ const stepHoverBy = (minutes) => {
5946
+ if (hover == null) return;
5947
+ const next = Math.round(hover.hourSnap * 60 + minutes) / 60;
5948
+ emitHover(Math.min(24, Math.max(0, next)), hover.y);
5949
+ };
5950
+ const onHoverWheel = (event) => {
5951
+ if (hover == null) return;
5952
+ stepHoverBy((event && event.deltaY) < 0 ? 1 : -1);
5953
+ };
5954
+ // 方向键逐分钟:←/→ 各走一分钟,和滚轮同一套落点
5955
+ const onHoverKey = (event) => {
5956
+ if (event == null) return;
5957
+ if (event.key === "ArrowLeft") { stepHoverBy(-1); return; }
5958
+ if (event.key === "ArrowRight") { stepHoverBy(1); }
5959
+ };
5960
+ const onHoverLeave = () => setHover(null);
5961
+ // 黑胶囊的位置:横向跟着竖线(靠边时改对齐方式,不夹 left),
5962
+ // 纵向跟着鼠标 —— 鼠标在图表上半部就挂到下方、下半部挂到上方,别压住曲线本身。
5963
+ // 原来钉在 top:1px,曲线爬到右上角时正好被它盖住(2026-11-26 用户:「黑胶囊挡住了」)。
5964
+ // 归位用**滑动**,但时长跟距离走(2026-11-27 用户:「是滑动的动画」)。
5965
+ // 之前固定 100ms:从最右边归位就是 100ms 横跨 300px(~3000px/s),
5966
+ // 看上去像跳帧而不像滑。现在 90ms 起、每小时 +14ms、封顶 300ms,
5967
+ // 长距离也是可跟踪的匀速滑行。
5968
+ const tipPos = (hv) => {
5969
+ const pctX = xPlot(hv.hour) / W;
5970
+ // ⚠️ 不能居中:居中会横跨在竖线上,「此刻」那根白条就被胶囊盖死了
5971
+ // (2026-11-27 用户:「往右靠一点 遮住白条了」)。
5972
+ // 现在一律**贴着竖线向一侧展开**,左半边向右、右半边向左,
5973
+ // 中间留 6px,线与胶囊永不相交;同时两端也不会出界。
5974
+ // ⚠️ 两边必须写成**同一种形式** calc(% + px)。
5975
+ // 之前右展开写的是纯 6px、左展开写的是 calc(-100% - 6px),
5976
+ // 一个是纯 px、一个是百分比混合 —— 浏览器**无法插值**,
5977
+ // 方向一翻就是硬切一个胶囊宽度,看上去就像冲到最右边
5978
+ // (2026-11-27 用户:「好像只有在虚线的左侧才会导致」)。
5979
+ const alignX = pctX > 0.55 ? "translateX(calc(-100% - 6px))" : "translateX(calc(0% + 6px))";
5980
+ // ⚠️ 垂直基点用**曲线在该时刻的高度**,不是鼠标高度。
5981
+ // 用鼠标高度时,鼠标一旦落在曲线上(用户就是顺着线走的)胶囊反而
5982
+ // 挂到曲线那一侧、直接盖住它(2026-11-27 用户:「遮挡到折现了」)。
5983
+ // 现在按「曲线在上半部就挂下方、在下半部就挂上方」,胶囊永远在线的反侧。
5984
+ const curveY = yOf(hv.acc);
5985
+ const below = curveY < H * 0.5;
5986
+ const y = Math.max(2, Math.min(H - 2, curveY));
5987
+ // 归位用**滑动**,但时长跟距离走(2026-11-27 用户:「是滑动的动画」)。
5988
+ // 之前固定 100ms:从最右边归位就是 100ms 横跨 300px(~3000px/s),
5989
+ // 看上去像跳帧而不像滑。现在 90ms 起、每小时 +14ms、封顶 300ms。
5990
+ // 跟手中间那些帧不过渡(不卡);**进入**和**归位**都按距离滑。
5991
+ // 只保留**松开归位**的动画(2026-11-27 用户:「算了 就留松开归位的动画吧」)。
5992
+ // 鼠标在图上(含刚进入)一律 0ms 跟手,不过渡也就不会出现任何冲过头;
5993
+ // 只有 hover 变空、胶囊要回「此刻」时才按距离滑。
5994
+ const prevHour = lastTipHourRef.current;
5995
+ const dur = hover || prevHour < 0
5996
+ ? 0
5997
+ : Math.round(Math.min(200, 80 + Math.abs(hv.hour - prevHour) * 10));
5998
+ // 下一次算距离用就是这一次的位置。
5999
+ // 原来靠一个 react.useEffect 同步,但那个 effect 写在 model.ok 早退**之后** ——
6000
+ // 首次渲染(today 还是 null)少跑一个 hook,数据到位后多跑一个,React 抛
6001
+ // Rendered more hooks → 刚启动就点开时间线直接崩(2026-11-27 用户:
6002
+ // 「插件还在加载的时候点击左下角 插件就会崩」)。
6003
+ lastTipHourRef.current = hv.hour;
6004
+ return {
6005
+ left: pctX * 100 + "%",
6006
+ top: (y / H) * 100 + "%",
6007
+ // 两行之后胶囊更高(~32px),偏移从 10 提到 14。
6008
+ transform: alignX + " " + (below ? "translateY(14px)" : "translateY(calc(-100% - 14px))"),
6009
+ // 只写时长:property 列表由 CSS 常驻提供,这样过渡才能真正启动。
6010
+ // 0ms 时 CSS 那边也不会走过渡,相当于直接落位
6011
+ "--tip-dur": dur + "ms",
6012
+ };
6013
+ };
6014
+ // 第二行左端标签现在由 hover.minLabel 给出(分钟区间),组件体里不再需要
6015
+ // 反解整点 —— 原来那个 i0h 是给「03:00-04:00」用的,已随分钟化一起删掉。
6016
+ // 常显(2026-11-27 用户:「其实胶囊常显也可以加」):鼠标离开就贴回「此刻」,
6017
+ // 不再整块消失。真正悬停时跟手(hover 非空就用它)。
6018
+ // ⚠️ 只有胶囊(tip)常显;竖虚线与白点仍然只跟真实悬停,
6019
+ // 否则会和「此刻」的白线 + 绿点重叠成两套。
6020
+ // 开关关掉时 shownHover 可以是 null(那就是「胶囊不常显」)。
6021
+ const shownHover = tipAlways ? (hover ?? buildHover(nowHour, yOf(model.total))) : hover;
6022
+ const area = clipped.length > 1
6023
+ ? dl + "L" + xPlot(last.at).toFixed(2) + " " + plotBase + "L" + xPlot(0) + " " + plotBase + "Z"
6024
+ : "";
6025
+ return jsx.jsx(PopShell, {
6026
+ anchorRect,
6027
+ wide: true,
6028
+ title: "今日消耗时间线",
6029
+ // 常显开关:放在右上角、关闭按钮左边。
6030
+ headExtra: jsx.jsxs("button", {
6031
+ className: "balance-pop__switch" + (tipAlways ? " balance-pop__switch--on" : ""),
6032
+ type: "button",
6033
+ onClick: setTipAlways,
6034
+ "aria-pressed": tipAlways ? "true" : "false",
6035
+ title: tipAlways ? "常显:鼠标离开后胶囊仍在「此刻」" : "不常显:鼠标离开就隐藏胶囊",
6036
+ children: [
6037
+ jsx.jsx("span", { className: "balance-pop__switch-dot" }),
6038
+ jsx.jsx("span", { children: "常显" }),
6039
+ ],
6040
+ }),
6041
+ // 「今天还没有消耗」只在**真的一分钱没花**时出现。total > 0 但 activeHours 为 0
6042
+ // 说明钱不在分小时账上(pluginCost 等),这时候说「还没有消耗」是错的。
6043
+ // 金额单独拆成一个节点加粗提亮(2026-11-27 用户:
6044
+ // 「这个今日消耗可以显眼一点」)。
6045
+ subtitle: [
6046
+ jsx.jsx("span", { key: "s0", children: "累计 " }),
6047
+ jsx.jsx("strong", {
6048
+ key: "s1",
6049
+ className: "balance-pop__sub-amount",
6050
+ children: popMoney(model.total),
6051
+ }),
6052
+ jsx.jsx("span", {
6053
+ key: "s2",
6054
+ children: (model.activeHours > 0
6055
+ ? " · " + model.activeHours + " 个时段有消耗"
6056
+ : (model.total > 1e-9 ? "" : " · 今天还没有消耗"))
6057
+ + (debugZoom ? " · 调试上限 ¥" + maxY : ""),
6058
+ }),
6059
+ ],
6060
+ onClose,
6061
+ // ⚠️ 图 + 明细**同一个面板**(2026-11-27 用户:「这两个浮窗合并吧」)。
6062
+ // 原来点「今日」开明细、点时段条开时间线,两个浮窗内容互补却要分别点开;
6063
+ // 合并后图在上、明细在下,点哪一块都开这一个。
6064
+ children: jsx.jsxs("div", {
6065
+ children: [
6066
+ jsx.jsx("div", { className: "balance-pop__chart", children: [
6067
+ jsx.jsxs("svg", {
6068
+ key: "svg",
6069
+ className: "balance-pop__svg",
6070
+ viewBox: "0 0 " + W + " " + H,
6071
+ role: "img",
6072
+ "aria-label": "今日消耗时间线",
6073
+ style: { cursor: "crosshair" },
6074
+ // 一分钟一格、24 小时铺 474px ⇒ 1px 跨 3 分钟,鼠标扫过只能落在 3 的倍数上。
6075
+ // 所以精调交给滚轮和方向键(各一格 = 一分钟),鼠标只负责落个大概位置。
6076
+ tabIndex: 0,
6077
+ onWheel: onHoverWheel,
6078
+ onKeyDown: onHoverKey,
6079
+ onMouseMove: onHoverMove,
6080
+ onMouseLeave: onHoverLeave,
6081
+ children: [
6082
+ // 色带和面积图裁成圆角(2026-11-26 用户:「边缘加上圆角」)。
6083
+ // 只裁这两层:坐标轴文字在底部两角,一起裁会把「0:00」「24:00」切掉一半。
6084
+ jsx.jsx("defs", {
6085
+ children: jsx.jsx("clipPath", {
6086
+ id: clipId,
6087
+ // ⚠️ 裁剪框必须跟 xOf 走(和色块同范围)。
6088
+ // 曾经用 PAD_L/plotW(18–476),而色块内缩到 26–468 之后完全落在
6089
+ // 裁剪框内部,圆角根本碰不到边,直接露出矩形的直角
6090
+ // (2026-11-27 用户:「圆角呢」)。
6091
+ children: jsx.jsx("rect", { x: PAD_L, y: PAD_T, width: plotW, height: plotH, rx: R, ry: R }),
6092
+ }),
6093
+ }),
6094
+
6095
+ // 色块不参与缩放(2026-11-27 用户:「压缩的时候 色块不要被压缩
6096
+ // 只压缩里面的刻度」)。底色表示的是「24 小时长什么样」,和金额上限无关,
6097
+ // 跟着 scaleY 一起变形反而像色块自己在抽动。
6098
+ // 色块只在它自己的位置,不跟着缩放组一起动
6099
+ // (2026-11-27 用户:「就是色块只在对应的位置 不要乱动」)。
6100
+ jsx.jsx("g", {
6101
+ key: "bands",
6102
+ clipPath: "url(#" + clipId + ")",
6103
+ children: [
6104
+ // 色块横向归两类边(…………………………………………………………………………
6105
+ // 外缘(0:00 与 24:00)→ xOf,贴着绘制区边缘,左右才有那几像素肉
6106
+ // 内部分界→ xPlot,和轴刻度、分隔线、折线同一套坐标
6107
+ // 不这样分的话,两者只能二选一:全走 xOf 则分隔线与刻度错 2px、
6108
+ // 对着分隔线指会读错时间;全走 xPlot 则色块两端内缩、左右没了余量
6109
+ // (2026-11-27 用户两条反馈分别对应这两个坑)。
6110
+ bands.map((b) => {
6111
+ const bx = b.from <= 0 ? xOf(0) : xPlot(b.from);
6112
+ const bx2 = b.to >= 24 ? xOf(24) : xPlot(b.to);
6113
+ return jsx.jsx("rect", {
6114
+ key: "b" + b.from,
6115
+ className: "balance-pop__band balance-pop__band--" + b.kind,
6116
+ x: bx,
6117
+ y: PAD_T,
6118
+ width: Math.max(0, bx2 - bx),
6119
+ height: plotH,
6120
+ });
6121
+ }),
6122
+ dividers.map((h) => jsx.jsx("line", {
6123
+ key: "d" + h,
6124
+ className: "balance-pop__grid",
6125
+ // 描边按屏幕像素算,不跟着 viewBox 缩放走 —— 否则 1px 虚线被摊到亚像素上会发虚
6126
+ vectorEffect: "non-scaling-stroke",
6127
+ // 分界线的 x 由时间换算得到(119.25 / 153 / 175.5 / 220.5),
6128
+ // 每条落在不同的亚像素位置、抗锯齿程度就不同,看着像粗细不一。
6129
+ // crispEdges 把竖线吸附到像素网格,四条才对得齐。
6130
+ shapeRendering: "crispEdges",
6131
+ x1: xPlot(h), y1: PAD_T, x2: xPlot(h), y2: PAD_T + plotH,
6132
+ })),
6133
+
6134
+ ],
6135
+ }),
6136
+ jsx.jsx("g", {
6137
+ className: "balance-pop__plot",
6138
+ // 原点钉在绘图区的 0 线(plotBase),底边不动、上面伸缩
6139
+ children: [
6140
+ jsx.jsx("g", {
6141
+ clipPath: "url(#" + clipId + ")",
6142
+ children: [
6143
+ // 横向网格跟 yTicks 走 —— yTicks 已经按像素间距过滤掉密集处,
6144
+ // 所以这里不用再自己算一套。网格线与左侧数字始终一一对应。
6145
+ yTicks.map((v) => jsx.jsx("line", {
6146
+ key: "yh" + v,
6147
+ className: "balance-pop__grid-h",
6148
+ vectorEffect: "non-scaling-stroke",
6149
+ shapeRendering: "crispEdges",
6150
+ x1: xOf(0), y1: yOf(v), x2: xOf(24), y2: yOf(v),
6151
+ })),
6152
+ area ? jsx.jsx("path", { className: "balance-pop__area", d: area }) : null,
6153
+ jsx.jsx("path", {
6154
+ className: "balance-pop__line",
6155
+ d: dl,
6156
+ // scaleY 会把描边一起压细(粗细变了就像“折线变了”)
6157
+ vectorEffect: "non-scaling-stroke",
6158
+ // 零值画虚线(见上面 isZero 的注释)。undefined 时 React 不渲染这个属性。
6159
+ strokeDasharray: isZero ? "3 3" : undefined,
6160
+ }),
6161
+ // 悬停位置的竖线(在裁剪组里,贴边时不会跑出色块)
6162
+ hover ? jsx.jsx("line", {
6163
+ key: "hv",
6164
+ className: "balance-pop__hover-line",
6165
+ vectorEffect: "non-scaling-stroke",
6166
+ shapeRendering: "crispEdges",
6167
+ x1: xPlot(hover.hour), y1: PAD_T, x2: xPlot(hover.hour), y2: PAD_T + plotH,
6168
+ }) : null,
6169
+ ],
6170
+ }),
6171
+ // 光标也在缩放组里,跟着一起动(2026-11-27 用户:「绿点也要动的」)。
6172
+ jsx.jsx("line", {
6173
+ className: "balance-pop__now",
6174
+ x1: xPlot(last.at), y1: PAD_T, x2: xPlot(last.at), y2: PAD_T + plotH,
6175
+ }),
6176
+ // 绿点外面包一个**常亮的空心圈**(2026-11-27 用户:
6177
+ // 「鼠标重合和常显时 绿圈外面包一个空心圈 常量的」)。
6178
+ // 常驻,不受 hover 影响;重合时白点落在它里面也不会混。
6179
+ // 泛光圈只在两种情况下亮:
6180
+ // 1. 鼠标与此刻重合(不分开关);
6181
+ // 2. 「常显」开着、且鼠标不在图上。
6182
+ // 开关关掉时归位状态不亮 —— 那时候连胶囊都不在,
6183
+ // 只剩一个白圈孤零零地亮着很突冗(2026-11-27 用户:
6184
+ // 「关闭常显的话 除非指针对齐 这个白色光圈就不要显示了」)。
6185
+ // 容差取半分钟:比 hover 的分钟吸附更细一点,指到同一分钟就算重合。
6186
+ (hover ? Math.abs(hover.hourSnap - last.at) < 1 / 120 : tipAlways) ? jsx.jsx("circle", {
6187
+ className: "balance-pop__dot-ring",
6188
+ cx: xPlot(last.at), cy: yOf(last.acc), r: 6.4,
6189
+ }) : null,
6190
+ jsx.jsx("circle", { className: "balance-pop__dot", cx: xPlot(last.at), cy: yOf(last.acc), r: 3 }),
6191
+ // 鼠标手动指到此刻时**不画实心白点**:
6192
+ // 那里已经有绿点 + 白光圈,再叠一个白点就脏了
6193
+ // (2026-11-27 用户:「如果我手动重合 就不要哪个实心白点了」)。
6194
+ hover && Math.abs(hover.hourSnap - last.at) >= 1 / 120 ? jsx.jsx("circle", {
6195
+ key: "hdot",
6196
+ className: "balance-pop__hover-dot",
6197
+ cx: xPlot(hover.hour), cy: yOf(hover.acc), r: 3,
6198
+ }) : null,
6199
+ ],
6200
+ }),
6201
+ // 左侧金额刻度(2026-11-27 用户:「刻度数字显示出来」)。
6202
+ // 画在绘图区左缘之外、且**不在 clip 组里** —— 放进去会连同曲线一起被裁掉。
6203
+ // 文字用整数:¥1 / ¥5 / ¥10 / ¥150,不补 .00,否则每行四个字符会挤到曲线上。
6204
+ // ⚠️ 标签要防重叠:阶梯步长在低额区很密(¥1~¥5 只占底部两成高度),
6205
+ // 五条线挤进二十来像素会把 ¥1~¥5 糊成一团黑块。网格线照画,**标签按间距跳着写**:
6206
+ // 与上一个已画标签的中心距不足 11px 就跳过,宁可少标几个也不能叠。
6207
+ // key 带上 maxY:换档时重挂一次,搭 CSS 淡入,
6208
+ // 否则数字会“啪”一下换成另一批(2026-11-27 用户:
6209
+ // 「除了光标和背景色块 其他的都跟着数值走」)。
6210
+ yLabels.map((v) => jsx.jsx("text", {
6211
+ // ⬇️ 用 targetMaxY 而不是 maxY:maxY 在插值期间每帧都变,
6212
+ // key 跟着变就等于每帧重挂、每帧重播淡入 —— 屏幕上就是一片乱闪。
6213
+ key: "yv" + targetMaxY + "-" + v,
6214
+ className: "balance-pop__axis balance-pop__axis--value"
6215
+ + (labelAnim ? " balance-pop__axis--value--anim" : ""),
6216
+ x: PAD_L - 2,
6217
+ // 最顶上那个刻度(就是 maxY 那一档)的 yOf 恰好等于 PAD_T = 6,
6218
+ // 文字 baseline 在 9、字号 11 → 顶部到 1px,几乎贴着色带边、被上面的
6219
+ // 卡片内边距压住,看上去就是「最顶上的刻度看不见」(2026-11-27 用户)。
6220
+ // 所以给 baseline 一个下限:再高也不低于 11。
6221
+ y: Math.max(yOf(v) + 3.5, 15),
6222
+ textAnchor: "end",
6223
+ children: "¥" + v,
6224
+ })),
6225
+ ticks.map((h) => jsx.jsx("text", {
6226
+ key: "t" + h,
6227
+ className: "balance-pop__axis",
6228
+ x: xPlot(h) + (h === 0 ? TICK_NUDGE : (h === 24 ? -TICK_NUDGE : 0)),
6229
+ y: H - 3,
6230
+ textAnchor: h === 0 ? "start" : (h === 24 ? "end" : "middle"),
6231
+ children: h + ":00",
6232
+ })),
6233
+ ],
6234
+ }),
6235
+ // 悬停提示:贴着鼠标位置,靠近两端时收进卡片内,别被 overflow:hidden 裁掉
6236
+ shownHover ? jsx.jsx("div", {
6237
+ key: "tip",
6238
+ className: "balance-pop__tip",
6239
+ // 跟随期间**不过渡**(2026-11-27 用户:「这个跟随动画有bug
6240
+ // 我指针速度太快就出现卡顿了」)。
6241
+ // mousemove 每帧都会改 left/top,而 CSS transition 每次都从头重开 →
6242
+ // 胶囊永远在追一个每 16ms 就变一次的目标,快速移动时就是一顿一顿的。
6243
+ // 现在只有**回位**(鼠标离开 → 常显「此刻」)走过渡,跟手时零延迟。
6244
+ className: "balance-pop__tip",
6245
+ // 靠边时改对齐方式而不是夹 left:夹了 tooltip 就和竖线脱开,
6246
+ // 不夹又会被 .balance-pop 的 overflow:hidden 切掉。
6247
+ style: tipPos(shownHover),
6248
+ // 两行:上行「时刻 累计 → 总额」,下行「本小时 → 该小时合计」。
6249
+ // 值按分钟吸附(见 onHoverMove 的 sFrac),同一分钟内数字不动,
6250
+ // 换分钟才跳一次 —— 不挂动画,闪的问题就没了。
6251
+ children: [
6252
+ jsx.jsxs("span", {
6253
+ key: "r1",
6254
+ className: "balance-pop__tip-row",
6255
+ children: [
6256
+ // 时刻 + 「累计」必须包在一起:直接丢给 space-between 的话,
6257
+ // 三个子元素会被拉成三列,「累计」被推到正中间、离时刻
6258
+ // 一大截(2026-11-27 用户:「隔的太远了吧」)。
6259
+ jsx.jsxs("span", {
6260
+ key: "t",
6261
+ className: "balance-pop__tip-left",
6262
+ children: [
6263
+ jsx.jsx("span", { className: "balance-pop__tip-time", children: shownHover.label }),
6264
+ // 「累计」字样:光有时刻 + 金额看不出口径。
6265
+ jsx.jsx("span", { className: "balance-pop__tip-tag", children: "累计" }),
6266
+ ],
6267
+ }),
6268
+ // key 里带**整数位数**(小数点的位置):只有位数变化才重挂、才播滑入。
6269
+ // ⚠️ 不能用字符串长度 —— ¥8.9808 和 ¥12.337 都是 7 个字符,
6270
+ // 整数位从 1 位变 2 位的恰恰是 ¥ 会挪位置的那种情况,长度抓不到。
6271
+ // 同位数内静默换值,不会像之前那样每帧重播动画闪成一片。
6272
+ // 还没到的时段不给 ¥0.00(读起来像“花了 0 元”,实际是“还没发生”)。
6273
+ // 第二行很早就是这么做的,第一行按分钟化时漏了。
6274
+ jsx.jsx("span", {
6275
+ // ⚠️ 第一行 = **今日累计消耗**,不分过去 / 未来。
6276
+ // 曲线本身画的就是累计,报差分就变成「胶囊和曲线对不上」
6277
+ // (2026-11-27 用户圈着这一行:「上面是当前累计消耗」)。
6278
+ // 未来时段 buildHover 已经把 acc 置成 model.total,所以这里直接报就是
6279
+ // 「截到此刻的今日累计」;不再换成「暂未消耗」
6280
+ // (2026-11-27 用户:「我说的是第一行 显示累计消耗:今日消耗数值」)。
6281
+ // 四位小数,和副标题那个「累计 ¥x.xxxx」同一口径。
6282
+ key: "c" + popMoney(shownHover.acc).length,
6283
+ className: "balance-pop__tip-cost",
6284
+ children: popMoney(shownHover.acc),
6285
+ }),
6286
+ ],
6287
+ }),
6288
+ jsx.jsxs("span", {
6289
+ key: "r2",
6290
+ className: "balance-pop__tip-row",
6291
+ children: [
6292
+ // 第二行左标签 = **整小时**区间(03:00-04:00)。
6293
+ // 分钟化只改第一行(2026-11-27 用户圈着第二行:「小时还是不变 我说的是第一行的」);
6294
+ // 这一行保留整小时汇总,横向滑动时只在跨整点那一下变化。
6295
+ jsx.jsx("span", {
6296
+ key: "l",
6297
+ className: "balance-pop__tip-hour",
6298
+ children: shownHover.hourLabel,
6299
+ }),
6300
+ // 还没到的时段不给 ¥0.00 —— 那读起来像「花了 0 元」,
6301
+ // 实际是「这段时间还没发生」(2026-11-26 用户:「显示 0 暂未产生消耗」)。
6302
+ jsx.jsx("span", {
6303
+ key: shownHover.future ? "vdone" : "v" + popMoneyTip(shownHover.hourCost).indexOf("."),
6304
+ className: "balance-pop__tip-hourcost" + (shownHover.future ? " balance-pop__tip-hourcost--pending" : ""),
6305
+ children: shownHover.future ? "暂未产生消耗" : popMoneyTip(shownHover.hourCost),
6306
+ }),
6307
+ ],
6308
+ }),
6309
+ ],
6310
+ }) : null,
6311
+ ] }),
6312
+ jsx.jsx("div", { className: "balance-pop__hr" }),
6313
+ jsx.jsx(TodayBreakdown, { bare: true, today }),
6314
+ ],
6315
+ }),
6316
+ });
6317
+ }
6318
+
6319
+ // ─── 用量统计面板(点余额胶囊打开) ──────────────────────────────────
6320
+ // ⚠️ 这一段是 2026-11-26 从 old/package/lib/client.js 原样搬回来的:
6321
+ // 中途重写时只留了 4 组、丢了「账户余额」卡、「近期消耗」「日均与峰值」,
6322
+ // 用户一眼看出「少了不少东西」。原来的 6 组 + 4 张卡才是对的,别再精简。
6323
+ function UsageStatsPanel({ onClose, panelRef, closing }) {
4196
6324
  const liveBalance = useBalance();
4197
6325
  const [heatmapTooltip, setHeatmapTooltip] = react.useState(null);
4198
6326
  // 加载进度条的「已用 X.Xs」—— 服务端一次返回、给不出百分比,但一个还在涨的数字
@@ -4346,7 +6474,7 @@ const CN_CALENDAR_SOURCES = [
4346
6474
  webToolCost: num(t.webToolCost),
4347
6475
  };
4348
6476
  }, [days, total]);
4349
- const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START;
6477
+ const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START && Date.now() < WEB_TOOL_FREE_FROM;
4350
6478
  const fmtCost = (v) => "¥" + num(v).toFixed(4);
4351
6479
  const denomCost = num(total && total.cost) > 0 ? num(total.cost) : 1;
4352
6480
  const rangeDays = Number(stats && stats.rangeDays) || 90;
@@ -4458,7 +6586,7 @@ const CN_CALENDAR_SOURCES = [
4458
6586
  ? jsx.jsxs(StatsGroup, {
4459
6587
  index: 3,
4460
6588
  title: "网页工具",
4461
- hint: webBillingStarted ? "¥5 / 千次" : "免费期内",
6589
+ hint: webBillingStarted ? "¥5 / 千次" : (Date.now() >= WEB_TOOL_FREE_FROM ? "只算 token" : "免费期内"),
4462
6590
  children: [
4463
6591
  jsx.jsx(StatsRow, {
4464
6592
  name: "Search / Fetch",
@@ -4466,9 +6594,14 @@ const CN_CALENDAR_SOURCES = [
4466
6594
  }),
4467
6595
  jsx.jsx(StatsRow, {
4468
6596
  name: "网页工具费用",
6597
+ // 11-18 12:00 起官方取消按次计费(服务端搜索只算 token,
6598
+ // web_fetch 更是本地匿名 HTTP)。所以这里不能再报「计费 N 次」——
6599
+ // 那 13 次全是 fetch,单价 0,报出来是 ¥0.0000 配「计费 13 次」,自相矛盾。
4469
6600
  value: webBillingStarted
4470
6601
  ? fmtCost(derived.webToolCost) + " · 计费 " + (derived.webSearchBillable + derived.webFetchBillable) + " 次"
4471
- : "免费期内 · 11-01 起按 ¥5 / 千次计费",
6602
+ : Date.now() >= WEB_TOOL_FREE_FROM
6603
+ ? "¥0 · 服务端搜索 / 本地抓取,只算 token"
6604
+ : "免费期内 · 11-01 起按 ¥5 / 千次计费",
4472
6605
  }),
4473
6606
  ],
4474
6607
  })
@@ -4898,6 +7031,20 @@ function useFooterCompact() {
4898
7031
  const todayCost = today !== null && Number.isFinite(Number(today.cost)) ? Number(today.cost) : null;
4899
7032
  // 显示精度固定 2 位(见 todayDecimals)。
4900
7033
  const todayText = todayCost === null ? null : todayCost.toFixed(todayDecimals(todayCost));
7034
+ // 两个小窗的数据源。⚠️ 必须在这一片(所有早退 return 之前)取值 ——
7035
+ // 和 todayCost 同一个理由:早退分支之后取会让两次渲染的 hook / 变量数量不同。
7036
+ // `today` 是 useToday() 的整份对象(含 bySession / sessionTitles / hourly / pluginCost)。
7037
+ const todayForPop = today;
7038
+ // ⚠️ `state.balance` 是**对象**({total_balance, currency, ...}),金额在 total_balance 上,
7039
+ // 而且它是字符串。直接 Number(state.balance) 会得到 NaN → 曲线永远画不出来。
7040
+ // 用 total_balance(= 充值余额,与胶囊显示的主数字同源),别用「充值+赠送」的和。
7041
+ const balanceForPop = (() => {
7042
+ const raw = state !== null && state.balance !== null && typeof state.balance === "object"
7043
+ ? state.balance.total_balance
7044
+ : null;
7045
+ const n = Number(raw);
7046
+ return Number.isFinite(n) && n >= 0 ? n : null;
7047
+ })();
4901
7048
  const [todayRoll, setTodayRoll] = react.useState(null);
4902
7049
  // 今日等待胶囊的光团起始相位:**每次挂载随机一次**(见 makeTodayFlowStyle 的注释)。
4903
7050
  // 不能用 useRef 装 —— 那样每次渲染都会重新算;useState 的初始化函数只跑一次。
@@ -5428,12 +7575,70 @@ function useFooterCompact() {
5428
7575
  // 双击看起来毫无反应。USAGE_URL 才是要传的那个。
5429
7576
  openPlatformOrUrl(USAGE_URL);
5430
7577
  };
5431
- // 余额元素的交互。悬停提示不用原生 title,统一走主题化浮层(见 withPanel)。
7578
+ // ─── 三个点击热区(2026-11-26 拆分)────────────────────────────────
7579
+ // 原来整行只有一个动作(单击=统计面板),用户要的是「点哪块看哪块」:
7580
+ // · 余额胶囊 → 统计面板(原样)
7581
+ // · 左侧「今日 ¥x」→ 今日各对话花了多少(todayPop)
7582
+ // · 时段词 / 刻度条 → 今日余额时间线(timelinePop)
7583
+ // 两个小窗都带被点那一块的 rect(出现位置锚在它上方 = 「上滑」)。
7584
+ const [todayPop, setTodayPop] = react.useState(null);
7585
+ const [timelinePop, setTimelinePop] = react.useState(null);
7586
+ /** 按 closest() 判断这次点的是哪一块;都不是就返回空串(= 整行默认动作)。
7587
+ * ⚠️ 顺序要紧:`.balance-footer__today` 是 `.balance-footer__timeline-meta` 的子节点,
7588
+ * 先判 now 才能把它从时段那一支里摘出来。 */
7589
+ const hitAreaOf = (target) => {
7590
+ if (target == null || typeof target.closest !== "function") return "";
7591
+ if (target.closest(".balance-footer__today") !== null) return "today";
7592
+ if (target.closest(".balance-footer__timeline-meta-item--today") !== null) return "today";
7593
+ if (target.closest(".balance-footer__timeline-meta") !== null) return "timeline";
7594
+ if (target.closest(".balance-footer__timeline-track") !== null) return "timeline";
7595
+ return "";
7596
+ };
7597
+ /** 这次点的是不是余额胶囊。单击开统计面板、双击开官方用量页都只认它。
7598
+ * `reveal` / `wave` 是胶囊内部的擦除层和刷新白光层 —— 不认的话,
7599
+ * 那两层压在胶囊上面时点下去会没反应。 */
7600
+ const isOnCapsule = (target) => {
7601
+ if (target == null || typeof target.closest !== "function") return false;
7602
+ return target.closest(".balance-footer__value") !== null
7603
+ || target.closest(".balance-footer__reveal") !== null
7604
+ || target.closest(".balance-footer__wave") !== null;
7605
+ };
7606
+ const rectOf = (el) => {
7607
+ if (el == null || typeof el.getBoundingClientRect !== "function") return null;
7608
+ const r = el.getBoundingClientRect();
7609
+ if (r == null || r.width <= 0 || r.height <= 0) return null;
7610
+ return { left: r.left, top: r.top, right: r.right, bottom: r.bottom, width: r.width, height: r.height };
7611
+ };
5432
7612
  // 余额元素的交互。悬停提示不用原生 title,统一走主题化浮层(见 withPanel)。
5433
7613
  const interactions = {
5434
- // 单击打开统计面板;顺便阻止 <a href> 的默认跳转(否则会同时弹系统浏览器)
7614
+ // 单击:热区分流(今日 → 明细,时段条 → 时间线,其余 → 统计面板);
7615
+ // 顺便阻止 <a href> 的默认跳转(否则会同时弹系统浏览器)
5435
7616
  onClick: (event) => {
5436
7617
  if (event && typeof event.preventDefault === "function") event.preventDefault();
7618
+ const area = hitAreaOf(event && event.target);
7619
+ if (area !== "") {
7620
+ // 兜一层:`event.target` 可能是行内文字节点外的任意后代,用它的 closest 父级量矩形
7621
+ const el = area === "today"
7622
+ ? (event.target.closest(".balance-footer__today") || event.target.closest(".balance-footer__timeline-meta-item--today"))
7623
+ : (event.target.closest(".balance-footer__timeline") || event.target.closest(".balance-footer__timeline-track"));
7624
+ const rect = rectOf(el) ?? rectOf(event.currentTarget);
7625
+ // ⚠️ 点开就**强制**拉一次 `?today=1`,不走 TTL(2026-11-26 实测:
7626
+ // 小窗打开时手上那份 `today` 可能还是 null / 旧对象 —— hourly 与 sessionTitles
7627
+ // 都是这一版才加的字段,旧缓存里根本没有,于是小窗永远停在「正在汇总」。
7628
+ // 用户点开就是要看最新数据,多一次请求完全值得。
7629
+ void fetchTodayOnce(true);
7630
+ // 两个热区开**同一个**面板(2026-11-27 用户:「这两个选中改成整体」):
7631
+ // 图和时间线明细已经合并在一张卡里,点「今日」或点时段条都开它,
7632
+ // 再点一下关掉。todayPop 保留变量名是为了改动面最小,实际不再单独开窗。
7633
+ setTodayPop(null);
7634
+ setTimelinePop((prev) => (prev !== null ? null : { rect }));
7635
+ return;
7636
+ }
7637
+ setTodayPop(null);
7638
+ setTimelinePop(null);
7639
+ // ⚠️ 只有**余额胶囊**才开统计面板(2026-11-26 用户:
7640
+ // 「只有点击余额胶囊才弹出统计界面」)。原来整行都是热区,点空白也弹,很吵。
7641
+ if (!isOnCapsule(event && event.target)) return;
5437
7642
  openStats(event);
5438
7643
  },
5439
7644
  onDoubleClick: openUsagePage,
@@ -5449,6 +7654,9 @@ function useFooterCompact() {
5449
7654
  },
5450
7655
  onDoubleClick: (event) => {
5451
7656
  if (isOverlayTarget(event && event.target)) return;
7657
+ // 双击(打开官方用量页)同样只认余额胶囊(2026-11-26 用户:
7658
+ // 「双击的交互也是只应用在余额胶囊上」)。原来整行双击都会跳浏览器。
7659
+ if (!isOnCapsule(event && event.target)) return;
5452
7660
  interactions.onDoubleClick(event);
5453
7661
  },
5454
7662
  onContextMenu: (event) => {
@@ -5460,19 +7668,42 @@ function useFooterCompact() {
5460
7668
  // 之前挂在内部的 .balance-footer 上,而那一层正是 primitives.Tooltip 的 cloneElement 目标,
5461
7669
  // props 可能被 Tooltip 的触发逻辑覆盖,结果只有金额胶囊响应、整行看着能点却点不动
5462
7670
  // (2026-10-30 反馈)。提到 Tooltip 外层 + 捕获阶段,双保险。
5463
- const withPanel = (node, hint, anchorStyle, extraProps) => jsx.jsxs("div", {
7671
+ // hint 三态(2026-11-26 用户:「这个显示只应用在余额条上」):
7672
+ // · 字符串 → 用这句自定义文案
7673
+ // · null → **不挂 Tooltip**(收起态圆钮 / 矩形卡:它们只是显示金额,挂那句
7674
+ // 「单击查看余额与使用统计…」会跟着圆钮一路飘)
7675
+ // · undefined → 默认文案,**只有展开态余额条该用这个**
7676
+ const DEFAULT_PANEL_HINT = "单击查看余额与使用统计,双击打开 DeepSeek API 用量页,右键刷新";
7677
+ const withPanel = (node, hint, anchorStyle, extraProps) => {
7678
+ const tipLabel = hint === null
7679
+ ? null
7680
+ : (typeof hint === "string" && hint !== "" ? hint : DEFAULT_PANEL_HINT);
7681
+ return jsx.jsxs("div", {
5464
7682
  className: "balance-stats-anchor balance-stats-anchor--" + (wide ? "wide" : "compact"),
5465
7683
  style: anchorStyle,
5466
7684
  ...(extraProps || null),
5467
7685
  children: [
5468
7686
  // 悬停提示走 DSH 主题化浮层:primitives.Tooltip 内部是 cloneElement(children, {ref}),
5469
7687
  // 不会插入额外 DOM 层,因此不破坏余额行在 flex 容器里的 42px 布局(浮层本身 portal 到 body)。
5470
- jsx.jsx(Tooltip, {
5471
- label: hint || "单击查看余额与使用统计,双击打开 DeepSeek API 用量页,右键刷新",
7688
+ tipLabel === null ? node : jsx.jsx(Tooltip, {
7689
+ label: tipLabel,
5472
7690
  side: "top",
5473
7691
  delayMs: 400,
5474
7692
  children: node,
5475
7693
  }),
7694
+ // 两个「上滑小窗」:都 portal 到 body —— 余额行在一个 overflow 容器里,
7695
+ // 留在原地会被裁掉(和统计面板同一个理由)。
7696
+ todayPop !== null ? createPortal(jsx.jsx(TodayBreakdown, {
7697
+ today: todayForPop,
7698
+ anchorRect: todayPop.rect,
7699
+ onClose: () => setTodayPop(null),
7700
+ }), document.body) : null,
7701
+ timelinePop !== null ? createPortal(jsx.jsx(BalanceTimeline, {
7702
+ today: todayForPop,
7703
+ balance: balanceForPop,
7704
+ anchorRect: timelinePop.rect,
7705
+ onClose: () => setTimelinePop(null),
7706
+ }), document.body) : null,
5476
7707
  // 统计面板:居中弹层 + 半透明遮罩(点击遮罩 / Esc / 关闭按钮均可关闭)
5477
7708
  statsOpen ? createPortal(jsx.jsx("div", {
5478
7709
  ref: layerRef,
@@ -5485,7 +7716,8 @@ function useFooterCompact() {
5485
7716
  }),
5486
7717
  }), document.body) : null,
5487
7718
  ],
5488
- });
7719
+ });
7720
+ };
5489
7721
 
5490
7722
  // 收起态浮窗被 composer 压住时直接隐藏(2026-10-31:「如果被遮挡直接隐藏就行了」)。
5491
7723
  // ⚠️ 必须量**真实矩形**,不能按 bottom:140 之类常量去推算:上一版就是这样错的 ——
@@ -5866,7 +8098,8 @@ function useFooterCompact() {
5866
8098
  }),
5867
8099
  }),
5868
8100
  ],
5869
- }), undefined, anchorStyle);
8101
+ // null = 不挂 Tooltip:那句「单击查看余额…」只属于展开态余额条
8102
+ }), null, anchorStyle);
5870
8103
  return typeof document === "undefined" ? rectFab : createPortal(rectFab, document.body);
5871
8104
  }
5872
8105
  // 两种情况都经 withPanel:收起态的定位落在它渲染的 .balance-stats-anchor--compact
@@ -5885,7 +8118,8 @@ function useFooterCompact() {
5885
8118
  ...externalLink(USAGE_URL, "usage"),
5886
8119
  ...interactions,
5887
8120
  children: balanceText,
5888
- }), undefined, anchorStyle);
8121
+ // null = 不挂 Tooltip(理由同上)
8122
+ }), null, anchorStyle);
5889
8123
  return typeof document === "undefined" ? fab : createPortal(fab, document.body);
5890
8124
  }
5891
8125
 
@@ -5916,7 +8150,7 @@ function useFooterCompact() {
5916
8150
  label: state.error || "余额查询失败",
5917
8151
  side: "top",
5918
8152
  delayMs: 200,
5919
- children: jsx.jsx("span", { className: "balance-footer__error", children: "余额读取失败" }),
8153
+ children: jsx.jsx("span", { className: "balance-footer__value balance-footer__value--error", children: "余额读取失败" }),
5920
8154
  }),
5921
8155
  ],
5922
8156
  }));
@@ -6043,7 +8277,12 @@ function useFooterCompact() {
6043
8277
  metaChildren.push(jsx.jsx("span", {
6044
8278
  className:
6045
8279
  "balance-footer__timeline-meta-item balance-footer__timeline-meta-item--today" +
6046
- (todayCost === null ? " balance-footer__timeline-meta-item--today-waiting" : ""),
8280
+ (todayCost === null ? " balance-footer__timeline-meta-item--today-waiting" : "") +
8281
+ // 小窗开着时高亮(2026-11-26 用户:「点击今日 或者时段消耗 需要高亮显示按钮」)
8282
+ // 小窗开着时高亮。两个热区(今日 / 时段条)现在开同一个面板,
8283
+ // 所以高亮也跟着同一个 state 走,看起来才是一个整体
8284
+ // (2026-11-27 用户:「这两个选中改成整体」)。
8285
+ (timelinePop !== null ? " balance-footer__today--active" : ""),
6047
8286
  children: [
6048
8287
  // 「今日」二字恒定不动:**不给它挂任何动画类**(用户 2026-10-31 反馈
6049
8288
  // 「刷新出来的时候今日二字也会闪一下」—— 根因就是以前整块挂了淡入动画)。
@@ -6162,7 +8401,12 @@ function useFooterCompact() {
6162
8401
  ],
6163
8402
  }, "today"));
6164
8403
  }
6165
- metaChildren.push(jsx.jsx("span", { className: "balance-footer__timeline-meta-group", children: tail }, "tail"));
8404
+ metaChildren.push(jsx.jsx("span", {
8405
+ className: "balance-footer__timeline-meta-group" + (timelinePop !== null ? " balance-footer__timeline--active" : ""),
8406
+ children: tail,
8407
+ }, "tail"));
8408
+ // 高亮只挂在**最内层**可点区域上(见下面 CSS):挂到 .balance-footer__timeline-meta
8409
+ // 会连「今日」一起亮,看起来像选了整行。
6166
8410
  const metaNode = jsx.jsx("span", { className: "balance-footer__timeline-meta", children: metaChildren });
6167
8411
  // 新版把「meta 行 + 刻度条」当结构主体,不存在"关掉只剩金额"的形态,
6168
8412
  // 所以这里不看 showPeriodLabel;那个开关只在旧版有意义(见下面的 classic 分支)。
@@ -6179,7 +8423,7 @@ function useFooterCompact() {
6179
8423
  children: [
6180
8424
  metaNode,
6181
8425
  jsx.jsxs("span", {
6182
- className: "balance-footer__timeline-track balance-footer__timeline-track--" + period,
8426
+ className: "balance-footer__timeline-track balance-footer__timeline-track--" + period + (timelinePop !== null ? " balance-footer__timeline-track--active" : ""),
6183
8427
  children: [
6184
8428
  // 裁剪层让四周各留 1px,颜色不贴边框。
6185
8429
  // 里面是泛光 + 色带两层,换日时由 TimelineBand 做交叉淡入(gradient 不可插值)。
@@ -6314,6 +8558,23 @@ function UsageCostLine({ useProjection, sessionId }) {
6314
8558
  // (响应 → setSplitMap → effect 重跑 → 再请求),死循环。用 ref 读当前值。
6315
8559
  const splitMapRef = react.useRef(splitMap);
6316
8560
  splitMapRef.current = splitMap;
8561
+ // ⚠️ 价格变了要重算,否则屏幕上的金额会停在旧价上(2026-11-26 实测发现)。
8562
+ // usageKey 只由 token 数构成、不含价格,所以同步完不会触发 ?session= 重发,
8563
+ // 而 askedSessions 又把会话标成「问过」,两边一起把数字钉死在旧价。
8564
+ // 判据用 settings.syncedPricingAt:同步成功、手动改价都会让它变。
8565
+ const lastPricingAtRef = react.useRef(null);
8566
+ react.useEffect(() => {
8567
+ const at = Number(settings.syncedPricingAt) || 0;
8568
+ // 首次只记账不清缓存,避免刚打开页面就白拉一轮
8569
+ if (lastPricingAtRef.current === null) {
8570
+ lastPricingAtRef.current = at;
8571
+ return;
8572
+ }
8573
+ if (lastPricingAtRef.current === at) return;
8574
+ lastPricingAtRef.current = at;
8575
+ if (globalThis.__balanceAsked instanceof Set) globalThis.__balanceAsked.clear();
8576
+ setSplitMap({});
8577
+ }, [settings.syncedPricingAt]);
6317
8578
  // 消耗明细面板:**点击展开**(对齐 DSH 原生「会话统计」的交互——点开切换 + 选中态 + portal 浮层)
6318
8579
  const [detailsOpen, setDetailsOpen] = react.useState(false);
6319
8580
  const detailsAnchorRef = react.useRef(null);
@@ -7775,7 +10036,8 @@ function UsageCostLine({ useProjection, sessionId }) {
7775
10036
  ? jsx.jsxs("span", {
7776
10037
  key: "team",
7777
10038
  className: "balance-usage-team",
7778
- title: "含 " + teamCount + " 个团队成员(智能体团队)的消耗",
10039
+ // 原来这里是原生 title(「含 N 个团队成员(智能体团队)的消耗」),hover 弹灰框,
10040
+ // 跟浮窗主题完全不搭。圆片上本来就写着「团队 2」,解释不需要 hover 也有。
7779
10041
  children: ["团队 ", String(teamCount)],
7780
10042
  })
7781
10043
  : null,
@@ -7955,7 +10217,7 @@ function UsageCostLine({ useProjection, sessionId }) {
7955
10217
  // ⚠️ 「免费期内」是**有期限**的文案(2026-11-02 用户:「今天都11/2号了 怎么还显示啊」)。
7956
10218
  // 原来只判 `webToolCost > 0`:计费已开始、但这几次调用本来就不计费(或在 11-01 之前发生的)
7957
10219
  // 时,金额是 0,于是永远显示「免费期内(11-01 起收费)」。必须和统计面板一样按日期判。
7958
- const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START;
10220
+ const webBillingStarted = Date.now() >= WEB_TOOL_BILLING_START && Date.now() < WEB_TOOL_FREE_FROM;
7959
10221
  costDetails.push(
7960
10222
  ["网页搜索 / 抓取", webSearchCalls + " / " + webFetchCalls + " 次"],
7961
10223
  [
@@ -7966,7 +10228,9 @@ function UsageCostLine({ useProjection, sessionId }) {
7966
10228
  ? webBillable > 0
7967
10229
  ? "¥0.0000 · 计费 " + webBillable + " 次"
7968
10230
  : "¥0.0000 · 均在免费期内产生"
7969
- : "免费期内(11-01 起收费)",
10231
+ : Date.now() >= WEB_TOOL_FREE_FROM
10232
+ ? "¥0 · 服务端搜索 / 本地抓取,只算 token"
10233
+ : "免费期内(11-01 起收费)",
7970
10234
  ],
7971
10235
  );
7972
10236
  }
@@ -8336,6 +10600,16 @@ function UsageCostLine({ useProjection, sessionId }) {
8336
10600
  const s = settings != null && typeof settings === "object" ? settings : {};
8337
10601
  const issues = [];
8338
10602
 
10603
+ // 升级残留(2026-11-27):启动时服务端已经清过一轮历史版本文件,所以这里非空
10604
+ // 基本只说明「插件进程还没重启」。不是故障,但值得说一句,别让人对着目录猜。
10605
+ const obsolete = Array.isArray(d.obsolete) ? d.obsolete.filter((x) => typeof x === "string" && x !== "") : [];
10606
+ if (obsolete.length > 0) {
10607
+ issues.push({
10608
+ level: "warn",
10609
+ text: `插件目录里还留着历史版本的文件:${obsolete.join("、")}(重启插件后自动清理)`,
10610
+ });
10611
+ }
10612
+
8339
10613
  // 余额
8340
10614
  if (d.balance == null) {
8341
10615
  issues.push({
@@ -8449,7 +10723,7 @@ function UsageCostLine({ useProjection, sessionId }) {
8449
10723
  const warn = issues.filter((x) => x.level === "warn");
8450
10724
  const out = [];
8451
10725
  if (bad.length === 0 && warn.length === 0) {
8452
- out.push("诊断结论 PASS 5 项检查通过:余额 / 今日 / 本会话 / 浮窗 / 设置");
10726
+ out.push("诊断结论 PASS 6 项检查通过:余额 / 今日 / 本会话 / 浮窗 / 设置 / 升级残留");
8453
10727
  return out;
8454
10728
  }
8455
10729
  const head = [];
@@ -8487,6 +10761,11 @@ function UsageCostLine({ useProjection, sessionId }) {
8487
10761
  lines.push("");
8488
10762
  for (const line of formatDiagVerdict(issues)) lines.push(line);
8489
10763
 
10764
+ // ── 升级残留 ──(启动时已清一轮;这里还列得出名字,就是进程还没重启)
10765
+ const obsoleteList = Array.isArray(d.obsolete) ? d.obsolete.filter((x) => typeof x === "string" && x !== "") : [];
10766
+ lines.push("");
10767
+ lines.push(`升级残留 ${obsoleteList.length === 0 ? "无" : obsoleteList.join("、") + " (重启插件后自动清理)"}`);
10768
+
8490
10769
  // ── 余额 ──
8491
10770
  const bal = d.balance;
8492
10771
  const balObj = bal != null && typeof bal === "object" ? bal : null;
@@ -8675,6 +10954,17 @@ function UsageCostLine({ useProjection, sessionId }) {
8675
10954
  // installed — 覆盖完成,等重启
8676
10955
  // error — 查询或更新失败
8677
10956
  const [updateCheck, setUpdateCheck] = react.useState({ kind: "idle" });
10957
+ // 官方价同步的状态。kind: idle | syncing | ok | error
10958
+ const [pricingSync, setPricingSync] = react.useState({ kind: "idle" });
10959
+ // 同步成功后弹一张「同步到什么了」的卡片。用户 2026-11-26 要求:
10960
+ // 「同步计费信息成功显示一个弹窗 里面显示同步到了什么内容」
10961
+ const [pricingModal, setPricingModal] = react.useState(false);
10962
+ const [calendarModal, setCalendarModal] = react.useState(false);
10963
+ // 失败时也要有一份结果可展示(成功那份在 calendarSync.result 里)
10964
+ const [calendarSyncResult, setCalendarSyncResult] = react.useState(null);
10965
+ // 节假日同步的实时进度(服务端 ?calendarProgress=1 轮出来的)。
10966
+ // 走模型要 10 秒左右,纯静止的「同步中…」看着像卡死。
10967
+ const [calendarProgress, setCalendarProgress] = react.useState(null);
8678
10968
  // 数据诊断(设置页 → 「数据诊断」→ 点一下出表):
8679
10969
  // idle/loading/ok/error 四态 + 一份已经拼好的纯文本。只读,不写任何设置。
8680
10970
  const [diagReport, setDiagReport] = react.useState({ kind: "idle", text: "" });
@@ -8775,23 +11065,84 @@ function UsageCostLine({ useProjection, sessionId }) {
8775
11065
  : "";
8776
11066
  return "已同步 " + calendar.count + " 天 · " + stamp.slice(5) + pending;
8777
11067
  }
8778
- if (calendarSync.kind === "syncing") return "正在同步…";
11068
+ // 走模型时是「搜索 + 抓公告全文 + 解析」,实测约 10 秒;写出来免得看着像卡死。
11069
+ if (calendarSync.kind === "syncing") return calendarSync.text || "正在同步…";
8779
11070
  return "尚未同步,正在用插件内置表。";
8780
11071
  })();
11072
+ // 进度条现在只画在弹窗里,百分比与阶段文案提到这里算一次,
11073
+ // 免得 JSX 里再写一段 IIFE(行内那份已随进度条一起搬走)。
11074
+ const calendarProgressPctVal = calendarProgressPct(calendarProgress);
11075
+ const calendarProgressText = (() => {
11076
+ const p = calendarProgress;
11077
+ if (p == null || p.label == null || p.label === "") {
11078
+ return calendarSync.text || "正在同步…";
11079
+ }
11080
+ const total = Number(p.total) || 0;
11081
+ const done = Number(p.done) || 0;
11082
+ if (total <= 1) return p.label;
11083
+ const cur = p.phase === "done" ? done : Math.min(total, done + 1);
11084
+ return String(cur) + "/" + String(total) + " · " + p.label;
11085
+ })();
11086
+ // 同步期间每 400ms 问一次进度。setTimeout 递归而不用 setInterval:
11087
+ // 一次请求挂住时不会堆出几条并发;组件卸载立刻停。
11088
+ react.useEffect(() => {
11089
+ if (calendarSync.kind !== "syncing") {
11090
+ setCalendarProgress(null);
11091
+ return;
11092
+ }
11093
+ let alive = true;
11094
+ let timer = null;
11095
+ const tick = async () => {
11096
+ try {
11097
+ const res = await fetch("/balance-api?calendarProgress=1", { headers: { accept: "application/json" } });
11098
+ const data = await res.json();
11099
+ // ⚠️ 必须校验 running 是布尔:旧版服务端不认这个路由,会回一份完整余额状态,
11100
+ // 它的 ok 同样是 true —— 不校验就把它当进度用,进度条永远停在 0(已实测)。
11101
+ if (alive && data && data.ok === true && typeof data.running === "boolean") {
11102
+ setCalendarProgress(data);
11103
+ }
11104
+ } catch {
11105
+ /* 进度拿不到不影响同步本身,下一拍再试 */
11106
+ }
11107
+ if (alive) timer = setTimeout(tick, 400);
11108
+ };
11109
+ void tick();
11110
+ return () => {
11111
+ alive = false;
11112
+ if (timer !== null) clearTimeout(timer);
11113
+ };
11114
+ }, [calendarSync.kind]);
11115
+
8781
11116
  const onSyncCalendar = async () => {
8782
11117
  if (calendarBusy) return;
8783
- setCalendarSync({ kind: "syncing", text: "正在同步…" });
11118
+ setCalendarSync({ kind: "syncing", text: "正在搜索国务院公告并解析,约 10 秒…" });
11119
+ // 进度条只在弹窗里(2026-11-27:「如果用户点同步 弹出弹窗 并提醒用户不要离开
11120
+ // 并且弹窗里面是进度条 原先的进度条移到弹窗里」)。弹窗一开就显示,
11121
+ // 结果到了还是这张弹窗切换内容(kind 从 syncing 变 ok/error)—— 不另开一张。
11122
+ setCalendarModal(true);
8784
11123
  try {
8785
- const data = await syncCalendar();
11124
+ // 以**用户眼前选中的那个开关**为准,不等 350ms 的保存落盘(见 syncCalendar 注释)
11125
+ const data = await syncCalendar(value.syncModeCalendar === "free" ? "free" : "model");
8786
11126
  if (data && data.ok === true) {
8787
11127
  // 成功不另拼一句文案:syncCalendar() 内部已经 adoptCalendar(data) 刷新了缓存,
8788
11128
  // calendarSummary 会带着新的同步时刻自己重渲染;这里只把状态切成 ok(绿色)。
8789
- setCalendarSync({ kind: "ok", text: "" });
11129
+ // 另存一份结果给弹窗用(同步到哪几年、加了多少天、这次花了多少 token)。
11130
+ setCalendarSync({ kind: "ok", text: "", result: data });
11131
+ setCalendarModal(true);
11132
+ // 这次同步走模型烧的 token 已经记进服务端账本(notePluginSpend),
11133
+ // 但手里这份 today 是同步之前的 —— 不主动拉一次,「插件同步 N 次 / ¥x」
11134
+ // 就要等到下一次 today 轮询才变(2026-11-27 用户:「更新速度有延迟」)。
11135
+ // 服务端那边同一笔记账也会作废今日缓存,两边合起来才是「点完就变」。
11136
+ void fetchTodayOnce(true);
8790
11137
  } else {
8791
11138
  setCalendarSync({
8792
11139
  kind: "error",
8793
11140
  text: (data && data.error) || "同步失败,继续使用本地数据。",
8794
11141
  });
11142
+ // 失败也弹窗:服务端已经把「模型为什么没成」「流结构」「chunk 数」「候选模型」都带回来了,
11143
+ // 只塞进指针文字一行根本看不出来。弹窗里逐项列。
11144
+ setCalendarSyncResult(data ?? null);
11145
+ setCalendarModal(true);
8795
11146
  }
8796
11147
  } catch (error) {
8797
11148
  setCalendarSync({
@@ -8840,6 +11191,80 @@ function UsageCostLine({ useProjection, sessionId }) {
8840
11191
  });
8841
11192
  };
8842
11193
 
11194
+ // 一键同步官方价与时段。用 POST:它写配置、还可能调模型(花 token),
11195
+ // GET 带副作用不符合语义,也不该被浏览器预取。
11196
+ // 同步花了多少钱。usage = { inputTokens, outputTokens, costCny, model, calls }
11197
+ // 金额小到 0.0001 级,固定四位;token 加千分位便于一眼判断量级。
11198
+ const syncCostText = (usage) => {
11199
+ if (!usage || typeof usage !== "object") return "未消耗 token";
11200
+ const inTok = Number(usage.inputTokens ?? 0);
11201
+ const outTok = Number(usage.outputTokens ?? 0);
11202
+ const cny = Number(usage.costCny ?? 0);
11203
+ const n = (v) => String(Math.round(v)).replace(/\B(?=(\d{3})+(?!\d))/g, ",");
11204
+ return "≈ " + n(inTok) + " 输入 + " + n(outTok) + " 输出 token ≈ ¥" + cny.toFixed(4)
11205
+ + (Number(usage.calls ?? 0) > 1 ? "(" + usage.calls + " 次调用)" : "");
11206
+ };
11207
+
11208
+ const onSyncPricing = () => {
11209
+ if (pricingSync.kind === "syncing") return;
11210
+ setPricingSync({ kind: "syncing", text: "正在抓官网并解析,约 5 秒…" });
11211
+ // 价格同步也先弹窗(2026-11-27:「点同步 弹出弹窗 并提醒用户不要离开」):
11212
+ // 它没有进度接口,所以只有一条来回扫的轨道 + 明确的时间预期,不伪造百分比。
11213
+ setPricingModal(true);
11214
+ void (async () => {
11215
+ try {
11216
+ // 同节假日:带上眼前选中的同步方式,别等服务端那份可能还没保存的设置
11217
+ const modeQuery = "&mode=" + (value.syncModePricing === "free" ? "free" : "model");
11218
+ const res = await fetch("/balance-api?sync=1" + modeQuery, {
11219
+ method: "POST",
11220
+ headers: { "Content-Type": "application/json" },
11221
+ body: "{}",
11222
+ });
11223
+ const data = await res.json();
11224
+ if (data?.ok === true) {
11225
+ setPricingSync({
11226
+ kind: "ok",
11227
+ how: data.how ?? "",
11228
+ model: data.model ?? "",
11229
+ parsed: data.parsed ?? null,
11230
+ usage: data.usage ?? null,
11231
+ modelSkipReason: data.modelSkipReason ?? "",
11232
+ chunkShape: data.chunkShape ?? "",
11233
+ at: Date.now(),
11234
+ });
11235
+ setPricingModal(true);
11236
+ // 同节假日:这次同步的 token 已记进服务端账本,主动拉一次今日,
11237
+ // 免得「插件同步」那行等下一拍轮询才更新(2026-11-27:「更新速度有延迟」)。
11238
+ void fetchTodayOnce(true);
11239
+ // 服务端已经写盘了,本地缓存跟上,界面立刻显示新价
11240
+ if (data.settings) {
11241
+ settingsCache = {
11242
+ ...settingsCache,
11243
+ value: { ...SETTINGS_DEFAULTS, ...data.settings },
11244
+ version: settingsCache.version,
11245
+ };
11246
+ applyPeakWindowsText(settingsCache.value.peakWindowsText);
11247
+ emitSettings();
11248
+ }
11249
+ } else if (res.status === 405) {
11250
+ setPricingSync({
11251
+ kind: "error",
11252
+ error: "同步接口还没加载",
11253
+ hint: "界面已经是新版,但插件服务端要重启 DSH 才会加载新代码。重启后再点一次即可。",
11254
+ });
11255
+ } else {
11256
+ setPricingSync({
11257
+ kind: "error",
11258
+ error: data?.error ?? ("HTTP " + res.status),
11259
+ hint: data?.hint ?? "",
11260
+ });
11261
+ }
11262
+ } catch (error) {
11263
+ setPricingSync({ kind: "error", error: error instanceof Error ? error.message : String(error) });
11264
+ }
11265
+ })();
11266
+ };
11267
+
8843
11268
  // 数据诊断:打一次 `?diag=1`,把关键字段拼成纯文本摆出来。
8844
11269
  // 刻意每次都重新请求(不缓存)—— 用户点它的时机就是「刚刚好像不对」,
8845
11270
  // 拿缓存等于拿现场之前的数据,反而误导。
@@ -9021,7 +11446,10 @@ function UsageCostLine({ useProjection, sessionId }) {
9021
11446
  + "请执行 " + (updateCheck.command || "dsh plugin install balance-dsh@" + updateCheck.to)
9022
11447
  + "(或 设置 → 插件 里的更新)后再重启。";
9023
11448
  }
9024
- return "已更新到 " + updateCheck.to + ",重启 DeepSeek Harness 后生效。";
11449
+ // 2026-11-27:更新时会清理旧版本残留的 lib/*.js,拿掉几个就如实说几个。
11450
+ const cleaned = Array.isArray(updateCheck.removed) ? updateCheck.removed.length : 0;
11451
+ const cleanNote = cleaned > 0 ? "(已清理 " + cleaned + " 个旧文件)" : "";
11452
+ return "已更新到 " + updateCheck.to + cleanNote + ",重启 DeepSeek Harness 后生效。";
9025
11453
  }
9026
11454
  if (updateCheck.kind === "error") return "检查失败:" + updateCheck.error + "(可稍后重试)";
9027
11455
  if (updateCheck.kind === "ok") {
@@ -9132,32 +11560,43 @@ function UsageCostLine({ useProjection, sessionId }) {
9132
11560
  };
9133
11561
  // 逐项记录用的 effect 已经上移到早退之前(见「NEW 相关」那段说明)——
9134
11562
  // hook 不能跟在条件 return 后面。这里只留纯计算。
9135
- const row = (key, label, hint, control, extra) => jsx.jsxs("div", {
9136
- className: "balance-settings__row",
9137
- // 顶部「本版新增」横幅靠它定位跳转(querySelector('[data-newtag="key"]'))
9138
- "data-newtag": key,
9139
- children: [
9140
- jsx.jsxs("div", {
9141
- className: "balance-settings__label",
9142
- children: [
9143
- jsx.jsxs("span", {
9144
- className: "balance-settings__label-line",
9145
- children: [
9146
- jsx.jsx("span", { className: "balance-settings__label-text", children: label }),
9147
- isNew(key)
9148
- ? jsx.jsx("span", { className: "balance-settings__new-badge", children: "NEW" })
9149
- : null,
9150
- ],
9151
- }),
9152
- hint ? jsx.jsx("span", { className: "balance-settings__hint", children: hint }) : null,
9153
- ],
9154
- }),
9155
- // extra 是可选的「中间预览」:夹在说明文字和右侧控件之间,
9156
- // 由 margin-left:auto 贴向控件一侧(用户指的那块空白就在这里)。
9157
- extra || null,
9158
- jsx.jsx("div", { className: "balance-settings__control", children: control }),
9159
- ],
9160
- }, key);
11563
+ // ⚠️ below 是**整行下方的全宽内容**,渲染在 row 的**外面**。
11564
+ // 不能塞进 control:control 是 flex:none,宽度由内容决定,一塞进去
11565
+ // control 就变宽,左边 flex:1 的说明文字跟着重排
11566
+ // (2026-11-27 用户:「这个进度条换个地方 要不然导致左边的字一直在动」)。
11567
+ const row = (key, label, hint, control, extra, below) => {
11568
+ const main = jsx.jsxs("div", {
11569
+ className: "balance-settings__row",
11570
+ // 顶部「本版新增」横幅靠它定位跳转(querySelector('[data-newtag="key"]'))
11571
+ "data-newtag": key,
11572
+ children: [
11573
+ jsx.jsxs("div", {
11574
+ className: "balance-settings__label",
11575
+ children: [
11576
+ jsx.jsxs("span", {
11577
+ className: "balance-settings__label-line",
11578
+ children: [
11579
+ jsx.jsx("span", { className: "balance-settings__label-text", children: label }),
11580
+ isNew(key)
11581
+ ? jsx.jsx("span", { className: "balance-settings__new-badge", children: "NEW" })
11582
+ : null,
11583
+ ],
11584
+ }),
11585
+ hint ? jsx.jsx("span", { className: "balance-settings__hint", children: hint }) : null,
11586
+ ],
11587
+ }),
11588
+ // extra 是可选的「中间预览」:夹在说明文字和右侧控件之间,
11589
+ // 由 margin-left:auto 贴向控件一侧(用户指的那块空白就在这里)。
11590
+ extra || null,
11591
+ jsx.jsx("div", { className: "balance-settings__control", children: control }),
11592
+ ],
11593
+ }, key);
11594
+ if (!below) return main;
11595
+ // ⚠️ below 走**数组**返回,不用 react.Fragment。jsx 工厂的第 3 个参数不是 key,
11596
+ // 传进去会被当成一个额外的文本 child 渲染出来,整行的 flex 布局直接崩成竖排
11597
+ // (2026-11-27 用户截图:「法定节假日」一个字一行)。
11598
+ return [main, jsx.jsx("div", { className: "balance-settings__below", children: below }, key + "-below")];
11599
+ };
9161
11600
 
9162
11601
  const toggle = (key, label, onClick) => jsx.jsx("button", {
9163
11602
  type: "button",
@@ -9212,6 +11651,55 @@ function UsageCostLine({ useProjection, sessionId }) {
9212
11651
  );
9213
11652
 
9214
11653
  // 二选一分段控件:用于「余额行外观」这类互斥选项。第 5 参 extra 是可选的行内预览。
11654
+ // 每行自己的「模型 / 免费」小切换。之所以不做一个全局开关:
11655
+ // 价格同步和节假日同步的收益不一样,用户可能只想让一个花钱
11656
+ // (2026-11-26:「就是需要模型还是免费同步」—— 直接放各行上)。
11657
+ // 服务端在 ?config=1 里回 modelSync:{ok,reason}。不可用时「模型」那颗按钮要禁用,
11658
+ // 否则用户点了没反应、或者走一遍再退回免费,完全看不出为什么。
11659
+ const modelSyncOk = settingsCache?.modelSync?.ok !== false;
11660
+ const modelSyncReason = settingsCache?.modelSync?.reason ?? "";
11661
+ const modeMini = (key) => jsx.jsx("div", {
11662
+ className: "balance-settings__mode-mini",
11663
+ role: "radiogroup",
11664
+ "aria-label": "同步方式",
11665
+ children: [
11666
+ { value: "model", label: "模型" },
11667
+ { value: "free", label: "免费" },
11668
+ ].map((opt) => jsx.jsx("button", {
11669
+ key: opt.value,
11670
+ type: "button",
11671
+ role: "radio",
11672
+ "aria-checked": value[key] === opt.value,
11673
+ title: opt.value === "model"
11674
+ ? (modelSyncOk ? "调用模型,读得准,会消耗 token" : (modelSyncReason || "这个环境用不了模型同步"))
11675
+ : "不调用模型,不花钱,官网改版可能读不出来",
11676
+ // 环境没挂载 dsh-llm 时「模型」是真用不了,禁掉并让 title 说明原因
11677
+ disabled: opt.value === "model" && !modelSyncOk,
11678
+ className:
11679
+ "balance-settings__mode-mini-btn balance-settings__mode-mini-btn--" + opt.value +
11680
+ (value[key] === opt.value ? " balance-settings__mode-mini-btn--on" : ""),
11681
+ onClick: () => patch(key, opt.value),
11682
+ children: opt.label,
11683
+ }, opt.value)),
11684
+ });
11685
+
11686
+ // 每行自己的模式说明(2026-11-27 用户:「把这个整体的提示撤了 设置成每项的提示」)。
11687
+ // 原来是一条覆盖两行的 group-note(「两行都走模型,会产生少量 token 消耗…」),
11688
+ // 用户看「价格与时段」那一行时得回头对一句「两行都…」才知道这行花不花钱。
11689
+ // 现在挪进各自行的 hint:**用哪种模式就说哪种模式的代价**,免费只说免费的事。
11690
+ // 金额按实测给的量级:账本 29 次调用 ¥0.0603,单次折合 ¥0.002 上下,写「不到 ¥0.01」留足余量。
11691
+ // ⚠️ 必须自己另起一行(display:block),否则会和上一句连成一长串 ——
11692
+ // 同 hint-warn / hint-error 的做法;走模型才用警示橙,免费用普通灰,别整行染橙。
11693
+ const syncModeTip = (key) => {
11694
+ const free = value[key] === "free";
11695
+ return jsx.jsx("span", {
11696
+ className: "balance-settings__hint-mode" + (free ? " balance-settings__hint-mode--free" : ""),
11697
+ children: free
11698
+ ? "当前免费:不调用模型、不产生消耗;官网改版后可能读不出来。"
11699
+ : "当前走模型:会产生少量 token 消耗(单次折合不到 ¥0.01)。",
11700
+ });
11701
+ };
11702
+
9215
11703
  const choiceRow = (key, label, hint, options, extra) => row(key, label, hint, jsx.jsx("div", {
9216
11704
  className: "balance-settings__segmented",
9217
11705
  role: "radiogroup",
@@ -9244,13 +11732,17 @@ function UsageCostLine({ useProjection, sessionId }) {
9244
11732
  }),
9245
11733
  });
9246
11734
  // note:分组级说明(可选),渲染在分组标题下方、行上方,用来说明这组的口径/适用范围
9247
- const group = (key, title, rows, note) => jsx.jsxs("div", {
11735
+ // note 可以是一句话,也可以是 { text, tone: "warn" }(警告用琥珀色,别和普通说明混在一起)。
11736
+ const group = (key, title, rows, note) => {
11737
+ const noteText = note !== null && typeof note === "object" ? note.text : note;
11738
+ const noteWarn = note !== null && typeof note === "object" && note.tone === "warn";
11739
+ return jsx.jsxs("div", {
9248
11740
  className: "balance-settings__group",
9249
11741
  children: [
9250
11742
  jsx.jsx("div", { className: "balance-settings__group-title", children: title }),
9251
- note
11743
+ noteText
9252
11744
  ? jsx.jsxs("div", {
9253
- className: "balance-settings__group-note",
11745
+ className: "balance-settings__group-note" + (noteWarn ? " balance-settings__group-note--warn" : ""),
9254
11746
  children: [
9255
11747
  // 同顶部告示那颗:宽高必须等于 viewBox 的 16,14/16 的非整数缩放会把描边抹糊。
9256
11748
  jsx.jsxs("svg", {
@@ -9268,13 +11760,14 @@ function UsageCostLine({ useProjection, sessionId }) {
9268
11760
  jsx.jsx("circle", { cx: 8, cy: 4.9, r: 0.85, fill: "currentColor", stroke: "none" }),
9269
11761
  ],
9270
11762
  }),
9271
- jsx.jsx("span", { className: "balance-settings__group-note-text", children: note }),
11763
+ jsx.jsx("span", { className: "balance-settings__group-note-text", children: noteText }),
9272
11764
  ],
9273
11765
  })
9274
11766
  : null,
9275
11767
  ...rows,
9276
11768
  ],
9277
- }, key);
11769
+ }, key);
11770
+ };
9278
11771
 
9279
11772
  // 自定义价格已从界面移除:价格本来就跟随官方内置价表(官方调价时更新插件即可),
9280
11773
  // 普通用户没有自己填的必要。服务端仍支持 settings.priceByModel 覆盖价,
@@ -9315,29 +11808,6 @@ function UsageCostLine({ useProjection, sessionId }) {
9315
11808
  openSettings ? jsx.jsxs("div", {
9316
11809
  className: "balance-settings__body",
9317
11810
  children: [
9318
- // 「本版新增」横幅:只在有条目新功能未过期时出现。
9319
- // 它不依赖侧栏入口 —— 用户关闭「侧边栏显示本插件」、或从 DSH「插件」
9320
- // 页直接进来时,这是唯一能看到"有新功能"的地方(2026-10-31 用户提问)。
9321
- pendingNew.length > 0
9322
- ? jsx.jsxs("div", {
9323
- className: "balance-settings__newcue",
9324
- children: [
9325
- jsx.jsx("span", { className: "balance-settings__newcue-badge", children: "NEW" }),
9326
- jsx.jsx("span", {
9327
- className: "balance-settings__newcue-text",
9328
- children: "本版新增:" + pendingNew
9329
- .map((item) => NEW_TAG_LABELS[item.key] || item.key)
9330
- .join(" · "),
9331
- }),
9332
- jsx.jsx("button", {
9333
- type: "button",
9334
- className: "balance-settings__newcue-btn",
9335
- onClick: () => focusNewRow(pendingNew[0].key),
9336
- children: "去看看",
9337
- }),
9338
- ],
9339
- })
9340
- : null,
9341
11811
  // 顶部告示:计费范围限制放在最前面,打开设置第一眼就看到,
9342
11812
  // 不用翻到「计费」分组才发现。
9343
11813
  jsx.jsxs("div", {
@@ -9367,6 +11837,29 @@ function UsageCostLine({ useProjection, sessionId }) {
9367
11837
  }),
9368
11838
  ],
9369
11839
  }),
11840
+ // 「本版新增」横幅:只在有条目新功能未过期时出现。
11841
+ // 它不依赖侧栏入口 —— 用户关闭「侧边栏显示本插件」、或从 DSH「插件」
11842
+ // 页直接进来时,这是唯一能看到"有新功能"的地方(2026-10-31 用户提问)。
11843
+ pendingNew.length > 0
11844
+ ? jsx.jsxs("div", {
11845
+ className: "balance-settings__newcue",
11846
+ children: [
11847
+ jsx.jsx("span", { className: "balance-settings__newcue-badge", children: "NEW" }),
11848
+ jsx.jsx("span", {
11849
+ className: "balance-settings__newcue-text",
11850
+ children: "本版新增:" + pendingNew
11851
+ .map((item) => NEW_TAG_LABELS[item.key] || item.key)
11852
+ .join(" · "),
11853
+ }),
11854
+ jsx.jsx("button", {
11855
+ type: "button",
11856
+ className: "balance-settings__newcue-btn",
11857
+ onClick: () => focusNewRow(pendingNew[0].key),
11858
+ children: "去看看",
11859
+ }),
11860
+ ],
11861
+ })
11862
+ : null,
9370
11863
  // 版本与更新:放在最前面(用户要"往上放一点")。
9371
11864
  // 检查、更新、结果说明都在这一块,底部只留保存状态与「恢复默认」。
9372
11865
  jsx.jsxs("div", {
@@ -9447,56 +11940,105 @@ function UsageCostLine({ useProjection, sessionId }) {
9447
11940
  ],
9448
11941
  }),
9449
11942
 
9450
- // 节假日同步紧跟在「版本与更新」下面:两者都是「后台自动补一次 + 可手动触发」,
9451
- // 放一起比塞在「计费」末尾好找。数据本身仍然决定算钱口径,只是入口挪了位置。
9452
- group("calendar", "节假日数据", [
9453
- row(
9454
- "calendar",
9455
- "同步状态",
9456
- "法定节假日与调休从国务院公告同步。插件每 30 天自动同步一次,这里可以手动立即更新。",
9457
- jsx.jsxs("div", {
9458
- className: "balance-settings__calendar",
9459
- children: [
9460
- jsx.jsx("span", {
9461
- className:
9462
- "balance-settings__calendar-note" +
9463
- (calendarSync.kind === "error"
9464
- ? " balance-settings__calendar-note--error"
9465
- : calendarSync.kind === "ok"
9466
- ? " balance-settings__calendar-note--ok"
9467
- : calendar.fetchedAt > 0
9468
- ? ""
9469
- : " balance-settings__calendar-note--warn"),
9470
- children: calendarSummary,
9471
- }),
9472
- jsx.jsx("button", {
9473
- type: "button",
9474
- className: "balance-settings__btn",
9475
- onClick: onSyncCalendar,
9476
- disabled: calendarBusy,
9477
- children: calendarBusy ? "同步中…" : "立即同步",
11943
+ // 两个同步都是「去官方拉当前口径」,单起一类放最前 —— 它们决定算钱对不对,
11944
+ // 比下面的余额参数重要得多。
11945
+ group("sync", "官方同步", [
11946
+ row(
11947
+ "syncedPricingAt",
11948
+ "价格与时段",
11949
+ jsx.jsxs("span", {
11950
+ children: [
11951
+ "抓一次官网,把最新价与时段覆盖到本地配置。",
11952
+ // 这一行自己的模式说明(原来归组级提示管,2026-11-27 拆下来)
11953
+ syncModeTip("syncModePricing"),
11954
+ pricingSync.kind === "error"
11955
+ ? jsx.jsx("span", {
11956
+ className: "balance-settings__hint-error",
11957
+ children: "✕ 同步失败:" + pricingSync.error + (pricingSync.hint ? "(" + pricingSync.hint + ")" : "") + "。现有配置未改动。",
11958
+ })
11959
+ : null,
11960
+ ],
11961
+ }),
11962
+ jsx.jsxs("div", { className: "balance-settings__row-actions", children: [
11963
+ modeMini("syncModePricing"),
11964
+ jsx.jsx("button", {
11965
+ type: "button",
11966
+ className: "balance-settings__btn balance-settings__btn--primary",
11967
+ onClick: onSyncPricing,
11968
+ disabled: pricingSync.kind === "syncing",
11969
+ children: pricingSync.kind === "syncing" ? "同步中…" : "立即同步",
11970
+ }),
11971
+ ] }),
11972
+ ),
11973
+ // 节假日同样决定算钱口径(法定节假日全天按空闲价),和价格同步并排。
11974
+ row(
11975
+ "calendar",
11976
+ "法定节假日",
11977
+ jsx.jsxs("span", {
11978
+ children: [
11979
+ "同步当年放假与调休日期,全天按空闲价计费。",
11980
+ // 同上:节假日这一行自己的模式说明。它一次同步会按年份循环调模型
11981
+ // (11 月之后是「今年 + 明年」两趟),所以和价格行不是同一笔量级 ——
11982
+ // 但仍是「不到 ¥0.01」一档,具体次数看当年目标年份。
11983
+ syncModeTip("syncModeCalendar"),
11984
+ calendar.fetchedAt > 0
11985
+ ? null
11986
+ : jsx.jsx("span", {
11987
+ className: "balance-settings__hint-warn",
11988
+ children: "⚠️ 还没同步过,先用内置日历",
9478
11989
  }),
9479
- ],
11990
+ ],
11991
+ }),
11992
+ jsx.jsxs("div", {
11993
+ className: "balance-settings__calendar",
11994
+ children: [
11995
+ modeMini("syncModeCalendar"),
11996
+ jsx.jsx("span", {
11997
+ className:
11998
+ "balance-settings__calendar-note" +
11999
+ (calendarSync.kind === "error"
12000
+ ? " balance-settings__calendar-note--error"
12001
+ : calendarSync.kind === "ok"
12002
+ ? " balance-settings__calendar-note--ok"
12003
+ : calendar.fetchedAt > 0
12004
+ ? ""
12005
+ : " balance-settings__calendar-note--warn"),
12006
+ children: calendarSummary,
9480
12007
  }),
9481
- ),
9482
- ]),
12008
+ jsx.jsx("button", {
12009
+ type: "button",
12010
+ className: "balance-settings__btn balance-settings__btn--primary",
12011
+ onClick: onSyncCalendar,
12012
+ disabled: calendarBusy,
12013
+ children: calendarBusy ? "同步中…" : "立即同步",
12014
+ }),
12015
+ ],
12016
+ }),
12017
+ // ⚠️ 第 5 个参数是 extra(行内、说明文字与控件之间),第 6 个才是 below。
12018
+ // 2026-11-27 这里少写了一个 null,进度条落到 extra 位 → 它带着 flex:1 0 100%
12019
+ // 把整行占满,左边「法定节假日」被压成一列竖排单字(用户截图就是这个)。
12020
+ // 现在显式占住 extra(null),进度条走 below,在整行**下面**独立一行。
12021
+ null,
12022
+ // 进度条已经搬进弹窗(2026-11-27 用户:「原先的进度条移到弹窗里」),
12023
+ // 这行下面不再常驻任何东西 —— below 位留 null,行高与原来一致。
12024
+ null,
12025
+ ),
12026
+ ]),
12027
+ // ⚠️ 这里原来有第 4 个参数(group-note),一条覆盖两行的「两行都走模型…」。
12028
+ // 2026-11-27 用户:「把这个整体的提示撤了 设置成每项的提示」—— 已拆进上面两行的
12029
+ // hint(见 syncModeTip)。**别再往 sync 组加组级提示**:哪一行花不花钱是行自己的事,
12030
+ // 组级那一句在只有一行走模型时还得绕个弯说「另一行不花钱」。
9483
12031
 
9484
- group("balance", "余额", [
12032
+ group("balance", "余额", [
9485
12033
  numberRow("refreshIntervalSec", "余额刷新间隔", "轮询间隔;对话产生新消耗时也会顺带刷新。", 5, 3600, "秒"),
9486
12034
  numberRow("lowBalanceThreshold", "低余额警示阈值", "余额低于该值时金额转为琥珀色。", 0, 100000, "元"),
9487
- row("apiKey", "API Key", "官方账号未登录或读不到余额时的回退凭据;留空则只用官方账号。",
9488
- jsx.jsx("input", {
9489
- className: "balance-settings__input",
9490
- style: { width: "280px" },
9491
- type: "password",
9492
- autoComplete: "off",
9493
- placeholder: "sk-…(留空 = 不设置)",
9494
- value: value.apiKey == null ? "" : value.apiKey,
9495
- onChange: (event) => patch("apiKey", event.target.value),
9496
- })),
12035
+ // 「API Key」输入框已按用户要求撤掉(2026-11-27:「这个选项删除 不需要了」)。
12036
+ // 服务端的 apiKey 字段与回退链路一律不动:已保存过的值仍能用于
12037
+ // 「官方账号读不到余额」的兜底,只是不再在界面上暴露与编辑。
9497
12038
  ]),
9498
12039
 
9499
- group("display", "界面显示", [
12040
+ // 侧边栏那排:全是「展开侧边栏后长什么样」,和对话区无关,所以和下面拆开
12041
+ group("sidebar", "侧边栏", [
9500
12042
  toggleRow("showBalanceRow", "侧边栏余额行", "展开侧边栏时底部紧挨设置齿轮的那一行。"),
9501
12043
  choiceRow("footerStyle", "余额行样式", "新版:上方一行文字信息 + 扁刻度条;旧版:钱包图标 + 「余额」 + 金额的纯文字行。", [
9502
12044
  { value: "timeline", label: "新版" },
@@ -9517,6 +12059,13 @@ function UsageCostLine({ useProjection, sessionId }) {
9517
12059
  value.footerStyle === "timeline"
9518
12060
  ? toggleRow("refreshWave", "右键刷新浪潮", "右键余额时,金额会被一道白光从左往右擦出来(和输入区「本会话消耗」同一个动效)。")
9519
12061
  : null,
12062
+ value.footerStyle === "classic"
12063
+ ? toggleRow("showPeriodLabel", "高峰 / 空闲标签", "旧版余额行里「金额 • 时段」的时段部分;关掉后只留金额。")
12064
+ : null,
12065
+ ]),
12066
+
12067
+ // 对话区那排:消耗浮窗、它的加载动效、以及收起侧边栏后那颗圆钮
12068
+ group("conversation", "对话界面", [
9520
12069
  toggleRow("showUsagePill", "会话消耗行", "对话界面右下角的小浮窗:一行两列(「本会话消耗估算」+ 金额),点开是明细浮层。"),
9521
12070
  // 两种加载动效互斥,用分段按钮选(和「余额行外观」同一个控件,视觉一致)。
9522
12071
  // 选项文字用「样式1 / 样式2」而不是效果名,所以旁边直接播一个真预览 ——
@@ -9565,18 +12114,15 @@ function UsageCostLine({ useProjection, sessionId }) {
9565
12114
  ],
9566
12115
  }, "p-cur"),
9567
12116
  })),
9568
- value.footerStyle === "classic"
9569
- ? toggleRow("showPeriodLabel", "高峰 / 空闲标签", "旧版余额行里「金额 • 时段」的时段部分;关掉后只留金额。")
9570
- : null,
9571
- ]),
9572
12117
 
9573
- group("fab", "收起态圆钮", [
12118
+ // 收起侧边栏后那颗悬浮圆钮 —— 它出现在对话区左下角,属于这一组
9574
12119
  toggleRow("showFab", "显示圆钮", "收起侧边栏时左下角的悬浮圆形余额。"),
9575
- numberRow("fabSize", "直径", "圆钮大小;圆内字号按比例缩放。", 32, 120, "px"),
9576
- numberRow("fabLeft", "距左缘", "数值越大越靠右;收起态卡片左下角等距,所以它同时也是距底边的距离。", 0, 600, "px"),
12120
+ numberRow("fabSize", "圆钮直径", "圆钮大小;圆内字号按比例缩放。", 32, 120, "px"),
12121
+ numberRow("fabLeft", "圆钮距左缘", "数值越大越靠右;收起态卡片左下角等距,所以它同时也是距底边的距离。", 0, 600, "px"),
9577
12122
  ]),
9578
12123
 
9579
- group("stats", "用量统计", [
12124
+ // 这四个都是「扫描多少 / 记多少」的性能旋钮,和界面无关,单独一组
12125
+ group("stats", "性能与缓存", [
9580
12126
  numberRow("todaySessionLimit", "今日消耗扫描上限", "启动时最多统计今天动过的多少个会话(多开对话、多跑子代理时调大,越大越全也可能越慢)。", 10, 2000, "个"),
9581
12127
  numberRow("statsSessionLimit", "扫描会话数上限", "统计面板最多回看多少个历史会话(越大越慢)。", 10, 2000, "个"),
9582
12128
  numberRow("statsCacheSec", "统计缓存时长", "统计结果缓存多久;0 = 每次重新扫描。", 0, 3600, "秒"),
@@ -9590,21 +12136,10 @@ function UsageCostLine({ useProjection, sessionId }) {
9590
12136
  ),
9591
12137
  ]),
9592
12138
 
9593
- group("billing", "计费", [
9594
- // 官方改时段就等于改「哪几个小时翻倍」。留成可编辑项,
9595
- // 以后即使没人改代码,用户自己也能跟上官方口径。
9596
- textRow(
9597
- "peakWindowsText",
9598
- "高峰时段",
9599
- "工作日北京时间的这些时段按高峰计价。格式 9-12, 14-18(官方当前值)。写错了自动沿用上一组有效值。",
9600
- "9-12, 14-18",
9601
- ),
9602
- numberRow("peakMultiplier", "高峰时段倍率", "官方为 2(高峰价 = 空闲价 × 倍率)。", 1, 10, "倍"),
9603
- ]),
9604
-
9605
- // 数据诊断排在最后:它是排障入口,不是日常设置,
9606
- // 出问题时往下翻一屏就能找到,平时不占视线。只读,不写任何设置。
12139
+ // 数据诊断排在最后:它是排障入口,不是日常设置,出问题时往下翻一屏就能找到,
12140
+ // 平时不占视线。只读,不写任何设置。
9607
12141
  group("diag", "数据诊断", [
12142
+
9608
12143
  row(
9609
12144
  "diag",
9610
12145
  "生成诊断报告",
@@ -9698,6 +12233,281 @@ function UsageCostLine({ useProjection, sessionId }) {
9698
12233
  ],
9699
12234
  }) : null,
9700
12235
 
12236
+ // 价格同步:进度 → 结果**同一张窗**(2026-11-27 用户:「两个同步的弹窗用一个窗口
12237
+ // 不要加载完就换窗口」)。原来进度走自绘窗、结果走 primitives.Modal,同步一结束
12238
+ // 就是关一张开一张,壳不同、位置不同、大小不同。现在 kind 一变只换**壳里的内容**。
12239
+ // ⚠️ open 必须写成「弹窗开关 && 不是 idle」—— 结果阶段把它关掉就又是换窗口了。
12240
+ // 抓官网 + 解析没有分阶段进度,所以只有一条扫描轨道(indeterminate),绝不写假百分比。
12241
+ jsx.jsx(SyncProgressDialog, {
12242
+ open: pricingModal && pricingSync.kind !== "idle",
12243
+ phase: pricingSync.kind === "syncing" ? "running" : "result",
12244
+ title:
12245
+ pricingSync.kind === "syncing"
12246
+ ? "正在同步模型价格"
12247
+ : pricingSync.kind === "ok"
12248
+ ? "价格与时段已同步"
12249
+ : "价格同步没成功",
12250
+ label: pricingSync.text || "正在抓官网并解析…",
12251
+ indeterminate: true,
12252
+ note: "⚠️ 同步期间请不要离开这个弹窗 —— 离开这次同步就失效了,还会白白浪费 token。同步到的数据只作展示用。",
12253
+ onClose: () => setPricingModal(false),
12254
+ children:
12255
+ pricingSync.kind === "error"
12256
+ ? jsx.jsxs("div", {
12257
+ className: "balance-settings__sync",
12258
+ children: [
12259
+ jsx.jsx("div", {
12260
+ className: "balance-settings__sync-note",
12261
+ style: { marginTop: 0 },
12262
+ children: pricingSync.error || "同步失败",
12263
+ }),
12264
+ pricingSync.hint
12265
+ ? jsx.jsx("div", { className: "balance-settings__sync-note", children: pricingSync.hint })
12266
+ : null,
12267
+ ],
12268
+ })
12269
+ : jsx.jsxs("div", {
12270
+ className: "balance-settings__sync",
12271
+ children: [
12272
+ jsx.jsxs("div", {
12273
+ className: "balance-settings__sync-grid",
12274
+ children: [
12275
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "高峰时段" }),
12276
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: (pricingSync.parsed?.peakWindowsText ?? "—") + "(工作日北京时间)" }),
12277
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "高峰倍率" }),
12278
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "×" + (pricingSync.parsed?.peakMultiplier ?? "—") + "(高峰价 = 空闲价 × 倍率)" }),
12279
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "flash 输入" }),
12280
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "未命中 ¥" + (pricingSync.parsed?.priceFlash?.inputCnyPerMillion ?? "—") + " · 命中 ¥" + (pricingSync.parsed?.priceFlash?.cacheReadCnyPerMillion ?? "—") + " / 百万 tokens" }),
12281
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "flash 输出" }),
12282
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "¥" + (pricingSync.parsed?.priceFlash?.outputCnyPerMillion ?? "—") + " / 百万 tokens" }),
12283
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "pro 输入" }),
12284
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "未命中 ¥" + (pricingSync.parsed?.pricePro?.inputCnyPerMillion ?? "—") + " · 命中 ¥" + (pricingSync.parsed?.pricePro?.cacheReadCnyPerMillion ?? "—") + " / 百万 tokens" }),
12285
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "pro 输出" }),
12286
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: "¥" + (pricingSync.parsed?.pricePro?.outputCnyPerMillion ?? "—") + " / 百万 tokens" }),
12287
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "解析方式" }),
12288
+ jsx.jsx("span", {
12289
+ className: "balance-settings__sync-val" + (pricingSync.how === "model" ? " balance-settings__sync-val--warn" : ""),
12290
+ children:
12291
+ pricingSync.how === "model"
12292
+ ? [
12293
+ "模型解析",
12294
+ // 模型名单独一块、独占一行:整串 "deepseek-official/deepseek-v4-flash"
12295
+ // 太长,跟着「模型解析」挤会从 "v4-" 后面硬断成两截。
12296
+ jsx.jsx("span", { className: "balance-settings__sync-sub", children: "(" + (pricingSync.model || "未知模型") + ")" }, "model"),
12297
+ ]
12298
+ : "没走模型(退回内置规则,未消耗 token)",
12299
+ }),
12300
+ // 选了模型却没走成 —— 把服务端给的原因原样摆出来,别让人对着「没走模型」猜
12301
+ pricingSync.how !== "model" && pricingSync.modelSkipReason
12302
+ ? jsx.jsxs("div", {
12303
+ style: { display: "contents" },
12304
+ children: [
12305
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型没跑成" }),
12306
+ jsx.jsx("span", {
12307
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
12308
+ style: { wordBreak: "break-all", lineHeight: "17px" },
12309
+ children: pricingSync.modelSkipReason,
12310
+ }),
12311
+ ],
12312
+ })
12313
+ : null,
12314
+ pricingSync.how !== "model" && pricingSync.modelSkipReason !== "" && pricingSync.chunkShape
12315
+ ? jsx.jsxs("div", {
12316
+ style: { display: "contents" },
12317
+ children: [
12318
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "流结构" }),
12319
+ jsx.jsx("span", {
12320
+ className: "balance-settings__sync-val",
12321
+ style: { wordBreak: "break-all", lineHeight: "16px", fontSize: "10.5px" },
12322
+ children: pricingSync.chunkShape,
12323
+ }),
12324
+ ],
12325
+ })
12326
+ : null,
12327
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "本次消耗" }),
12328
+ jsx.jsx("span", {
12329
+ className: "balance-settings__sync-val" + (pricingSync.usage ? " balance-settings__sync-val--cost" : ""),
12330
+ children: syncCostText(pricingSync.usage),
12331
+ }),
12332
+ ],
12333
+ }),
12334
+ jsx.jsx("div", {
12335
+ className: "balance-settings__sync-note",
12336
+ children: "已写入本地配置,升级插件不会覆盖。这些是目录价,展示时按上面倍率区分高峰 / 空闲。",
12337
+ }),
12338
+ ],
12339
+ }),
12340
+ }),
12341
+
12342
+ // 节假日同步:进度 → 结果**同一张窗**(2026-11-27 用户:「两个同步的弹窗用一个窗口
12343
+ // 不要加载完就换窗口」)。原来进度走自绘、成功 / 失败各走一张官方 Modal,同步一结束
12344
+ // 就是关一张开一张。现在 kind 一变只换壳里的内容:标题、正文、按钮文案。
12345
+ // ⚠️ open 必须写成「弹窗开关 && 不是 idle」—— 结果阶段关掉就又变成换窗口了。
12346
+ jsx.jsx(SyncProgressDialog, {
12347
+ open: calendarModal && calendarSync.kind !== "idle",
12348
+ phase: calendarSync.kind === "syncing" ? "running" : "result",
12349
+ // 标题必须反映真实结果:只要还有年份没拿到(failedYears),就不能写「已同步」——
12350
+ // 2026-11-26 用户看到「已同步」同时看到「模型没跑成」,两句互相打脸。
12351
+ title:
12352
+ calendarSync.kind === "syncing"
12353
+ ? "正在同步法定节假日"
12354
+ : calendarSync.kind === "error"
12355
+ ? "节假日同步没成功"
12356
+ : (Array.isArray(calendarSync.result?.failedYears) && calendarSync.result.failedYears.length > 0)
12357
+ ? "法定节假日部分同步"
12358
+ : "法定节假日已同步",
12359
+ label: calendarProgressText,
12360
+ pct: calendarProgressPctVal,
12361
+ note: "⚠️ 同步期间请不要离开这个弹窗 —— 离开这次同步就失效了,还会白白浪费 token。同步到的数据只作展示用。",
12362
+ onClose: () => setCalendarModal(false),
12363
+ children:
12364
+ calendarSync.kind === "error"
12365
+ ? jsx.jsxs("div", {
12366
+ className: "balance-settings__sync-grid",
12367
+ children: [
12368
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "结果" }),
12369
+ jsx.jsx("span", { className: "balance-settings__sync-val balance-settings__sync-val--warn", children: calendarSync.text || "同步失败" }),
12370
+ ...(calendarSyncResult?.modelSkipReason
12371
+ ? [
12372
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型没跑成" }),
12373
+ jsx.jsx("span", {
12374
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
12375
+ style: { wordBreak: "break-all", lineHeight: "17px" },
12376
+ children: calendarSyncResult.modelSkipReason,
12377
+ }),
12378
+ ]
12379
+ : []),
12380
+ ...(calendarSyncResult?.chunkCount != null
12381
+ ? [
12382
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "收到 chunk" }),
12383
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: String(calendarSyncResult.chunkCount) }),
12384
+ ]
12385
+ : []),
12386
+ ...(calendarSyncResult?.chunkShape
12387
+ ? [
12388
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "流结构" }),
12389
+ jsx.jsx("span", {
12390
+ className: "balance-settings__sync-val",
12391
+ style: { wordBreak: "break-all", lineHeight: "16px", fontSize: "10.5px" },
12392
+ children: calendarSyncResult.chunkShape,
12393
+ }),
12394
+ ]
12395
+ : []),
12396
+ ...(calendarSyncResult?.candidates
12397
+ ? [
12398
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "候选模型" }),
12399
+ jsx.jsx("span", {
12400
+ className: "balance-settings__sync-val",
12401
+ style: { wordBreak: "break-all", lineHeight: "16px", fontSize: "10.5px" },
12402
+ children: calendarSyncResult.candidates,
12403
+ }),
12404
+ ]
12405
+ : []),
12406
+ ...(calendarSyncResult?.modelListRaw
12407
+ ? [
12408
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型列表" }),
12409
+ jsx.jsx("span", {
12410
+ className: "balance-settings__sync-val",
12411
+ style: { wordBreak: "break-all", lineHeight: "15px", fontSize: "10px" },
12412
+ children: calendarSyncResult.modelListRaw,
12413
+ }),
12414
+ ]
12415
+ : []),
12416
+ ...(Array.isArray(calendarSyncResult?.failedYears) && calendarSyncResult.failedYears.length > 0
12417
+ ? [
12418
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "失败年份" }),
12419
+ jsx.jsx("span", { className: "balance-settings__sync-val", children: calendarSyncResult.failedYears.join(" / ") }),
12420
+ ]
12421
+ : []),
12422
+ ],
12423
+ })
12424
+ : jsx.jsxs("div", {
12425
+ className: "balance-settings__sync",
12426
+ children: [
12427
+ jsx.jsxs("div", {
12428
+ className: "balance-settings__sync-grid",
12429
+ children: [
12430
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "同步年份" }),
12431
+ jsx.jsx("span", {
12432
+ className: "balance-settings__sync-val",
12433
+ children: Array.isArray(calendarSync.result?.years) && calendarSync.result.years.length > 0
12434
+ ? calendarSync.result.years.join(" / ")
12435
+ : "没有变化",
12436
+ }),
12437
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "新增天数" }),
12438
+ jsx.jsx("span", {
12439
+ className: "balance-settings__sync-val",
12440
+ children: Number(calendarSync.result?.added ?? 0) > 0
12441
+ ? calendarSync.result.added + " 天"
12442
+ : "0 天(已是最新)",
12443
+ }),
12444
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "日历总量" }),
12445
+ jsx.jsx("span", {
12446
+ className: "balance-settings__sync-val",
12447
+ children: (calendar.count ?? 0) + " 天"
12448
+ + (Array.isArray(calendar.missing) && calendar.missing.length > 0
12449
+ ? "(" + calendar.missing.join(" / ") + " 待公布)"
12450
+ : ""),
12451
+ }),
12452
+ // 失败年份要进弹窗:光有「模型没跑成」看不出是哪一年没拿到。
12453
+ ...(Array.isArray(calendarSync.result?.failedYears) && calendarSync.result.failedYears.length > 0
12454
+ ? [
12455
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "失败年份" }),
12456
+ jsx.jsx("span", {
12457
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
12458
+ children: calendarSync.result.failedYears.join(" / ") + "(沿用本地数据)",
12459
+ }),
12460
+ ]
12461
+ : []),
12462
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "数据来源" }),
12463
+ jsx.jsx("span", {
12464
+ className: "balance-settings__sync-val",
12465
+ children: calendarSync.result?.usage
12466
+ ? "模型搜索国务院公告"
12467
+ : "没走模型(取的是第三方 JSON,未消耗 token)",
12468
+ }),
12469
+ // 「数据来源」说的是材料从哪来,「解析方式」说的是谁把材料变成日期 ——
12470
+ // 两件事,原来只写了前一半,用户对着弹窗问「怎么假期同步没有显示解析方式」
12471
+ // (2026-11-27)。模型名由服务端 calendarStatus() 的 `model` 带回来,
12472
+ // 走免费模式时是空串 → 显示内置规则。
12473
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "解析方式" }),
12474
+ jsx.jsx("span", {
12475
+ className: "balance-settings__sync-val" + (calendarSync.result?.usage ? " balance-settings__sync-val--warn" : ""),
12476
+ children: calendarSync.result?.usage
12477
+ ? [
12478
+ "模型解析",
12479
+ // 同价格那边:模型名单独占一行,整串跟着「模型解析」会从 "v4-" 后面硬断
12480
+ jsx.jsx("span", { className: "balance-settings__sync-sub", children: "(" + (calendarSync.result?.model || "未知模型") + ")" }, "model"),
12481
+ ]
12482
+ : "内置规则(未走模型,未消耗 token)",
12483
+ }),
12484
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "本次消耗" }),
12485
+ jsx.jsx("span", {
12486
+ className: "balance-settings__sync-val" + (calendarSync.result?.usage ? " balance-settings__sync-val--cost" : ""),
12487
+ children: syncCostText(calendarSync.result?.usage),
12488
+ }),
12489
+ // 选了模型却没花钱,一定有个原因 —— 别让用户对着「未消耗 token」猜。
12490
+ // 用数组展开而不是 Fragment:项目的 jsx 工厂里没有 Fragment,别赌。
12491
+ ...(calendarSync.result?.modelSkipReason
12492
+ ? [
12493
+ jsx.jsx("span", { className: "balance-settings__sync-key", children: "模型没跑成" }),
12494
+ jsx.jsx("span", {
12495
+ className: "balance-settings__sync-val balance-settings__sync-val--warn",
12496
+ style: { wordBreak: "break-all", lineHeight: "17px" },
12497
+ children: calendarSync.result.modelSkipReason,
12498
+ }),
12499
+ ]
12500
+ : []),
12501
+ ],
12502
+ }),
12503
+ jsx.jsx("div", {
12504
+ className: "balance-settings__sync-note",
12505
+ children: "法定节假日全天按空闲价计费,调休上班的周末按工作日峰谷算。已写入本地配置,升级插件不会覆盖。",
12506
+ }),
12507
+ ],
12508
+ }),
12509
+ }),
12510
+
9701
12511
  // 关掉侧边栏入口后的提醒:直接用 DSH 官方 Modal 渲染。
9702
12512
  tipModal && sidebarTip
9703
12513
  ? jsx.jsx(tipModal, {