dsh-balance-ball 0.1.0 → 0.1.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Star_Robin
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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.0",
3
+ "version": "0.1.2",
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": {
@@ -41,6 +43,20 @@
41
43
  }
42
44
  },
43
45
  "license": "MIT",
46
+ "repository": {
47
+ "type": "git",
48
+ "url": "git+https://github.com/StarRob1n/dsh-account-balance.git"
49
+ },
50
+ "homepage": "https://github.com/StarRob1n/dsh-account-balance#readme",
51
+ "keywords": [
52
+ "deepseek",
53
+ "deepseek-harness",
54
+ "dsh",
55
+ "dsh-plugin",
56
+ "balance",
57
+ "billing",
58
+ "usage"
59
+ ],
44
60
  "engines": {
45
61
  "node": ">=20",
46
62
  "dsh": ">=0.2.0"
@@ -0,0 +1,4 @@
1
+ [
2
+ "assets/screenshot-ball.png",
3
+ "assets/screenshot-panel.png"
4
+ ]