dsh-balance-ball 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,7 +1,11 @@
1
- # dsh-account-balance
1
+ # dsh-balance-ball
2
2
 
3
3
  DeepSeek Harness 插件:一个可拖动的悬浮球,常驻显示你的 **DeepSeek 账户余额**,点击展开详情面板,查看实时价格、今日价格走势和 token 消耗估算。
4
4
 
5
+ ![悬浮球](assets/screenshot-ball.png)
6
+
7
+ ![详情面板](assets/screenshot-panel.png)
8
+
5
9
  ## 功能
6
10
 
7
11
  - **悬浮球**:圆形、可拖动、可固定,颜色随余额状态变化(绿=充足、黄=少于10元、红=耗尽)
@@ -15,13 +19,13 @@ DeepSeek Harness 插件:一个可拖动的悬浮球,常驻显示你的 **Dee
15
19
  ### 方式一:npm
16
20
 
17
21
  ```bash
18
- dsh plugin add dsh-account-balance
22
+ dsh plugin add dsh-balance-ball
19
23
  ```
20
24
 
21
25
  ### 方式二:GitHub
22
26
 
23
27
  ```bash
24
- dsh plugin --profile web add github:<你的用户名>/dsh-account-balance
28
+ dsh plugin --profile web add github:StarRob1n/dsh-account-balance
25
29
  ```
26
30
 
27
31
  安装后重启 DSH,右下角会出现悬浮球。
Binary file
Binary file
package/lib/client.js CHANGED
@@ -330,17 +330,33 @@ window.__ModuleLoader__.load({
330
330
  function BalanceWidget() {
331
331
  const { state, reload } = useBalance();
332
332
  const [open, setOpen] = react.useState(false);
333
- // 位置状态:默认右下角,用 useState 驱动(拖动时更新,菜单跟随)
333
+ const STORE_KEY = "dsh-balance-ball/pos";
334
+ // 位置状态:优先从 localStorage 恢复上次位置,否则默认右下角
334
335
  const [pos, setPos] = react.useState(() => {
335
336
  const vv = typeof window !== "undefined" ? window.visualViewport : null;
336
337
  const vw = (vv && vv.width) || (typeof window !== "undefined" ? document.documentElement.clientWidth : 0) || (typeof window !== "undefined" ? window.innerWidth : 0);
337
338
  const vh = (vv && vv.height) || (typeof window !== "undefined" ? document.documentElement.clientHeight : 0) || (typeof window !== "undefined" ? window.innerHeight : 0);
338
- return {
339
- left: vw > 0 ? vw - BALL_SIZE - 20 : 100,
340
- top: vh > 0 ? vh - BALL_SIZE - 100 : 200,
341
- };
339
+ const defLeft = vw > 0 ? vw - BALL_SIZE - 20 : 100;
340
+ const defTop = vh > 0 ? vh - BALL_SIZE - 100 : 200;
341
+ // 尝试恢复上次位置(越界则回退默认)
342
+ try {
343
+ const saved = JSON.parse(localStorage.getItem(STORE_KEY) || "null");
344
+ if (saved && typeof saved.left === "number" && typeof saved.top === "number") {
345
+ const maxX = vw - BALL_SIZE;
346
+ const maxY = vh - BALL_SIZE;
347
+ return {
348
+ left: Math.max(0, Math.min(saved.left, maxX)),
349
+ top: Math.max(0, Math.min(saved.top, maxY)),
350
+ };
351
+ }
352
+ } catch (_) {}
353
+ return { left: defLeft, top: defTop };
342
354
  });
343
- const move = react.useCallback((p) => setPos(p), []);
355
+ const move = react.useCallback((p) => {
356
+ setPos(p);
357
+ // 持久化位置,重启后恢复
358
+ try { localStorage.setItem(STORE_KEY, JSON.stringify(p)); } catch (_) {}
359
+ }, []);
344
360
  const close = react.useCallback(() => setOpen(false), []);
345
361
  const toggle = react.useCallback(() => setOpen((o) => !o), []);
346
362
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-balance-ball",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "悬浮球显示 DeepSeek 账户余额(OAuth 登录),附带实时价格、今日价格走势与 token 消耗估算区间。可拖动、可固定,点击展开详情面板。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -13,7 +13,9 @@
13
13
  "lib/index.js",
14
14
  "lib/client.js",
15
15
  "cordis.patch.yml",
16
- "README.md"
16
+ "README.md",
17
+ "assets",
18
+ "screenshots.json"
17
19
  ],
18
20
  "dsh": {
19
21
  "bundle": {
@@ -0,0 +1,4 @@
1
+ [
2
+ "assets/screenshot-ball.png",
3
+ "assets/screenshot-panel.png"
4
+ ]