dsh-plugin-greeting-bubble 1.5.0-beta.2 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +4 -3
  2. package/client.js +21 -1
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -30,10 +30,11 @@
30
30
 
31
31
  - 页面加载约 0.35 秒后,右下角(距右 20px、距底 84px,即输入框发送按钮上方)淡入**小机器人 + 气泡卡片**:`🤖 早上好,腾盛 · ¥12.34`(问候语按时间变化)。
32
32
  - **折叠态**只显示机器人 + 「问候语 · 金额」胶囊;**点击机器人或胶囊**展开详情,再点一次收起。
33
+ - 展开时**底边保持不动、向上生长**;即使挂在右下角,详情也不会溢出屏幕。
33
34
  - 机器人的状态会在视觉上体现:
34
35
  - 正常:主题蓝,偶尔眨眼;
35
36
  - 刷新中:天线闪烁;
36
- - 余额 <¥3:变成橙色;
37
+ - 余额 <¥8:变成橙色;
37
38
  - 连接断开:变成灰色并“闭眼”。
38
39
  - 展开后显示:账户名/联系方式、**连接状态(断开时可一键重连)**、**今日消费金额估算**、充值余额、最近更新时间,以及「用量」「充值」快捷入口。
39
40
  - 今日消费金额只显示金额(`≈ ¥x.xx`);口径是基准余额 − 当前余额,优先用**昨天最后一次读到的余额**(≈ 0 点余额),没有昨天数据则用**今天第一次读到的余额**;充值会使基准同步抬高,不计入消费。
@@ -103,7 +104,7 @@ git clone https://github.com/liwei169/dsh-plugin-greeting-bubble.git
103
104
  | 详情里的「重连」 | 连接断开时出现,点击立即重连 Host |
104
105
  | 详情里的「刷新」 | 立即刷新余额(不用等 60 秒) |
105
106
  | 详情里的「隐藏金额 / 显示金额」 | 切换隐私模式并记住 |
106
- | 余额低于 ¥3 | 机器人变橙,胶囊显示橙色圆点 |
107
+ | 余额低于 ¥8 | 机器人变橙,胶囊显示橙色圆点 |
107
108
  | 连接断开 | 机器人变灰、闭眼 |
108
109
  | 刷新页面 | 挂件再次出现,位置保持上次拖到的位置 |
109
110
  | 插件页关闭该包的开关 | 挂件立即消失(HMR 生效时无需刷新) |
@@ -168,7 +169,7 @@ const BALANCE_MAX_BACKOFF_MS = 300_000; // 连续失败后的最大退避
168
169
  `client.js` 顶部:
169
170
 
170
171
  ```js
171
- const LOW_BALANCE_CNY = 3; // 低于这个金额显示“余额不足”
172
+ const LOW_BALANCE_CNY = 8; // 低于这个金额显示“余额不足”
172
173
  ```
173
174
 
174
175
  隐私模式的状态保存在 localStorage 的 `dsh-greeting-bubble:privacy:v1`;想强制恢复“显示金额”,在控制台执行:
package/client.js CHANGED
@@ -38,7 +38,7 @@ window.__ModuleLoader__.load({
38
38
  const BALANCE_MAX_BACKOFF_MS = 300_000;
39
39
 
40
40
  /** Below this CNY amount the widget warns. */
41
- const LOW_BALANCE_CNY = 3;
41
+ const LOW_BALANCE_CNY = 8;
42
42
 
43
43
  /** Local-day consumption baseline; reset when the date changes. */
44
44
  const CONSUMPTION_KEY = 'dsh-greeting-bubble:consumption:v1';
@@ -510,6 +510,7 @@ window.__ModuleLoader__.load({
510
510
  const [refreshing, setRefreshing] = React.useState(false);
511
511
  const widgetRef = React.useRef(null);
512
512
  const dragRef = React.useRef(null);
513
+ const bottomAnchorRef = React.useRef(null);
513
514
  const suppressClickRef = React.useRef(false);
514
515
  const inFlightRef = React.useRef(null);
515
516
  const profileRef = React.useRef(null);
@@ -618,6 +619,23 @@ window.__ModuleLoader__.load({
618
619
  return () => { window.removeEventListener('resize', handleResize); };
619
620
  }, []);
620
621
 
622
+ // Keep the widget's bottom edge fixed while expanding: a widget anchored
623
+ // near the bottom edge then grows upward instead of running off-screen.
624
+ React.useEffect(() => {
625
+ const element = widgetRef.current;
626
+ const bottom = bottomAnchorRef.current;
627
+ if (!element || bottom === null) return;
628
+ bottomAnchorRef.current = null;
629
+ const rect = element.getBoundingClientRect();
630
+ const margin = 8;
631
+ const maxTop = Math.max(margin, window.innerHeight - rect.height - margin);
632
+ const top = Math.round(clamp(bottom - rect.height, margin, maxTop));
633
+ const left = Math.round(clamp(rect.left, margin, Math.max(margin, window.innerWidth - rect.width - margin)));
634
+ if (Math.abs(top - rect.top) > 0.5 || Math.abs(left - rect.left) > 0.5) {
635
+ setPosition({ x: left, y: top });
636
+ }
637
+ }, [expanded]);
638
+
621
639
  if (dismissed) return null;
622
640
  const greeting = label(greetingKeyForHour(new Date().getHours()), '你好,腾盛');
623
641
  const dismissLabel = label('dismiss', '关闭问候气泡');
@@ -652,6 +670,8 @@ window.__ModuleLoader__.load({
652
670
 
653
671
  /** Expand/collapse; the first expansion loads the account profile. */
654
672
  function toggleExpanded() {
673
+ const element = widgetRef.current;
674
+ if (element) bottomAnchorRef.current = element.getBoundingClientRect().bottom;
655
675
  setExpanded((current) => {
656
676
  const next = !current;
657
677
  if (next && profile === null) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-greeting-bubble",
3
- "version": "1.5.0-beta.2",
3
+ "version": "1.5.1",
4
4
  "description": "Shows a “你好,腾盛” speech bubble in the bottom-right corner of the DeepSeek Harness Web GUI.",
5
5
  "license": "MIT",
6
6
  "publishConfig": {