dsh-deepseek-whale 0.17.0 → 0.17.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/CHANGELOG.md +15 -0
- package/README.md +6 -4
- package/assets/widget.js +341 -9
- package/memory.html +1 -0
- package/package.json +1 -1
- package/src/settings.cjs +33 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,20 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.17.3 — 2026-11-25
|
|
4
|
+
|
|
5
|
+
- 新增页面内快捷键设置:菜单 / 设置里的「快捷键设置…」,可改语音输入 / 刷新余额 / 停止动作 / 打开菜单 / 打开设置 / 用量记录
|
|
6
|
+
- 快捷键保存在插件 settings.json 的 `shortcuts`;点击键位后按下新组合,支持清除、恢复默认;录制时不会触发旧快捷键
|
|
7
|
+
- 页面内快捷键只在 DSH 页面有焦点时生效,不是系统级全局快捷键;菜单里的语音输入标签会跟随当前组合
|
|
8
|
+
|
|
9
|
+
## 0.17.2 — 2026-11-25
|
|
10
|
+
|
|
11
|
+
- 插件动作播放最多 4fps,避免动作过快;走路/动作保持清晰关键帧
|
|
12
|
+
- 待机随机游走:左右走动,走到边或本次走完会转身回中心;朝向随方向镜像;右键「随机游走」可关
|
|
13
|
+
|
|
14
|
+
## 0.17.1 — 2026-11-24
|
|
15
|
+
|
|
16
|
+
- 重新打包发布;0.17.0 在 npm 上只生成了 staged 占位版本,未真正上架
|
|
17
|
+
|
|
3
18
|
## 0.17.0 — 2026-11-24
|
|
4
19
|
|
|
5
20
|
- 语音 / 输入触发的 DeepSeek 最终回复自动回到挂件:气泡显示 + 本机朗读
|
package/README.md
CHANGED
|
@@ -11,6 +11,8 @@
|
|
|
11
11
|
- **余额气泡与对话气泡分开开关**:右键菜单分别控制
|
|
12
12
|
- **DeepSeek 工具**:在 DSH 注册 `balance_whale`,DeepSeek 可直接读取余额 / 用量、让鲸鱼说一句、播放 / 停止动作、打开面板、刷新余额与厂商、改大小、切气泡、隐藏;名字 / 性格 / 说话方式由使用者在 DeepSeek / DSH 侧配置,插件不保存也不覆盖
|
|
13
13
|
- **语音 / 输入直接交给 DSH DeepSeek**:右键输入或按 `Ctrl+Alt+V` 语音识别后,文本作为当前 DSH 会话的一条用户消息直接发给已连接的 DeepSeek(空闲 `followup`,运行中 `steer`);由 DeepSeek 用自己的名字 / 性格 / 说话方式回复,并可调用 `balance_whale` 控制挂件;插件不再内置另一套 DeepSeek 提示词,也不保存人格;设置「行为」区可关闭,断线时保留本地命令兜底
|
|
14
|
+
- **待机随机游走**:DSH 页面待机时左右走动,走到边或本次走完会转身回中心;朝向随方向镜像;右键「随机游走」可关
|
|
15
|
+
- **快捷键设置**:菜单或设置里打开「快捷键设置…」,可改语音输入 / 刷新余额 / 停止动作 / 打开菜单 / 打开设置 / 用量记录;只在 DSH 页面有焦点时生效,不是系统级全局快捷键;支持清除、恢复默认,录制时不会触发旧组合
|
|
14
16
|
- **语音输入**:使用宿主 Windows 的 zh-CN 离线识别(System.Speech),不录音、不上传;没有麦克风或权限被拒时明确提示
|
|
15
17
|
- **DeepSeek 回复回到挂件**:语音 / 输入触发的最终回复自动显示在鲸鱼气泡,并由「朗读 DeepSeek 回复」读出(默认开,可单独关);如果 DeepSeek 已经调用 `say`,同一条不会重复读
|
|
16
18
|
- 右键菜单:刷新余额、用量记录、回忆账本、停止动作 + 10 个动作(挥手/走路/吃东西/玩耍/喝茶/打网球/看书/打盹/睡觉/伸懒腰,选中后会一直循环,直到点「停止动作」或左键点她)、角色与服饰、大小(小/中/大)、提示音开关、隐藏挂件
|
|
@@ -87,7 +89,7 @@
|
|
|
87
89
|
|
|
88
90
|
```bash
|
|
89
91
|
npx --yes @deepseek-ai/dsh@0.2.1-rc.2 plugin --profile web add "D:/src/dsh-deepseek-whale"
|
|
90
|
-
# 或已打包:npx --yes @deepseek-ai/dsh@0.2.1-rc.2 plugin --profile web add "D:/src/dsh-deepseek-whale/dsh-deepseek-whale-0.17.
|
|
92
|
+
# 或已打包:npx --yes @deepseek-ai/dsh@0.2.1-rc.2 plugin --profile web add "D:/src/dsh-deepseek-whale/dsh-deepseek-whale-0.17.3.tgz"
|
|
91
93
|
```
|
|
92
94
|
|
|
93
95
|
安装后必须重启 `dsh web` 进程,再在浏览器 Ctrl+F5;只刷新页面不会重新加载 bundle。
|
|
@@ -95,13 +97,13 @@ npx --yes @deepseek-ai/dsh@0.2.1-rc.2 plugin --profile web add "D:/src/dsh-deeps
|
|
|
95
97
|
### DeepSeek Harness 桌面端
|
|
96
98
|
|
|
97
99
|
桌面端的 profile 由客户端独占管理,CLI 不允许写入。请通过客户端的插件管理器安装本地包
|
|
98
|
-
`D:\src\dsh-deepseek-whale\dsh-deepseek-whale-0.17.
|
|
100
|
+
`D:\src\dsh-deepseek-whale\dsh-deepseek-whale-0.17.3.tgz`(或源目录),版本不匹配时由主人本人确认风险。
|
|
99
101
|
装完完全退出客户端再打开。
|
|
100
102
|
|
|
101
103
|
## 更新
|
|
102
104
|
|
|
103
|
-
- **Web(link 安装)**:直接改 `D:/src/dsh-deepseek-whale` 源码,重启 `dsh web` 宿主进程,再 Ctrl+F5。当前版本 **0.17.
|
|
104
|
-
- **桌面端**:用新版 tgz(`dsh-deepseek-whale-0.17.
|
|
105
|
+
- **Web(link 安装)**:直接改 `D:/src/dsh-deepseek-whale` 源码,重启 `dsh web` 宿主进程,再 Ctrl+F5。当前版本 **0.17.3**。
|
|
106
|
+
- **桌面端**:用新版 tgz(`dsh-deepseek-whale-0.17.3.tgz`)在插件管理器里重新安装 / 更新,包名不变会覆盖旧版本;完全退出客户端再打开。
|
|
105
107
|
|
|
106
108
|
## 与现有插件的关系
|
|
107
109
|
|
package/assets/widget.js
CHANGED
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
if (pref.balanceOn == null) pref.balanceOn = true;
|
|
78
78
|
if (pref.dialogOn == null) pref.dialogOn = true;
|
|
79
79
|
if (pref.customChar == null) pref.customChar = false;
|
|
80
|
+
if (pref.walkOn == null) pref.walkOn = true;
|
|
80
81
|
const save = () => { try { localStorage.setItem(LS_KEY, JSON.stringify(pref)); } catch {} };
|
|
81
82
|
for (const character of CHARACTERS) {
|
|
82
83
|
const img = new Image();
|
|
@@ -121,8 +122,8 @@
|
|
|
121
122
|
.dw-rows img{max-width:100%;max-height:160px;border-radius:10px;display:block;margin:0 auto}
|
|
122
123
|
.dw-rows a{color:inherit;text-decoration:underline;pointer-events:auto}
|
|
123
124
|
.dw-grad{-webkit-background-clip:text;background-clip:text;color:transparent!important}
|
|
124
|
-
.dw-pet{position:relative;width:var(--dw-size,128px);height:var(--dw-size,128px);pointer-events:auto;cursor:grab;touch-action:none;transition:transform .07s ease}
|
|
125
|
-
.dw-pet.pressed{transform:scale(.96,1.05)}
|
|
125
|
+
.dw-pet{position:relative;width:var(--dw-size,128px);height:var(--dw-size,128px);pointer-events:auto;cursor:grab;touch-action:none;transition:transform .07s ease;transform:scaleX(var(--dw-face,1))}
|
|
126
|
+
.dw-pet.pressed{transform:scaleX(var(--dw-face,1)) scale(.96,1.05)}
|
|
126
127
|
.dw-root.dw-quiet .dw-pet{opacity:.62;filter:saturate(.85)}
|
|
127
128
|
.dw-root.dw-quiet .dw-heart{display:none}
|
|
128
129
|
.dw-root.dw-doze .dw-pet{opacity:.8}
|
|
@@ -164,6 +165,14 @@
|
|
|
164
165
|
.dw-settings-checks{display:flex;gap:16px;flex-wrap:wrap;font-size:13px;margin:6px 0 2px}
|
|
165
166
|
.dw-settings-hint{color:#7a87a6;font-size:11.5px;margin:10px 0 0}
|
|
166
167
|
.dw-settings-done{background:#4d6bfe;border:1px solid #4d6bfe;color:#fff;border-radius:9px;padding:7px 16px;cursor:pointer;font:inherit}
|
|
168
|
+
.dw-shortcut-row{display:flex;align-items:center;justify-content:space-between;gap:10px;padding:8px 0;border-bottom:1px solid #eef2fb;font-size:12.5px}
|
|
169
|
+
.dw-shortcut-row:last-child{border-bottom:0}
|
|
170
|
+
.dw-shortcut-actions{display:flex;align-items:center;gap:6px}
|
|
171
|
+
.dw-shortcut-key{min-width:118px;padding:6px 9px;border:1px solid #d5dff3;border-radius:8px;background:#f8faff;color:#33477e;font:600 12px "Segoe UI","Microsoft YaHei",sans-serif;cursor:pointer}
|
|
172
|
+
.dw-shortcut-key:hover{background:#eef3ff}
|
|
173
|
+
.dw-shortcut-key.recording{border-color:#4d6bfe;background:#eef3ff;color:#2d49d8}
|
|
174
|
+
.dw-shortcut-clear{padding:6px 8px;border:1px solid #dfe5f5;border-radius:8px;background:#fff;color:#7a87a6;font:inherit;font-size:11px;cursor:pointer}
|
|
175
|
+
.dw-shortcut-clear:hover{border-color:#a9bdf5;color:#2b46d8}
|
|
167
176
|
.dw-modal-card iframe{width:100%;height:100%;border:0;display:block;background:#f4f7ff}
|
|
168
177
|
.dw-modal-close{position:absolute;right:10px;top:10px;z-index:2;width:28px;height:28px;border-radius:50%;border:1px solid rgba(80,100,160,.25);background:#fff;color:#3b4a8a;font-size:14px;cursor:pointer}
|
|
169
178
|
`;
|
|
@@ -241,6 +250,95 @@
|
|
|
241
250
|
let refreshTimer = 0;
|
|
242
251
|
let settingsModal = null;
|
|
243
252
|
let settingsSaveTimer = 0;
|
|
253
|
+
let shortcutsModal = null;
|
|
254
|
+
let shortcutDraft = null;
|
|
255
|
+
let shortcutRecording = '';
|
|
256
|
+
const DEFAULT_SHORTCUTS = {
|
|
257
|
+
voice: 'Ctrl+Alt+V',
|
|
258
|
+
refresh: 'Ctrl+Alt+R',
|
|
259
|
+
stop: 'Ctrl+Alt+S',
|
|
260
|
+
menu: 'Ctrl+Alt+M',
|
|
261
|
+
settings: 'Ctrl+Alt+O',
|
|
262
|
+
usage: 'Ctrl+Alt+U',
|
|
263
|
+
};
|
|
264
|
+
const SHORTCUT_DEFS = [
|
|
265
|
+
{ key: 'voice', label: '语音输入' },
|
|
266
|
+
{ key: 'refresh', label: '刷新余额' },
|
|
267
|
+
{ key: 'stop', label: '停止动作' },
|
|
268
|
+
{ key: 'menu', label: '打开菜单' },
|
|
269
|
+
{ key: 'settings', label: '打开设置' },
|
|
270
|
+
{ key: 'usage', label: '用量记录' },
|
|
271
|
+
];
|
|
272
|
+
function cleanShortcut(value, fallback = '') {
|
|
273
|
+
if (typeof value !== 'string') return fallback;
|
|
274
|
+
const trimmed = value.trim();
|
|
275
|
+
if (!trimmed) return '';
|
|
276
|
+
if (trimmed.length > 40) return '';
|
|
277
|
+
if (/^F([1-9]|1[0-9]|2[0-4])$/i.test(trimmed)) return trimmed;
|
|
278
|
+
if (!/^[A-Za-z0-9+]+$/.test(trimmed)) return '';
|
|
279
|
+
if (!/\+[A-Za-z0-9]+$/.test(trimmed)) return '';
|
|
280
|
+
if (!/^(CommandOrControl|Control|Ctrl|Alt|Shift|Meta)\+/.test(trimmed)) return '';
|
|
281
|
+
return trimmed;
|
|
282
|
+
}
|
|
283
|
+
function normalizeShortcuts(raw) {
|
|
284
|
+
const source = raw && typeof raw === 'object' ? raw : {};
|
|
285
|
+
const shortcuts = {};
|
|
286
|
+
for (const key of Object.keys(DEFAULT_SHORTCUTS)) {
|
|
287
|
+
shortcuts[key] = typeof source[key] === 'string'
|
|
288
|
+
? cleanShortcut(source[key], '')
|
|
289
|
+
: DEFAULT_SHORTCUTS[key];
|
|
290
|
+
}
|
|
291
|
+
return shortcuts;
|
|
292
|
+
}
|
|
293
|
+
function fmtShortcut(accel) {
|
|
294
|
+
if (!accel) return '未设置';
|
|
295
|
+
return String(accel).replace(/CommandOrControl|Control/g, 'Ctrl').replace(/Super|Meta/g, 'Win');
|
|
296
|
+
}
|
|
297
|
+
function keyFromEvent(e) {
|
|
298
|
+
if (['Control', 'Shift', 'Alt', 'Meta'].includes(e.key)) return '';
|
|
299
|
+
if (/^[a-zA-Z]$/.test(e.key)) return e.key.toUpperCase();
|
|
300
|
+
if (/^[0-9]$/.test(e.key)) return e.key;
|
|
301
|
+
if (/^F([1-9]|1[0-9]|2[0-4])$/.test(e.key)) return e.key;
|
|
302
|
+
const map = {
|
|
303
|
+
' ': 'Space', Enter: 'Enter', Tab: 'Tab', ArrowUp: 'Up', ArrowDown: 'Down',
|
|
304
|
+
ArrowLeft: 'Left', ArrowRight: 'Right', Home: 'Home', End: 'End',
|
|
305
|
+
PageUp: 'PageUp', PageDown: 'PageDown', Insert: 'Insert', Delete: 'Delete',
|
|
306
|
+
};
|
|
307
|
+
return map[e.key] || '';
|
|
308
|
+
}
|
|
309
|
+
function accelFromEvent(e) {
|
|
310
|
+
const key = keyFromEvent(e);
|
|
311
|
+
if (!key) return '';
|
|
312
|
+
const mods = [];
|
|
313
|
+
if (e.ctrlKey || e.metaKey) mods.push('Ctrl');
|
|
314
|
+
if (e.altKey) mods.push('Alt');
|
|
315
|
+
if (e.shiftKey) mods.push('Shift');
|
|
316
|
+
if (!mods.length && !/^F([1-9]|1[0-9]|2[0-4])$/.test(key)) return '';
|
|
317
|
+
return mods.length ? `${mods.join('+')}+${key}` : key;
|
|
318
|
+
}
|
|
319
|
+
function parseAccelerator(accel) {
|
|
320
|
+
const parts = String(accel || '').split('+').filter(Boolean);
|
|
321
|
+
if (!parts.length) return null;
|
|
322
|
+
const key = parts.pop().toUpperCase();
|
|
323
|
+
const mods = new Set(parts.map((part) => part.toLowerCase()));
|
|
324
|
+
return {
|
|
325
|
+
key,
|
|
326
|
+
ctrl: mods.has('ctrl') || mods.has('control') || mods.has('commandorcontrol'),
|
|
327
|
+
alt: mods.has('alt'),
|
|
328
|
+
shift: mods.has('shift'),
|
|
329
|
+
meta: mods.has('meta') || mods.has('super'),
|
|
330
|
+
};
|
|
331
|
+
}
|
|
332
|
+
function shortcutMatches(e, accel) {
|
|
333
|
+
const parsed = parseAccelerator(accel);
|
|
334
|
+
if (!parsed) return false;
|
|
335
|
+
if (keyFromEvent(e).toUpperCase() !== parsed.key) return false;
|
|
336
|
+
const wantsCtrl = parsed.ctrl || parsed.meta;
|
|
337
|
+
if (wantsCtrl !== Boolean(e.ctrlKey || e.metaKey)) return false;
|
|
338
|
+
if (parsed.alt !== Boolean(e.altKey)) return false;
|
|
339
|
+
if (parsed.shift !== Boolean(e.shiftKey)) return false;
|
|
340
|
+
return true;
|
|
341
|
+
}
|
|
244
342
|
let soundsSaveTimer = 0;
|
|
245
343
|
const galleryMap = new Map();
|
|
246
344
|
let clickIndex = -1;
|
|
@@ -523,7 +621,99 @@
|
|
|
523
621
|
let blinkStart = 0;
|
|
524
622
|
let lastSig = '';
|
|
525
623
|
|
|
624
|
+
const WANDER_SPEED = 20;
|
|
625
|
+
const wander = {
|
|
626
|
+
active: false,
|
|
627
|
+
dir: 1,
|
|
628
|
+
offset: 0,
|
|
629
|
+
until: 0,
|
|
630
|
+
returning: false,
|
|
631
|
+
lastAt: 0,
|
|
632
|
+
nextAt: Date.now() + 12000 + Math.random() * 8000,
|
|
633
|
+
};
|
|
634
|
+
function wanderMax() {
|
|
635
|
+
return Math.max(8, Math.min(24, Math.round((Number(pref.petScale) || 80) * 0.25)));
|
|
636
|
+
}
|
|
637
|
+
function syncWander() {
|
|
638
|
+
root.style.transform = wander.offset ? `translate3d(${wander.offset.toFixed(2)}px,0,0)` : '';
|
|
639
|
+
}
|
|
640
|
+
function setWanderFace(dir) {
|
|
641
|
+
petEl.style.setProperty('--dw-face', dir > 0 ? '-1' : '1');
|
|
642
|
+
}
|
|
643
|
+
function startWander() {
|
|
644
|
+
wander.active = true;
|
|
645
|
+
wander.returning = false;
|
|
646
|
+
wander.lastAt = Date.now();
|
|
647
|
+
wander.dir = wander.offset > 2 ? -1 : wander.offset < -2 ? 1 : (Math.random() < 0.5 ? -1 : 1);
|
|
648
|
+
wander.until = Date.now() + 7000 + Math.random() * 3000;
|
|
649
|
+
setWanderFace(wander.dir);
|
|
650
|
+
syncWander();
|
|
651
|
+
play('walk');
|
|
652
|
+
}
|
|
653
|
+
function stopWander(idle = false) {
|
|
654
|
+
if (!wander.active) {
|
|
655
|
+
wander.nextAt = Date.now() + 18000 + Math.random() * 22000;
|
|
656
|
+
return;
|
|
657
|
+
}
|
|
658
|
+
wander.active = false;
|
|
659
|
+
wander.offset = 0;
|
|
660
|
+
wander.returning = false;
|
|
661
|
+
wander.lastAt = 0;
|
|
662
|
+
syncWander();
|
|
663
|
+
setWanderFace(1);
|
|
664
|
+
if (idle && current === 'walk' && !forced) play('idle');
|
|
665
|
+
wander.nextAt = Date.now() + 18000 + Math.random() * 22000;
|
|
666
|
+
}
|
|
667
|
+
function wanderTick() {
|
|
668
|
+
const now = Date.now();
|
|
669
|
+
if (!wander.active) {
|
|
670
|
+
if (pref.walkOn === false || now < wander.nextAt) return;
|
|
671
|
+
if (hidden || quietActive || dozeActive || forced || questionHold || customActive || modal || settingsModal || menu || current !== 'idle' || document.visibilityState !== 'visible') return;
|
|
672
|
+
startWander();
|
|
673
|
+
return;
|
|
674
|
+
}
|
|
675
|
+
if (pref.walkOn === false || hidden || quietActive || dozeActive || questionHold || customActive || modal || settingsModal || document.visibilityState !== 'visible') {
|
|
676
|
+
stopWander(true);
|
|
677
|
+
return;
|
|
678
|
+
}
|
|
679
|
+
if (forced || current !== 'walk') {
|
|
680
|
+
stopWander(false);
|
|
681
|
+
return;
|
|
682
|
+
}
|
|
683
|
+
const dt = wander.lastAt ? Math.min(0.3, (now - wander.lastAt) / 1000) : 0;
|
|
684
|
+
wander.lastAt = now;
|
|
685
|
+
if (!wander.returning && now >= wander.until && Math.abs(wander.offset) > 2) {
|
|
686
|
+
wander.returning = true;
|
|
687
|
+
wander.dir = -Math.sign(wander.offset);
|
|
688
|
+
wander.until = now + (Math.abs(wander.offset) / WANDER_SPEED) * 1000 + 300;
|
|
689
|
+
setWanderFace(wander.dir);
|
|
690
|
+
} else if (!wander.returning && now >= wander.until) {
|
|
691
|
+
stopWander(true);
|
|
692
|
+
return;
|
|
693
|
+
}
|
|
694
|
+
const step = wander.dir * WANDER_SPEED * dt;
|
|
695
|
+
if (wander.returning) {
|
|
696
|
+
const next = wander.offset + step;
|
|
697
|
+
if ((wander.offset > 0 && next <= 0) || (wander.offset < 0 && next >= 0)) {
|
|
698
|
+
stopWander(true);
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
wander.offset = next;
|
|
702
|
+
} else {
|
|
703
|
+
wander.offset += step;
|
|
704
|
+
const max = wanderMax();
|
|
705
|
+
if (Math.abs(wander.offset) > max) {
|
|
706
|
+
wander.offset = Math.sign(wander.offset) * max;
|
|
707
|
+
wander.dir *= -1;
|
|
708
|
+
wander.until = Math.max(wander.until, now + 2500);
|
|
709
|
+
setWanderFace(wander.dir);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
syncWander();
|
|
713
|
+
}
|
|
714
|
+
|
|
526
715
|
function play(name, ms) {
|
|
716
|
+
if (name !== 'walk' && wander.active) stopWander(false);
|
|
527
717
|
current = name;
|
|
528
718
|
stateStart = performance.now();
|
|
529
719
|
lastSig = '';
|
|
@@ -534,6 +724,7 @@
|
|
|
534
724
|
}
|
|
535
725
|
|
|
536
726
|
function startAction(name) {
|
|
727
|
+
if (wander.active) stopWander(false);
|
|
537
728
|
forced = true;
|
|
538
729
|
clearTimeout(actionTimer);
|
|
539
730
|
play(name);
|
|
@@ -555,6 +746,7 @@
|
|
|
555
746
|
|
|
556
747
|
let questionHold = false;
|
|
557
748
|
function holdState(name) {
|
|
749
|
+
if (wander.active) stopWander(false);
|
|
558
750
|
clearTimeout(actionTimer);
|
|
559
751
|
current = name;
|
|
560
752
|
stateStart = performance.now();
|
|
@@ -582,12 +774,14 @@
|
|
|
582
774
|
frame = Math.min(st.frames - 1, 1 + Math.floor((now - blinkStart) / 130));
|
|
583
775
|
}
|
|
584
776
|
} else if (st.frames > 1) {
|
|
585
|
-
|
|
777
|
+
const fps = (forced || wander.active) ? Math.min(4, st.fps) : st.fps;
|
|
778
|
+
frame = Math.floor(((now - stateStart) / 1000) * fps) % st.frames;
|
|
586
779
|
}
|
|
587
780
|
setFrame(st, frame);
|
|
588
781
|
requestAnimationFrame(tick);
|
|
589
782
|
}
|
|
590
783
|
requestAnimationFrame(tick);
|
|
784
|
+
setInterval(wanderTick, 100);
|
|
591
785
|
|
|
592
786
|
function onPetClick() {
|
|
593
787
|
forced = false;
|
|
@@ -787,9 +981,10 @@
|
|
|
787
981
|
readRepliesOn: data.readRepliesOn !== false,
|
|
788
982
|
agencyOn: data.agencyOn !== false,
|
|
789
983
|
aiBrainOn: data.aiBrainOn !== false,
|
|
984
|
+
shortcuts: normalizeShortcuts(data.shortcuts),
|
|
790
985
|
};
|
|
791
986
|
} catch {
|
|
792
|
-
settingsCfg = { refreshSeconds: 60, dailyBudget: 0, quietOnFocus: true, idleDoze: true, idleDozeMinutes: 3, moodOn: true, speakOn: false, readRepliesOn: true, agencyOn: true, aiBrainOn: true };
|
|
987
|
+
settingsCfg = { refreshSeconds: 60, dailyBudget: 0, quietOnFocus: true, idleDoze: true, idleDozeMinutes: 3, moodOn: true, speakOn: false, readRepliesOn: true, agencyOn: true, aiBrainOn: true, shortcuts: { ...DEFAULT_SHORTCUTS } };
|
|
793
988
|
}
|
|
794
989
|
scheduleRefresh();
|
|
795
990
|
if (!hidden) renderBubble();
|
|
@@ -1510,13 +1705,19 @@
|
|
|
1510
1705
|
closeMenu();
|
|
1511
1706
|
runNatural(text);
|
|
1512
1707
|
});
|
|
1513
|
-
addItem(menu,
|
|
1708
|
+
addItem(menu, `语音输入 ${fmtShortcut((settingsCfg && settingsCfg.shortcuts ? settingsCfg.shortcuts.voice : DEFAULT_SHORTCUTS.voice))}`, () => startVoice());
|
|
1514
1709
|
addItem(menu, '语音交给 DeepSeek', async () => {
|
|
1515
1710
|
await loadSettings();
|
|
1516
1711
|
settingsCfg.aiBrainOn = settingsCfg.aiBrainOn === false;
|
|
1517
1712
|
saveSettingsSoon();
|
|
1518
1713
|
showToast(settingsCfg.aiBrainOn ? '语音会交给 DSH DeepSeek' : '语音只走本地');
|
|
1519
1714
|
}, settingsCfg ? settingsCfg.aiBrainOn !== false : true);
|
|
1715
|
+
addItem(menu, '随机游走', () => {
|
|
1716
|
+
pref.walkOn = pref.walkOn === false;
|
|
1717
|
+
save();
|
|
1718
|
+
if (!pref.walkOn) stopWander(true);
|
|
1719
|
+
showToast(pref.walkOn ? '待机会随机走走' : '待机不再走动');
|
|
1720
|
+
}, pref.walkOn !== false);
|
|
1520
1721
|
sep();
|
|
1521
1722
|
addItem(menu, '刷新余额', () => { play('joy', 1200); load(true); });
|
|
1522
1723
|
addItem(menu, '用量记录', () => openUsage());
|
|
@@ -1569,6 +1770,7 @@
|
|
|
1569
1770
|
}, soundCfg ? soundCfg.enabled !== false : true);
|
|
1570
1771
|
addItem(menu, '音效设置…', () => openSounds());
|
|
1571
1772
|
addItem(menu, '设置…', () => openSettings());
|
|
1773
|
+
addItem(menu, '快捷键设置…', () => openShortcuts());
|
|
1572
1774
|
sep();
|
|
1573
1775
|
addItem(menu, '余额气泡', () => {
|
|
1574
1776
|
pref.balanceOn = pref.balanceOn === false;
|
|
@@ -1603,12 +1805,34 @@
|
|
|
1603
1805
|
document.addEventListener('pointerdown', (e) => {
|
|
1604
1806
|
if (menu && !menu.contains(e.target)) closeMenu();
|
|
1605
1807
|
}, true);
|
|
1606
|
-
|
|
1808
|
+
function findShortcutAction(e) {
|
|
1809
|
+
const shortcuts = settingsCfg?.shortcuts || DEFAULT_SHORTCUTS;
|
|
1810
|
+
for (const action of ['voice', 'refresh', 'stop', 'menu', 'settings', 'usage']) {
|
|
1811
|
+
if (shortcuts[action] && shortcutMatches(e, shortcuts[action])) return action;
|
|
1812
|
+
}
|
|
1813
|
+
return '';
|
|
1814
|
+
}
|
|
1815
|
+
function runShortcutAction(action) {
|
|
1816
|
+
if (action === 'voice') return startVoice();
|
|
1817
|
+
if (action === 'refresh') { play('joy', 1200); load(true); return; }
|
|
1818
|
+
if (action === 'stop') { stopAction(); return; }
|
|
1819
|
+
if (action === 'usage') { openUsage(); return; }
|
|
1820
|
+
if (action === 'settings') { openSettings(); return; }
|
|
1821
|
+
if (action === 'menu') {
|
|
1822
|
+
if (menu) { closeMenu(); return; }
|
|
1823
|
+
const r = petEl.getBoundingClientRect();
|
|
1824
|
+
openMenu(Math.max(8, r.right - 220), Math.max(8, r.top - 300));
|
|
1825
|
+
}
|
|
1826
|
+
}
|
|
1827
|
+
|
|
1828
|
+
document.addEventListener('keydown', (e) => { if (e.key === 'Escape') { closeMenu(); closeModal(); closeSettings(); closeShortcuts(); } });
|
|
1607
1829
|
document.addEventListener('keydown', (e) => {
|
|
1608
|
-
if (
|
|
1609
|
-
|
|
1830
|
+
if (shortcutRecording) return;
|
|
1831
|
+
const action = findShortcutAction(e);
|
|
1832
|
+
if (!action) return;
|
|
1610
1833
|
e.preventDefault();
|
|
1611
|
-
|
|
1834
|
+
e.stopPropagation();
|
|
1835
|
+
runShortcutAction(action);
|
|
1612
1836
|
});
|
|
1613
1837
|
|
|
1614
1838
|
let modal = null;
|
|
@@ -1639,6 +1863,109 @@
|
|
|
1639
1863
|
function openBubbles() { openFrame('/deepseek-whale/bubbles', '气泡设置', true, () => loadBubbles()); }
|
|
1640
1864
|
function openSounds() { openFrame('/deepseek-whale/sounds', '音效设置', false, () => loadSounds()); }
|
|
1641
1865
|
|
|
1866
|
+
function closeShortcuts() {
|
|
1867
|
+
shortcutRecording = '';
|
|
1868
|
+
if (shortcutsModal) {
|
|
1869
|
+
shortcutsModal.remove();
|
|
1870
|
+
shortcutsModal = null;
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
function renderShortcutRows() {
|
|
1874
|
+
if (!shortcutsModal || !shortcutDraft) return;
|
|
1875
|
+
const host = shortcutsModal.querySelector('#dw-shortcut-rows');
|
|
1876
|
+
if (!host) return;
|
|
1877
|
+
host.innerHTML = '';
|
|
1878
|
+
for (const def of SHORTCUT_DEFS) {
|
|
1879
|
+
const row = document.createElement('div');
|
|
1880
|
+
row.className = 'dw-shortcut-row';
|
|
1881
|
+
const label = document.createElement('span');
|
|
1882
|
+
label.textContent = def.label;
|
|
1883
|
+
const actions = document.createElement('span');
|
|
1884
|
+
actions.className = 'dw-shortcut-actions';
|
|
1885
|
+
const key = document.createElement('button');
|
|
1886
|
+
key.className = `dw-shortcut-key${shortcutRecording === def.key ? ' recording' : ''}`;
|
|
1887
|
+
key.textContent = shortcutRecording === def.key ? '按下组合键…' : fmtShortcut(shortcutDraft[def.key]);
|
|
1888
|
+
key.addEventListener('click', () => {
|
|
1889
|
+
shortcutRecording = def.key;
|
|
1890
|
+
renderShortcutRows();
|
|
1891
|
+
});
|
|
1892
|
+
const clear = document.createElement('button');
|
|
1893
|
+
clear.className = 'dw-shortcut-clear';
|
|
1894
|
+
clear.textContent = '清除';
|
|
1895
|
+
clear.addEventListener('click', () => {
|
|
1896
|
+
shortcutDraft[def.key] = '';
|
|
1897
|
+
shortcutRecording = '';
|
|
1898
|
+
renderShortcutRows();
|
|
1899
|
+
});
|
|
1900
|
+
actions.append(key, clear);
|
|
1901
|
+
row.append(label, actions);
|
|
1902
|
+
host.appendChild(row);
|
|
1903
|
+
}
|
|
1904
|
+
}
|
|
1905
|
+
async function openShortcuts() {
|
|
1906
|
+
closeMenu();
|
|
1907
|
+
closeModal();
|
|
1908
|
+
closeSettings();
|
|
1909
|
+
closeShortcuts();
|
|
1910
|
+
if (!settingsCfg) await loadSettings();
|
|
1911
|
+
shortcutDraft = normalizeShortcuts(settingsCfg ? settingsCfg.shortcuts : DEFAULT_SHORTCUTS);
|
|
1912
|
+
shortcutsModal = document.createElement('div');
|
|
1913
|
+
shortcutsModal.className = 'dw-modal';
|
|
1914
|
+
shortcutsModal.innerHTML = `
|
|
1915
|
+
<div class="dw-settings-card">
|
|
1916
|
+
<button class="dw-settings-close" title="关闭">✕</button>
|
|
1917
|
+
<h3>快捷键</h3>
|
|
1918
|
+
<p class="dw-settings-hint">只在 DSH 页面有焦点时生效,不是系统级全局快捷键。点击键位后按下新组合;留空可关闭。</p>
|
|
1919
|
+
<div id="dw-shortcut-rows"></div>
|
|
1920
|
+
<div class="dw-settings-row" style="justify-content:space-between;margin-top:12px">
|
|
1921
|
+
<button class="dw-settings-done" id="dw-shortcut-reset" style="background:#fff;color:#33477e;border-color:#d5dff3">恢复默认</button>
|
|
1922
|
+
<button class="dw-settings-done" id="dw-shortcut-save">保存</button>
|
|
1923
|
+
</div>
|
|
1924
|
+
</div>`;
|
|
1925
|
+
document.body.appendChild(shortcutsModal);
|
|
1926
|
+
renderShortcutRows();
|
|
1927
|
+
shortcutsModal.querySelector('#dw-shortcut-reset').addEventListener('click', () => {
|
|
1928
|
+
shortcutDraft = { ...DEFAULT_SHORTCUTS };
|
|
1929
|
+
shortcutRecording = '';
|
|
1930
|
+
renderShortcutRows();
|
|
1931
|
+
});
|
|
1932
|
+
shortcutsModal.querySelector('#dw-shortcut-save').addEventListener('click', () => {
|
|
1933
|
+
const values = Object.values(shortcutDraft).filter(Boolean);
|
|
1934
|
+
if (new Set(values).size !== values.length) {
|
|
1935
|
+
showToast('快捷键不能重复');
|
|
1936
|
+
return;
|
|
1937
|
+
}
|
|
1938
|
+
settingsCfg.shortcuts = normalizeShortcuts(shortcutDraft);
|
|
1939
|
+
saveSettingsSoon();
|
|
1940
|
+
closeShortcuts();
|
|
1941
|
+
showToast('快捷键已保存');
|
|
1942
|
+
});
|
|
1943
|
+
shortcutsModal.addEventListener('pointerdown', (e) => {
|
|
1944
|
+
if (e.target === shortcutsModal || e.target.classList.contains('dw-settings-close')) closeShortcuts();
|
|
1945
|
+
});
|
|
1946
|
+
}
|
|
1947
|
+
document.addEventListener('keydown', (e) => {
|
|
1948
|
+
if (!shortcutRecording) return;
|
|
1949
|
+
e.preventDefault();
|
|
1950
|
+
e.stopImmediatePropagation();
|
|
1951
|
+
if (e.key === 'Escape') {
|
|
1952
|
+
shortcutRecording = '';
|
|
1953
|
+
renderShortcutRows();
|
|
1954
|
+
return;
|
|
1955
|
+
}
|
|
1956
|
+
if ((e.key === 'Backspace' || e.key === 'Delete') && !e.ctrlKey && !e.altKey && !e.metaKey && !e.shiftKey) {
|
|
1957
|
+
if (shortcutDraft) shortcutDraft[shortcutRecording] = '';
|
|
1958
|
+
shortcutRecording = '';
|
|
1959
|
+
renderShortcutRows();
|
|
1960
|
+
return;
|
|
1961
|
+
}
|
|
1962
|
+
const accel = accelFromEvent(e);
|
|
1963
|
+
if (!accel) return;
|
|
1964
|
+
if (shortcutDraft) shortcutDraft[shortcutRecording] = accel;
|
|
1965
|
+
shortcutRecording = '';
|
|
1966
|
+
renderShortcutRows();
|
|
1967
|
+
}, true);
|
|
1968
|
+
|
|
1642
1969
|
function closeSettings() {
|
|
1643
1970
|
if (settingsModal) {
|
|
1644
1971
|
settingsModal.remove();
|
|
@@ -1650,6 +1977,7 @@
|
|
|
1650
1977
|
closeMenu();
|
|
1651
1978
|
closeModal();
|
|
1652
1979
|
closeSettings();
|
|
1980
|
+
closeShortcuts();
|
|
1653
1981
|
if (!settingsCfg) await loadSettings();
|
|
1654
1982
|
await loadSounds();
|
|
1655
1983
|
const scale = pref.petScale;
|
|
@@ -1688,6 +2016,9 @@
|
|
|
1688
2016
|
<label><input type="checkbox" id="dw-set-ai" ${settingsCfg && settingsCfg.aiBrainOn === false ? '' : 'checked'}> 语音交给 DeepSeek</label>
|
|
1689
2017
|
<label>分钟 <input id="dw-set-doze-min" type="number" min="1" max="30" style="width:58px" value="${settingsCfg ? settingsCfg.idleDozeMinutes || 3 : 3}"></label>
|
|
1690
2018
|
</div>
|
|
2019
|
+
<div class="dw-settings-row" style="justify-content:flex-start;margin-top:6px">
|
|
2020
|
+
<button class="dw-settings-done" id="dw-set-shortcuts" style="background:#fff;color:#33477e;border-color:#d5dff3">快捷键设置…</button>
|
|
2021
|
+
</div>
|
|
1691
2022
|
<p class="dw-settings-hint">语音 / 文字指令会作为当前 DSH 会话的用户消息交给 DeepSeek;关闭后只走本地。</p>
|
|
1692
2023
|
<div class="dw-settings-row" style="justify-content:flex-end;margin-top:14px"><button class="dw-settings-done" id="dw-set-done">完成</button></div>
|
|
1693
2024
|
</div>`;
|
|
@@ -1791,6 +2122,7 @@
|
|
|
1791
2122
|
if (!e.target.checked) stopSpeaking();
|
|
1792
2123
|
saveSettingsSoon();
|
|
1793
2124
|
});
|
|
2125
|
+
settingsModal.querySelector('#dw-set-shortcuts').addEventListener('click', () => openShortcuts());
|
|
1794
2126
|
settingsModal.querySelector('#dw-set-agency').addEventListener('change', (e) => {
|
|
1795
2127
|
if (!settingsCfg) settingsCfg = { refreshSeconds: 60, dailyBudget: 0 };
|
|
1796
2128
|
settingsCfg.agencyOn = e.target.checked;
|
package/memory.html
CHANGED
|
@@ -187,6 +187,7 @@
|
|
|
187
187
|
`尺寸 ${pref.petScale || 80}%`,
|
|
188
188
|
pref.balanceOn === false ? '余额气泡关' : '余额气泡开',
|
|
189
189
|
pref.dialogOn === false ? '对话气泡关' : '对话气泡开',
|
|
190
|
+
pref.walkOn === false ? '随机游走关' : '随机游走开',
|
|
190
191
|
settings?.quietOnFocus === false ? '专注安静关' : '专注安静开',
|
|
191
192
|
settings?.idleDoze === false ? '空闲打盹关' : `空闲打盹 ${settings?.idleDozeMinutes || 3} 分钟`,
|
|
192
193
|
settings?.moodOn === false ? '情绪跟随关' : '情绪跟随开',
|
package/package.json
CHANGED
package/src/settings.cjs
CHANGED
|
@@ -1,7 +1,29 @@
|
|
|
1
1
|
const fs = require('node:fs')
|
|
2
2
|
const path = require('node:path')
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const SHORTCUT_KEYS = ['voice', 'refresh', 'stop', 'menu', 'settings', 'usage']
|
|
5
|
+
const DEFAULT_SHORTCUTS = {
|
|
6
|
+
voice: 'Ctrl+Alt+V',
|
|
7
|
+
refresh: 'Ctrl+Alt+R',
|
|
8
|
+
stop: 'Ctrl+Alt+S',
|
|
9
|
+
menu: 'Ctrl+Alt+M',
|
|
10
|
+
settings: 'Ctrl+Alt+O',
|
|
11
|
+
usage: 'Ctrl+Alt+U',
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function cleanShortcut(value, fallback = '') {
|
|
15
|
+
if (typeof value !== 'string') return fallback
|
|
16
|
+
const trimmed = value.trim()
|
|
17
|
+
if (!trimmed) return ''
|
|
18
|
+
if (trimmed.length > 40) return ''
|
|
19
|
+
if (/^F([1-9]|1[0-9]|2[0-4])$/i.test(trimmed)) return trimmed
|
|
20
|
+
if (!/^[A-Za-z0-9+]+$/.test(trimmed)) return ''
|
|
21
|
+
if (!/\+[A-Za-z0-9]+$/.test(trimmed)) return ''
|
|
22
|
+
if (!/^(CommandOrControl|Control|Ctrl|Alt|Shift|Meta)\+/.test(trimmed)) return ''
|
|
23
|
+
return trimmed
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const DEFAULT = { refreshSeconds: 60, dailyBudget: 0, quietOnFocus: true, idleDoze: true, idleDozeMinutes: 3, moodOn: true, speakOn: false, readRepliesOn: true, agencyOn: true, aiBrainOn: true, shortcuts: { ...DEFAULT_SHORTCUTS } }
|
|
5
27
|
|
|
6
28
|
function createSettings({ storePath }) {
|
|
7
29
|
let cfg = null
|
|
@@ -22,6 +44,16 @@ function createSettings({ storePath }) {
|
|
|
22
44
|
readRepliesOn: r.readRepliesOn !== false,
|
|
23
45
|
agencyOn: r.agencyOn !== false,
|
|
24
46
|
aiBrainOn: r.aiBrainOn !== false,
|
|
47
|
+
shortcuts: (() => {
|
|
48
|
+
const rawShortcuts = r.shortcuts && typeof r.shortcuts === 'object' ? r.shortcuts : {}
|
|
49
|
+
const shortcuts = {}
|
|
50
|
+
for (const key of SHORTCUT_KEYS) {
|
|
51
|
+
shortcuts[key] = typeof rawShortcuts[key] === 'string'
|
|
52
|
+
? cleanShortcut(rawShortcuts[key], '')
|
|
53
|
+
: DEFAULT_SHORTCUTS[key]
|
|
54
|
+
}
|
|
55
|
+
return shortcuts
|
|
56
|
+
})(),
|
|
25
57
|
}
|
|
26
58
|
}
|
|
27
59
|
|