dsh-whale-widget 0.1.0 → 0.2.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/README.md CHANGED
@@ -1,121 +1,140 @@
1
- # DSH 小鲸鱼余额挂件(DeepSeek Balance Whale Widget)
2
-
3
- DeepSeek Harness(DSH)Web 界面右下角的常驻余额挂件:本地小鲸鱼气泡图 + DeepSeek API 余额,每次打开界面自动启用。本项目是标准 DSH 插件包,可通过 `dsh plugin` 安装/卸载。
4
-
5
- ## 特性
6
-
7
- - 🐋 常驻自启:随 DSH Web 界面每次打开自动出现(标准 DSH bundle 插件)
8
- - 💰 余额:60 秒自动刷新 + 点击手动刷新;余额变化时数字**滚动动画**;瞬时网络抖动自动沿用最近余额不报错
9
- - 🖱️ 拖拽 + **四边四分之一吸附**(左/右/上/下,角落可组合)
10
- - 🔄 左吸附时整体**水平镜像翻转**(文字同步反向、带动画)
11
- - 🧸 **按压 Q 弹**玩偶效果(按压时底部坐标不变)
12
- - 🎚️ 悬停显示大小调节按钮(0.6–1.4 倍,尺寸记忆)
13
- - 📐 随浏览器窗口自动缩放;文字位置/字号与图片联动
14
-
15
- ## 目录结构
16
-
17
- ```text
18
- dsh-whale-widget/
19
- ├── package.json # DSH bundle 插件元数据
20
- ├── README.md # 本文件
21
- ├── cordis.patch.yml # 插件挂载声明
22
- ├── lib/
23
- │ └── index.js # 宿主侧插件本体
24
- ├── assets/
25
- │ └── DSniang02.png # 小鲸鱼气泡图
26
- └── whale-widget-prompt.md # 完整规格/维护提示词
27
- ```
28
-
29
- ## 安装
30
-
31
- ### 方式 A:本地开发安装(当前项目)
32
-
33
- 在项目根目录(`DeepSeek-Balance-Whale-Widget-main`)执行:
34
-
35
- ```powershell
36
- dsh plugin --profile web add link:.\dsh-whale-widget
37
- ```
38
-
39
- 说明:
40
-
41
- - `dsh plugin` 会把参数转发给 pnpm,并在成功后自动把 `dsh-whale-widget` 加入 `dsh.profile.bundles`
42
- - 使用 `link:` 会在 profile 的 `node_modules` 里链接到当前源码目录,方便继续改代码
43
- - 安装完成后重启 `dsh web`,再 F5 刷新浏览器
44
- - **如果之后移动了源码目录**,必须重新到新的项目根目录执行一次:
45
- ```powershell
46
- dsh plugin --profile web add link:.\dsh-whale-widget
47
- ```
48
- 因为 `link:` 记录的是源目录的绝对路径;移动后旧链接会失效。若提示已存在/冲突,可先 `dsh plugin --profile web remove dsh-whale-widget` 再重新 add。
49
-
50
- ### 方式 B:发布到 npm 后安装
51
-
52
- 如果你把这个包发布到 npm:
53
-
54
- ```powershell
55
- cd dsh-whale-widget
56
- npm publish
57
- ```
58
-
59
- 然后任意机器上安装:
60
-
61
- ```powershell
62
- dsh plugin --profile web add dsh-whale-widget
63
- ```
64
-
65
- ## 卸载
66
-
67
- ```powershell
68
- dsh plugin --profile web remove dsh-whale-widget
69
- ```
70
-
71
- ## 从旧手动安装升级
72
-
73
- 如果你之前按旧方式手动安装过(复制 `whale-balance.mjs` + 改 `cordis.patch.yml`),先清理:
74
-
75
- ```powershell
76
- $web = "$env:USERPROFILE\.dsh\profiles\web"
77
-
78
- Remove-Item "$web\whale-balance.mjs" -ErrorAction SilentlyContinue
79
- Remove-Item "$web\DSniang02.png" -ErrorAction SilentlyContinue
80
- ```
81
-
82
- 然后编辑 `$web\cordis.patch.yml`,删除这段旧补丁:
83
-
84
- ```yaml
85
- - insert:
86
- - id: whale-balance-widget
87
- name: ./whale-balance.mjs?v=1
88
- ```
89
-
90
- 如果里面只有这段,直接改成:
91
-
92
- ```yaml
93
- []
94
- ```
95
-
96
- 清理后再执行上面的安装命令。
97
-
98
- ## 验证
99
-
100
- ```powershell
101
- dsh --profile web --dump-config | Select-String -Pattern "whale"
102
-
103
- curl http://127.0.0.1:3080/dsh-whale/image.png
104
- curl http://127.0.0.1:3080/dsh-whale/balance.json
105
- ```
106
-
107
- - `/dsh-whale/image.png` → 200 `image/png`
108
- - `/dsh-whale/balance.json` → 200,含 `{"ok":true,"totalBalance":...,"currency":"CNY"}`
109
- - 浏览器 F5 后右下角出现挂件
110
-
111
- ## 常见问题
112
-
113
- - **挂件不出现**:确认 `dsh plugin add` 成功;`dsh --profile web --dump-config` 里能看到 `dsh-whale-widget`;重启 `dsh web` 后 F5。
114
- - **图片不显示**:确认 `assets/DSniang02.png` 在插件包内,且没有把旧文件放在 profile 里占用了同名路由。
115
- - **余额报「未配置 DEEPSEEK_API_KEY」**:去 DSH 配置凭据。
116
- - **本地开发改了代码不生效**:使用 `link:` 安装时,修改源码后重启 `dsh web`(ESM 模块缓存);如果用已发布版本,需要 `npm publish` 新版本后 `dsh plugin --profile web update dsh-whale-widget`。
117
- - **自定义图片**:必须是 1026×1026、气泡几何一致(中心 455,247、长轴 710、纵轴 430),否则按 `whale-widget-prompt.md` 调整文字定位参数。
118
-
119
- ## 开发与维护
120
-
121
- 完整规格、视觉参数、架构结论和生成提示词见 `whale-widget-prompt.md`。修改文字位置、颜色、动画、吸附逻辑时参考该文件。
1
+ # DSH 小鲸鱼余额挂件(DeepSeek Balance Whale Widget)
2
+
3
+ DeepSeek Harness(DSH)Web 界面右下角的常驻余额挂件:小鲸鱼气泡图 + DeepSeek API 余额 + 今日已用,每次打开界面自动启用。本项目是标准 DSH 插件包,可通过 `dsh plugin` 安装/卸载。
4
+
5
+ ## 特性
6
+
7
+ - 🐋 **常驻自启**:随 DSH Web 界面每次打开自动出现(标准 DSH bundle 插件)
8
+ - 💰 **余额**:60 秒自动刷新 + 点击鲸鱼手动刷新;余额变化时数字**滚动动画**;瞬时网络抖动自动沿用最近余额不报错
9
+ - 📊 **今日已用**:两种模式任选(见下),显示今日消耗金额
10
+ - **小鲸鱼记账(推荐,免令牌)**:不需要任何会话令牌,鲸鱼娘每次观测余额后用余额差值自动记账(`.dshw-usage.json`,跨天自动归零归档)
11
+ - **实时·令牌**:填入平台会话令牌后直接调用平台用量接口,按**峰谷定价**(空闲 9:00–12:00 14:00–18:00 之外 / 高峰 9–12 与 14–18 点)实时换算今日已用
12
+ - 🖱️ **拖拽 + 四边四分之一吸附**(左/右/上/下,角落可组合)
13
+ - 🔄 左吸附时整体**水平镜像翻转**(文字同步反向、带动画)
14
+ - 🧸 **按压 Q 弹**玩偶效果(按压时底部坐标不变)
15
+ - 🎚️ **汉堡菜单**(悬停鲸鱼右上角出现):大小滑块(0.6–2.5 倍,尺寸记忆)、音效切换(小黄鸭 / 音效1)、音量调节、用量模式选择
16
+ - 🔊 **音效**:按压/松手音效(可选包内 mp3,缺失时静默降级)
17
+ - 💬 **随机台词**:点击气泡切换随机台词段(6 组加权随机,含峰谷提示/今日已用/卖萌吐槽),再点一次关闭;气泡总显示 5 秒自动收起
18
+ - 📐 随浏览器窗口自动缩放;文字位置/字号与图片联动
19
+
20
+ ## 目录结构
21
+
22
+ ```text
23
+ dsh-whale-widget/
24
+ ├── package.json # DSH bundle 插件元数据
25
+ ├── README.md # 本文件
26
+ ├── cordis.patch.yml # 插件挂载声明
27
+ ├── lib/
28
+ │ └── index.js # 宿主侧插件本体
29
+ ├── assets/
30
+ │ ├── DSniang1.png # 小鲸鱼本体(cut-out,气泡由代码绘制)
31
+ │ ├── Ya1.mp3 / Ya2.mp3 # 小黄鸭音效(可选)
32
+ │ └── D1.mp3 / D2.mp3 # 音效1(可选)
33
+ └── whale-widget-prompt.md # 完整规格/维护提示词
34
+ ```
35
+
36
+ ## 安装
37
+
38
+ ### 方式 A:本地开发安装(当前项目)
39
+
40
+ 在项目根目录(`DeepSeek-Balance-Whale-Widget-main`)执行:
41
+
42
+ ```powershell
43
+ dsh plugin --profile web add link:.\dsh-whale-widget
44
+ ```
45
+
46
+ 说明:
47
+
48
+ - `dsh plugin` 会把参数转发给 pnpm,并在成功后自动把 `dsh-whale-widget` 加入 `dsh.profile.bundles`
49
+ - 使用 `link:` 会在 profile 的 `node_modules` 里链接到当前源码目录,方便继续改代码
50
+ - 安装完成后重启 `dsh web`,再 F5 刷新浏览器
51
+ - **如果之后移动了源码目录**,必须重新到新的项目根目录执行一次:
52
+ ```powershell
53
+ dsh plugin --profile web add link:.\dsh-whale-widget
54
+ ```
55
+ 因为 `link:` 记录的是源目录的绝对路径;移动后旧链接会失效。若提示已存在/冲突,可先 `dsh plugin --profile web remove dsh-whale-widget` 再重新 add。
56
+
57
+ ### 方式 B:发布到 npm 后安装
58
+
59
+ 如果你把这个包发布到 npm:
60
+
61
+ ```powershell
62
+ cd dsh-whale-widget
63
+ npm publish
64
+ ```
65
+
66
+ 然后任意机器上安装:
67
+
68
+ ```powershell
69
+ dsh plugin --profile web add dsh-whale-widget
70
+ ```
71
+
72
+ ## 卸载
73
+
74
+ ```powershell
75
+ dsh plugin --profile web remove dsh-whale-widget
76
+ ```
77
+
78
+ ## 从旧手动安装升级
79
+
80
+ 如果你之前按旧方式手动安装过(复制 `whale-balance.mjs` + 改 `cordis.patch.yml`),先清理:
81
+
82
+ ```powershell
83
+ $web = "$env:USERPROFILE\.dsh\profiles\web"
84
+
85
+ Remove-Item "$web\whale-balance.mjs" -ErrorAction SilentlyContinue
86
+ Remove-Item "$web\whale-balance.cjs" -ErrorAction SilentlyContinue
87
+ Remove-Item "$web\DSniang1.png" -ErrorAction SilentlyContinue
88
+ Remove-Item "$web\DSniang02.png" -ErrorAction SilentlyContinue
89
+ ```
90
+
91
+ 然后编辑 `$web\cordis.patch.yml`,删除这段旧补丁:
92
+
93
+ ```yaml
94
+ - insert:
95
+ - id: whale-balance-widget
96
+ name: ./whale-balance.mjs?v=1
97
+ ```
98
+
99
+ 如果里面只有这段,直接改成:
100
+
101
+ ```yaml
102
+ []
103
+ ```
104
+
105
+ 清理后再执行上面的安装命令。
106
+
107
+ ## 凭据与用量模式
108
+
109
+ - **余额**:需要 `DEEPSEEK_API_KEY`(在 DSH 凭据服务中配置),用于 `api.deepseek.com/user/balance`
110
+ - **实时·令牌模式**:需要 `DEEPSEEK_PLATFORM_TOKEN`(平台会话令牌,从浏览器 DevTools 的用量请求 `Authorization` 头获取),用于 `platform.deepseek.com/api/v0/usage/by_api_key/amount`
111
+ - **小鲸鱼记账模式(默认)**:不需要平台令牌,鲸鱼娘用余额差值自动记账,跨天自动归档
112
+
113
+ ## 验证
114
+
115
+ ```powershell
116
+ dsh --profile web --dump-config | Select-String -Pattern "whale"
117
+
118
+ curl http://127.0.0.1:3080/dsh-whale/image.png
119
+ curl http://127.0.0.1:3080/dsh-whale/balance.json
120
+ curl http://127.0.0.1:3080/dsh-whale/size.json
121
+ ```
122
+
123
+ - `/dsh-whale/image.png` → 200 `image/png`
124
+ - `/dsh-whale/balance.json` → 200,含 `{"ok":true,"totalBalance":...,"currency":"CNY","todayUsage":...}`
125
+ - `/dsh-whale/size.json` → GET 返回 `{scale,sound,vol,soundSet,usageMode}`;PUT 写入
126
+ - 浏览器 F5 后右下角出现挂件
127
+
128
+ ## 常见问题
129
+
130
+ - **挂件不出现**:确认 `dsh plugin add` 成功;`dsh --profile web --dump-config` 里能看到 `dsh-whale-widget`;重启 `dsh web` 后 F5。
131
+ - **图片不显示**:确认 `assets/DSniang1.png` 在插件包内,且没有把旧文件放在 profile 里占用了同名路由。
132
+ - **余额报「未配置 DEEPSEEK_API_KEY」**:去 DSH 配置凭据。
133
+ - **今日已用显示 --**:记账模式下需要先跑一次余额观测(60 秒内自动完成);令牌模式需要配置 `DEEPSEEK_PLATFORM_TOKEN`。
134
+ - **没有声音**:确认 `assets/*.mp3` 在包内;若不想带音效文件,静默降级为无声音。
135
+ - **本地开发改了代码不生效**:使用 `link:` 安装时,修改源码后重启 `dsh web`(ESM 模块缓存);如果用已发布版本,需要 `npm publish` 新版本后 `dsh plugin --profile web update dsh-whale-widget`。
136
+ - **自定义图片**:气泡由代码绘制(SVG),鲸鱼本体为 cut-out PNG,放在右下角 59.45%;换图需保证透明背景 cut-out,否则按 `whale-widget-prompt.md` 调整几何参数。
137
+
138
+ ## 开发与维护
139
+
140
+ 完整规格、视觉参数、架构结论和生成提示词见 `whale-widget-prompt.md`。修改文字位置、颜色、动画、吸附逻辑、台词组或定价表时参考该文件。
package/assets/D1.mp3 ADDED
Binary file
package/assets/D2.mp3 ADDED
Binary file
Binary file
package/assets/Ya1.mp3 ADDED
Binary file
package/assets/Ya2.mp3 ADDED
Binary file
package/cordis.patch.yml CHANGED
@@ -1,15 +1,15 @@
1
- # ============================================================================
2
- # dsh-whale-widget —— DSH bundle patch
3
- # ============================================================================
4
- # 这是插件的"挂载声明"。DSH 启动时按 bundle 层栈叠加各插件 patch,
5
- # 本文件会把鲸鱼余额挂件插入 Web profile 的配置树。
6
- #
7
- # 安装方式(不再需要手工复制/手工改 profile patch):
8
- # dsh plugin --profile web add dsh-whale-widget
9
- # 或本地开发安装:
10
- # dsh plugin --profile web add link:<本目录绝对路径>
11
- # ============================================================================
12
-
13
- - insert:
14
- - id: dsh-whale-widget
15
- name: dsh-whale-widget
1
+ # ============================================================================
2
+ # dsh-whale-widget —— DSH bundle patch
3
+ # ============================================================================
4
+ # 这是插件的"挂载声明"。DSH 启动时按 bundle 层栈叠加各插件 patch,
5
+ # 本文件会把鲸鱼余额挂件插入 Web profile 的配置树。
6
+ #
7
+ # 安装方式(不再需要手工复制/手工改 profile patch):
8
+ # dsh plugin --profile web add dsh-whale-widget
9
+ # 或本地开发安装:
10
+ # dsh plugin --profile web add link:<本目录绝对路径>
11
+ # ============================================================================
12
+
13
+ - insert:
14
+ - id: dsh-whale-widget
15
+ name: dsh-whale-widget