balance-dsh 2.1.8 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -695,12 +695,26 @@ window.__ModuleLoader__.load({
695
695
  时长与曲线与刷新白条 balance-wipe-head 完全一致(.58s cubic-bezier(.34,.7,.26,1))。 */
696
696
  .balance-footer__timeline-pointer{position:absolute;left:0;top:-1px;bottom:-1px;width:2px;margin-left:-1px;background:var(--dsw-alias-label-primary,#fff);box-shadow:0 0 3px rgba(255,255,255,.7),0 0 2px rgba(0,0,0,.55);pointer-events:none;z-index:2}
697
697
  .balance-footer__timeline-pointer--intro{animation:balance-ptr-in 580ms cubic-bezier(.34,.7,.26,1) both;will-change:left}
698
- /* 闸门没开时的样子:待在终点但**不可见**(2026-11-02 用户要求指针动画排队)。
699
- 不加这条的话,等闸门的这 640ms 里指针会明晃晃站在终点,闸门一开又跳回 3px 重滑 —— 看得见的闪。 */
700
- .balance-footer__timeline-pointer--pending{opacity:0}
701
- /* from 固定 = pct 0 的位置(0% + 3px 内缩);to 读元素上的自定义属性,即最终落点。
698
+ /* 闸门没开时的样子:**停在 0 点(00:00 的位置)但保持可见**(2026-11-02 第二十六轮)。
699
+ 用户原话:「加载插件之后 指针在0点处滑到当前时段 所以说指针全程不要消失在时段条上」。
700
+ 原来这里是 opacity:0(等闸门的这几百毫秒里指针看不见,闸门一开才从左边滑出来),
701
+ 看起来就是「指针先没了、再冒出来」。现在位置由 state 的 pct:0 决定,这里不再改透明度。
702
+ ⚠️ 别再往这条规则里塞 opacity:0 / visibility:hidden / display:none。 */
703
+ .balance-footer__timeline-pointer--pending{opacity:1}
704
+ /* from 固定 = pct 0 的位置(0% + 2px 内缩,= 组件的 inset,两处必须同值);to 读元素上的自定义属性,即最终落点。
702
705
  both 让动画结束后停在 to,摘掉 --intro 时 inline left 恰好同值,不会跳。 */
703
- @keyframes balance-ptr-in{from{left:3px}to{left:var(--balance-ptr-to,3px)}}
706
+ @keyframes balance-ptr-in{from{left:2px}to{left:var(--balance-ptr-to,2px)}}
707
+ /* 跨零点:从最右端扫回最左端(2026-11-02 用户:「从 23:59 到第二天 00:00 是从最右边向左滑到最左边」)。
708
+ 三个刻意的取舍:
709
+ 1) **不写 fill-mode**:动画一结束就回落到 inline left,而 to 与 inline left 同值,收尾看不出跳。
710
+ 写 both 反而会把 left 永久钉在动画终点,把此后每分钟的落位全盖住(入场那条必须 both,
711
+ 是因为它要靠 both 顶到 JS 摘类那一刻;这条不需要,所以也就不用定时器摘类)。
712
+ 2) 时长与色带换日的交叉淡入 BAND_FADE_MS(620ms)同值 —— 零点那一瞬是「指针扫回来 + 颜色淡过去」
713
+ 同一个动作,不该一快一慢。
714
+ 3) from 用 calc(100% - 2px) 而不是 100%:指针 2px 宽、以 left 为中心线,100% 会有一半被裁掉
715
+ (2px 与组件里的 inset 是同一个数,改一处必须两处一起改)。 */
716
+ .balance-footer__timeline-pointer--midnight{animation:balance-ptr-midnight 620ms linear}
717
+ @keyframes balance-ptr-midnight{from{left:calc(100% - 2px)}to{left:var(--balance-ptr-to,2px)}}
704
718
  /* ── 侧栏入口的红点 + 未读高亮 ─────────────────────────────────────────── */
705
719
  .balance-panel-icon{position:relative;display:inline-flex;align-items:center;justify-content:center}
706
720
  /* 未读时图标本身染成品牌色,比周围灰图标更跳 */
@@ -736,7 +750,7 @@ window.__ModuleLoader__.load({
736
750
  默认是 superellipse(1.5)——不覆盖的话 border-radius:50% 会被渲染成"圆角方形"
737
751
  (squircle),根本不是圆(2026-09-28 用户反馈「很奇怪啊」,截图是 squircle)。
738
752
  DSH 自己的 .pill 也是这么显式写 corner-shape:round 抵消的。 */
739
- .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)}
753
+ .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)}
740
754
  .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)}
741
755
  .balance-fab:active{transform:scale(.95)}
742
756
  /* 金额偏长时(如 ¥1234.56)自动收一号字,免得 60px 圆里挤爆 */
@@ -901,7 +915,9 @@ window.__ModuleLoader__.load({
901
915
  box-shadow:0 6px 18px rgba(0,0,0,.4),inset 0 0 0 1px rgba(255,255,255,.05);
902
916
  color:var(--dsw-alias-label-tertiary);
903
917
  -webkit-backdrop-filter:blur(10px) saturate(1.15);backdrop-filter:blur(10px) saturate(1.15);
904
- transition:box-shadow .16s linear}
918
+ /* ⚠️ 内联写 transition 会把整条覆盖掉(transition 不支持合并),所以淡出用的
919
+ opacity 过渡只能加在这条 CSS 里(2026-11-03 用户:「隐藏的时候淡出」)。 */
920
+ transition:box-shadow .16s linear,opacity .18s ease}
905
921
  /* ⚠️ hover 必须**自己重写 background**:基础规则 .balance-usage-line:hover 的
906
922
  rgba(127,127,127,.12) 是半透明底(那是给内联 pill 用的),压在卡片上会让实底变透明、
907
923
  露出后面的聊天内容。反馈交给 box-shadow 与文字色,底始终保持不透明。 */
@@ -2622,7 +2638,7 @@ const CN_CALENDAR_SOURCES = [
2622
2638
  // ─── 时段刻度条:色带固定 = 一整天,指针随时刻从左走到右 ────────────────
2623
2639
  // 轨道铺满当天 00:00 → 次日 00:00 的时段色带(不滚动),指针位置 = 现在时刻在当天的比例。
2624
2640
  // 指针每秒前进一次(pointerNow 独立节拍),CSS transition:left 1s linear 补成连续滑动;
2625
- // 跨零点那一帧用 --snap 关掉过渡,直接落到新一天的起点。
2641
+ // 稳态每分钟对齐一次直接落位;**跨零点**那一拍挂 --midnight,从右端扫回左端(见那条 CSS)。
2626
2642
  const DAY_MS = 24 * 3600000;
2627
2643
  /** 当天 00:00(北京时间)的毫秒时间戳。色带、指针、跨零点判定共用同一个基准。 */
2628
2644
  function dayStartOf(now) {
@@ -2632,6 +2648,16 @@ const CN_CALENDAR_SOURCES = [
2632
2648
  function pointerPercent(now) {
2633
2649
  return ((now - dayStartOf(now)) / DAY_MS) * 100;
2634
2650
  }
2651
+ /** 跨零点判定:返回这一拍所属的那一天 + 要不要「从右端扫回左端」。
2652
+ *
2653
+ * 只有**往前**跨天才扫(2026-11-02 用户要求)。时钟被调回去(NTP 校时 / 手动改系统时间 /
2654
+ * 换时区导致 dayStart 变小)就照旧直接落位 —— 那种情况下右→左的扫动没有意义,
2655
+ * 反而会让人以为时间真的走完了一天。
2656
+ * 一次跨多天(机器睡眠 / 笔记本合盖过夜)也只扫一次,不连播。 */
2657
+ function pointerSweepPlan(prevDayStart, now) {
2658
+ const dayStart = dayStartOf(now);
2659
+ return { dayStart, sweep: dayStart > prevDayStart };
2660
+ }
2635
2661
  /** 生成刻度条:当天色带渐变 + 时段文字 + 指针位置。
2636
2662
  * @returns {{ gradient: string, pointerPct: number }} */
2637
2663
  // 纯函数结果缓存:buildTimeline(now) 完全由 now 决定(内部 currentPeriod 都显式传了 t),
@@ -3102,17 +3128,14 @@ const CN_CALENDAR_SOURCES = [
3102
3128
  // 而 `costPending` 会一直盖到响应回来为止。
3103
3129
  const SESSION_USAGE_DELAY_MS = 240;
3104
3130
 
3105
- /** 「今日」金额的显示精度:数额越小位数越多,大了就逐级省略。
3106
- * 用户 2026-10-31:如果数额小可以显示到小数点后 4 位,越大就相应省略一位。
3107
- * 固定两位时小额永远是 ¥0.00(看不到变化),大额又显得啰嗦。 */
3108
- function todayDecimals(value) {
3109
- const v = Math.abs(Number(value));
3110
- if (!Number.isFinite(v)) return 2;
3111
- if (v < 1) return 4;
3112
- if (v < 10) return 3;
3113
- if (v < 100) return 2;
3114
- if (v < 1000) return 1;
3115
- return 0;
3131
+ /** 「今日」金额的显示精度:**固定 2 位**(2026-11-03 用户:「今日消耗固定显示到小数点第二位」,
3132
+ * 截图里收起态卡片是 `今日 ¥0.6494`)。
3133
+ * 早先是按额度分档(<1 → 4 位、<10 → 3 位、<100 → 2 位、<1000 → 1 位、≥1000 → 0 位,
3134
+ * 2026-10-31 用户要求「数额小显示 4 位」)。分档有两个毛病:四位小数在 11px 的卡片里太长,
3135
+ * 而且档位切换时滚动格子(`buildRollCells`)的位数会变、整串数字要重排一次。
3136
+ * 函数名与签名保持不变:所有调用点、以及 selftest 抽函数真跑的那几条都还走这里。 */
3137
+ function todayDecimals() {
3138
+ return 2;
3116
3139
  }
3117
3140
 
3118
3141
  // ─── 加载动画的排队闸门(2026-11-02 第六轮,用户要求)────────────────────
@@ -3178,6 +3201,49 @@ const CN_CALENDAR_SOURCES = [
3178
3201
  function floatShouldShowNow() {
3179
3202
  return Date.now() >= loadAnimDoneAt();
3180
3203
  }
3204
+
3205
+ // ─── 窄窗口直接隐藏两张浮卡(2026-11-03 用户)──────────────────────────────
3206
+ // 用户原话:「不让小浮窗显示到外面去了 窗口缩到最小的时候 这俩悬浮窗直接隐藏」,并圈出
3207
+ // 左下余额卡(¥8.89 / 今日 / 高峰)与右下「本会话消耗估算 ¥31.02」。
3208
+ // 主窗口最小宽度 520,这俩卡合计约 213px 宽,窄窗里必然压在聊天框与输入框上;
3209
+ // 页面又画不到窗口外面(出窗那套已回滚),所以到这条线就把两块整个藏掉。
3210
+ // 860 是「两块卡 + 输入框还摆得下」的下限:再窄就开始盖住输入框的左右两端。
3211
+ const NARROW_HIDE_WIDTH = 860;
3212
+ const NARROW_FADE_MS = 180; // 与 CSS 里那条 opacity .18s 同值 —— 淡出结束才许真藏
3213
+ /** 窗口宽到不下两张浮卡时返回 `{ narrow, gone }`:
3214
+ * · `narrow` = 该开始淡出(调用处写 `opacity:0` + `pointer-events:none`);
3215
+ * · `gone` = 淡出演完了,这时候才写 `visibility:hidden`
3216
+ * (visibility 一设就立刻不可见,同步写就等于没有淡出)。
3217
+ * 首帧窗口本来就窄时 `gone` 初值即 true —— 页面一打开就是藏着的,不该闪一下淡出。
3218
+ * ⚠️ 一律用 `visibility`/`opacity`,不用 display:none、不卸载:`.balance-fab` 的遮挡判定
3219
+ * 要靠 `getBoundingClientRect`(display:none 的盒子量出来全 0,判定会永远"没被压住"),
3220
+ * `.balance-usage-line` 还是离场探测与可见性轮询的锚点,抽掉会被误判成「消耗行没开」。 */
3221
+ function useNarrowWindow() {
3222
+ const read = () => (typeof window === "undefined" ? false : (window.innerWidth || 0) < NARROW_HIDE_WIDTH);
3223
+ const [narrow, setNarrow] = react.useState(read);
3224
+ const [gone, setGone] = react.useState(read);
3225
+ react.useEffect(() => {
3226
+ const sync = () => setNarrow(read());
3227
+ sync(); // 重挂载(切会话/切视图)时 innerWidth 可能已经变了
3228
+ window.addEventListener("resize", sync);
3229
+ // resize 在拖拽窗口边缘时会被节流,多挂一个 RO 让「缩到最小」那一下立刻生效
3230
+ const ro = typeof ResizeObserver === "function" ? new ResizeObserver(sync) : null;
3231
+ if (ro) ro.observe(document.documentElement);
3232
+ return () => {
3233
+ window.removeEventListener("resize", sync);
3234
+ if (ro) ro.disconnect();
3235
+ };
3236
+ }, []);
3237
+ react.useEffect(() => {
3238
+ if (!narrow) {
3239
+ setGone(false); // 变宽:立刻恢复可见,再让 opacity 自己淡进来
3240
+ return undefined;
3241
+ }
3242
+ const id = setTimeout(() => setGone(true), NARROW_FADE_MS);
3243
+ return () => clearTimeout(id);
3244
+ }, [narrow]);
3245
+ return { narrow, gone };
3246
+ }
3181
3247
  /** 这次挂载要不要演入场:**整页只演一次**(切会话重挂载不再重播)。 */
3182
3248
  function floatEnterPlan() {
3183
3249
  return floatEnterPlayed ? "instant" : "replay";
@@ -3972,12 +4038,16 @@ function TimelinePointer() {
3972
4038
  const expired = Date.now() - PLUGIN_LOADED_AT > POINTER_INTRO_MAX_AGE_MS;
3973
4039
  const wantIntro = !pointerIntroDone && !expired;
3974
4040
  // 排队(2026-11-02 用户要求「指针的动画排队 插件加载完再开始」):
3975
- // 闸门还没开就先挂 --pending(opacity:0)待在终点,等 loadAnimDoneAt() 到了再挂 --intro
3976
- // 从 3px 滑过来。注意**不能**直接挂 --intro 挂着 CSS 动画等它 —— 那动画是从插入时刻起跑的,
3977
- // 不存在"延迟起播"这回事;而先显示终点位置又会看得见闪一下,所以中间需要这个隐形态。
4041
+ // 闸门还没开就先挂 --pending 待在**0 点**,等 loadAnimDoneAt() 到了再挂 --intro
4042
+ // 从 3px 滑到当前时段。
4043
+ // ⚠️ 注意**不能**直接挂 --intro 挂着 CSS 动画等它 —— 那动画是从插入时刻起跑的,
4044
+ // 不存在"延迟起播"这回事。
4045
+ // ⚠️ 也**不能**像原来那样「待在终点 + 不可见」:用户 2026-11-02 第二十六轮要求
4046
+ // 「指针全程不要消失在时段条上」,所以待命位置必须是 0 点、而且看得见 —— 闸门一开
4047
+ // 顺着同一个点往右滑(keyframes from:3px 正好等于 0 点的落点),全程连续、不闪不消失。
3978
4048
  const waiting = wantIntro && Date.now() < loadAnimDoneAt();
3979
4049
  return {
3980
- pct: pointerPercent(Date.now()),
4050
+ pct: waiting ? 0 : pointerPercent(Date.now()),
3981
4051
  intro: wantIntro && !waiting,
3982
4052
  pending: waiting,
3983
4053
  };
@@ -3995,10 +4065,19 @@ function TimelinePointer() {
3995
4065
  const scheduleIdle = () => {
3996
4066
  idleTimer = setTimeout(tick, idleIn(Date.now()));
3997
4067
  };
4068
+ // 上一拍所属的那一天(北京时间 00:00 起点)。挂载时初始化 → 打开页面那一刻不会误播扫回动画。
4069
+ let lastDayStart = dayStartOf(Date.now());
4070
+ // 跨零点的次数,兼作 span 的 key:每次跨天都 +1 让节点重挂,CSS animation 才会重新起播
4071
+ // (只靠 class 的 true→false→true 在「一次睡过好几天」时会漏掉一次重播)。
4072
+ let sweepSeq = 0;
3998
4073
  function tick() {
3999
- // 稳态:不带动画直接落位(每分钟才动 0.069%,跳过去看不出来),
4000
- // 下一拍对齐到下一个整分钟。跨零点也走这里,不会反向滑回去。
4001
- setView({ pct: pointerPercent(Date.now()), intro: false, pending: false });
4074
+ // 稳态:不带动画直接落位(每分钟才动 0.069%,跳过去看不出来),下一拍对齐到下一个整分钟。
4075
+ // 跨零点例外:那一拍带上 sweep,指针从右端扫回左端(见 CSS 的 --midnight)。
4076
+ const now = Date.now();
4077
+ const plan = pointerSweepPlan(lastDayStart, now);
4078
+ lastDayStart = plan.dayStart;
4079
+ if (plan.sweep) sweepSeq += 1;
4080
+ setView({ pct: pointerPercent(now), intro: false, pending: false, sweep: sweepSeq });
4002
4081
  scheduleIdle();
4003
4082
  }
4004
4083
  /** 闸门开:把落点按「现在」重算一次(等闸门这几百毫秒里时刻在走),再挂 --intro 起播。 */
@@ -4028,20 +4107,30 @@ function TimelinePointer() {
4028
4107
  // 依赖故意为空:只在挂载时读一次初值,之后由 CSS animation + 分钟对齐自己跑。
4029
4108
  // eslint-disable-next-line react-hooks/exhaustive-deps
4030
4109
  }, []);
4031
- // 刻度两端各留 3px 余量:指针 2px 宽、margin-left 让它以 left 为中心线,直接贴 0%/100%
4110
+ // 刻度两端各留 2px 余量:指针 2px 宽、margin-left 让它以 left 为中心线,直接贴 0%/100%
4032
4111
  // 会有一半被父级 overflow 裁掉,看着就像指针跑到轨道外面去了。
4033
- // 把 [0,100] 线性压进 [3px, 100% - 3px]:中心线 = inset + (p/100) × (宽 - 2 × inset),
4112
+ // 把 [0,100] 线性压进 [2px, 100% - 2px]:中心线 = inset + (p/100) × (宽 - 2 × inset),
4034
4113
  // 展开成 calc 就是「p% + inset px - (p/100) × 2 × inset px」。
4114
+ // ⚠️ 2026-11-02 第二十七轮:3px → 2px(用户「指针的0点往左一个像素吧」)。
4115
+ // `inset` 与两条 keyframes 的端点(`balance-ptr-in{from:2px}` / `balance-ptr-midnight{from:calc(100% - 2px)}`)
4116
+ // **必须同值**:差 1px 的话「待命 0 点 → 入场起跳」和「跨零点扫回起点」都会当场跳一下。
4035
4117
  const pct = view.pct;
4036
- const inset = 3;
4118
+ const inset = 2;
4037
4119
  const shift = inset - (pct / 100) * 2 * inset;
4038
4120
  const pos = "calc(" + pct.toFixed(4) + "% + " + shift.toFixed(2) + "px)";
4121
+ // 跨零点扫回:次数兼作 key(每次跨天都重挂,animation 才会重播)。
4122
+ // 入场 / 隐身排队期间不挂 —— 那两个动作优先,别在首屏那一刻抢同一根竖条。
4123
+ const sweepSeq = view.sweep || 0;
4124
+ const sweepClass =
4125
+ !view.intro && !view.pending && sweepSeq > 0 ? " balance-footer__timeline-pointer--midnight" : "";
4039
4126
  return jsx.jsx("span", {
4040
- className: view.intro
4041
- ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--intro"
4042
- : view.pending
4043
- ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--pending"
4044
- : "balance-footer__timeline-pointer",
4127
+ key: "pointer-" + sweepSeq,
4128
+ className:
4129
+ (view.intro
4130
+ ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--intro"
4131
+ : view.pending
4132
+ ? "balance-footer__timeline-pointer balance-footer__timeline-pointer--pending"
4133
+ : "balance-footer__timeline-pointer") + sweepClass,
4045
4134
  // left 给稳态用;--balance-ptr-to 是 keyframes 的终点(两者取值相同)。
4046
4135
  style: { left: pos, "--balance-ptr-to": pos },
4047
4136
  });
@@ -4121,6 +4210,9 @@ function makeTodayFlowStyle() {
4121
4210
  const state = useBalance();
4122
4211
  const settings = useSettings();
4123
4212
  const today = useToday();
4213
+ // 窗口缩到很窄时整块不显示(2026-11-03 用户:「窗口缩到最小的时候 这俩悬浮窗直接隐藏」)。
4214
+ // ⚠️ 必须待在这一片(所有 return 之前),理由见下面这条注释。
4215
+ const narrowWindow = useNarrowWindow();
4124
4216
  // ⚠️⚠️ 今日金额的派生值与 hook 必须待在这一片(所有 return 之前)。
4125
4217
  // 组件下半部分有多条早退分支:state.status === "error" / !state.balance / depleted,
4126
4218
  // 首帧 balance 还是 null 就走 2778 那条 return;等数据回来那一帧才继续往下执行。
@@ -4129,7 +4221,7 @@ function makeTodayFlowStyle() {
4129
4221
  // 错误边界一兜,左下角就空了(2026-10-31 用户反馈「左下角的显示消失了」)。
4130
4222
  // 记牢:BalanceFooter 里新增的任何 hook 都只能加在这一片。
4131
4223
  const todayCost = today !== null && Number.isFinite(Number(today.cost)) ? Number(today.cost) : null;
4132
- // 显示精度随额度分档(<1 → 4 位 … ≥1000 → 0 位),见 todayDecimals。
4224
+ // 显示精度固定 2 位(见 todayDecimals)。
4133
4225
  const todayText = todayCost === null ? null : todayCost.toFixed(todayDecimals(todayCost));
4134
4226
  const [todayRoll, setTodayRoll] = react.useState(null);
4135
4227
  // 今日等待胶囊的光团起始相位:**每次挂载随机一次**(见 makeTodayFlowStyle 的注释)。
@@ -4844,7 +4936,12 @@ function makeTodayFlowStyle() {
4844
4936
  fabStyle.bottom = fabLeft + "px";
4845
4937
  // 位置未定之前不可见(见上面 fabVisible 的说明)。visibility 而不是 display:none ——
4846
4938
  // 后者会让元素没有盒子、getBoundingClientRect 全 0,遮挡判断就永远测不出来。
4847
- if (!fabVisible) fabStyle.visibility = "hidden";
4939
+ if (!fabVisible || narrowWindow.gone) fabStyle.visibility = "hidden";
4940
+ // 窄窗口:先淡出(opacity 过渡写在 CSS 里),淡完才由 gone 挂 visibility
4941
+ if (narrowWindow.narrow) {
4942
+ fabStyle.opacity = 0;
4943
+ fabStyle.pointerEvents = "none"; // opacity:0 仍然吃点击,必须一起关掉
4944
+ }
4848
4945
  const anchorStyle = { left: fabLeft + "px" };
4849
4946
  const total = Number.parseFloat(b.total_balance ?? "0");
4850
4947
  // 「余额不足」必须听服务端的 is_available,**不能**用 total <= 0 推断
@@ -4897,7 +4994,11 @@ function makeTodayFlowStyle() {
4897
4994
  // 矩形卡还挂在 CSS 的 44px 上(两种布局手感不一致)。
4898
4995
  rectStyle.bottom = rectLeft + "px";
4899
4996
  // 同样要带可见性控制,否则矩形卡会先闪一下兜底位置(用户反馈的就是这种浮窗)
4900
- if (!fabVisible) rectStyle.visibility = "hidden";
4997
+ if (!fabVisible || narrowWindow.gone) rectStyle.visibility = "hidden";
4998
+ if (narrowWindow.narrow) {
4999
+ rectStyle.opacity = 0;
5000
+ rectStyle.pointerEvents = "none";
5001
+ }
4901
5002
  // ⚠️ 余额**只用数字**,绝不用展开态的 `rollCells`:那个基于 `totalText`
4902
5003
  // =「17.87 CNY」,塞进 81px 会被 `overflow:hidden` 裁成「17.87 CN\」
4903
5004
  // (2026-10-31 实测截图)。币种在收起态没有横向空间,展开态才显示。
@@ -6261,6 +6362,8 @@ function UsageCostLine({ useProjection, sessionId }) {
6261
6362
  // ⚠️ 闸门用轮询而不是一次性 setTimeout:`loadAnimDoneAt()` 的起跑点会在「余额第一次出现」
6262
6363
  // 那一刻才定下来(noteBalanceAppeared),挂载时算出的终点可能偏早。
6263
6364
  const [floatShown, setFloatShown] = react.useState(() => floatShouldShowNow());
6365
+ // 窄窗口(窗口缩到最小附近)整块不显示,见 useNarrowWindow 的说明。
6366
+ const narrowWindow = useNarrowWindow();
6264
6367
  react.useEffect(() => {
6265
6368
  if (floatShown) return undefined;
6266
6369
  const id = setInterval(() => {
@@ -6935,7 +7038,10 @@ function UsageCostLine({ useProjection, sessionId }) {
6935
7038
  : { left: floatBox.left + "px", right: "auto", bottom: floatBox.bottom + "px" }),
6936
7039
  // 插件加载动画走完之前不显形(用户:「插件加载之前 会话消耗小窗不要加载」)。
6937
7040
  // 用 visibility 而不是不渲染:`.balance-usage-line` 必须留在 DOM 里(离场探测/轮询靠它)。
6938
- ...(floatShown ? null : { visibility: "hidden" }),
7041
+ // 窗口缩到很窄时整块藏起来(2026-11-03:「这俩悬浮窗直接隐藏」+「隐藏的时候淡出」):
7042
+ // 先 opacity 过渡到 0,`gone` 到点才挂 visibility(同步挂就等于没有淡出)。
7043
+ ...(narrowWindow.narrow ? { opacity: 0, pointerEvents: "none" } : null),
7044
+ ...(floatShown && !narrowWindow.gone ? null : { visibility: "hidden" }),
6939
7045
  },
6940
7046
  // 单行两列:第一列「本会话消耗估算」的字样,第二列金额胶囊(迷雾 / 开窗 / 逐位滚全在)。
6941
7047
  // 2026-11-02 第十一轮:用户「只显示本会话的消耗 不要今日消耗 然后调小一点 太大了
package/lib/index.js CHANGED
@@ -1077,7 +1077,7 @@ function formatBalance(balance) {
1077
1077
  // | { status:"failed" } (网络失败;官方明确“失败绝不变成 0 余额”)
1078
1078
  // client 是 AccountClientMetadata(version / locale / timezoneOffsetSeconds),
1079
1079
  // 缺字段会在平台侧组装请求头时抛错,所以三个字段都要给。
1080
- const PLUGIN_VERSION = "2.1.8";
1080
+ const PLUGIN_VERSION = "2.2.0";
1081
1081
 
1082
1082
  /** 斜杠命令名(2026-10-31 定案:用带作者后缀的全名,避免和别的余额插件撞车,也不设备用名)。
1083
1083
  * ⚠️ DSH 的 COMMAND_NAME = /^[a-z][a-z0-9_-]*$/u —— **只允许小写**。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "balance-dsh",
3
- "version": "2.1.8",
3
+ "version": "2.2.0",
4
4
  "description": "在 DeepSeek Harness 中显示 DeepSeek 账户余额和当前会话 token/费用消耗(含高峰/空闲峰谷计费)。仅支持 DeepSeek 官方模型与账号,暂不支持其他大模型。",
5
5
  "author": "Rannist",
6
6
  "type": "module",