better-dsh-pet 0.2.2 → 0.2.4

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
@@ -21,11 +21,9 @@
21
21
 
22
22
  ## 🎬 视频推广
23
23
 
24
- > 📹 演示视频占位:拍好视频后把链接放到这里。
24
+ > 📹 点击观看 better-dsh-pet 演示视频:
25
25
  >
26
- > ```md
27
- > [▶️ 点击观看 better-dsh-pet 演示视频](https://www.bilibili.com/video/你的视频ID)
28
- > ```
26
+ > [▶️ B站:一行命令,把大肥鱼放到桌面](https://www.bilibili.com/video/BV1YH8h6WEvi)
29
27
 
30
28
  ---
31
29
 
package/lib/client.js CHANGED
@@ -276,10 +276,25 @@ window.__ModuleLoader__.load({
276
276
  }
277
277
 
278
278
  function apply(ctx) {
279
- ctx.slots.inject('settings.plugin.item', () => ctx.slots.register({
280
- name: 'settings.plugin.item', id: 'better-dsh-pet', order: 30,
281
- inject: () => ({}),
282
- }, PetSettingsCard))
279
+ ctx.slots.inject('settings.plugin.item', () => {
280
+ const kind = typeof ctx.slots.spec === 'function'
281
+ ? ctx.slots.spec('settings.plugin.item')?.kind
282
+ : undefined
283
+ // 不同 DSH 客户端版本对 settings.plugin.item 的槽位类型不同:
284
+ // 旧版是 list(用 id 标识卡片),新版可能是 keyed(用 key 标识)。
285
+ // 这里同时带上 id 和 key,两种声明都能兼容。
286
+ const options = {
287
+ name: 'settings.plugin.item',
288
+ id: 'better-dsh-pet',
289
+ key: 'better-dsh-pet',
290
+ order: 30,
291
+ inject: () => ({}),
292
+ }
293
+ // 若运行时的槽位规格明确是 keyed,则只保留 key(避免多余字段带来歧义);
294
+ // 其余情况(list / 未知)保留 id,保证旧版 DSH 也能正常加载。
295
+ if (kind === 'keyed') delete options.id
296
+ return ctx.slots.register(options, PetSettingsCard)
297
+ })
283
298
  }
284
299
 
285
300
  exports.name = 'better-dsh-pet-client'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "better-dsh-pet",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "A desktop-native pet bubble driven by DeepSeek Harness session events: transparent always-on-top Electron window, status-aware animations, balance, pomodoro, roast, and DSH settings card.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -64,6 +64,7 @@ function createWindow() {
64
64
  height,
65
65
  x: area.x,
66
66
  y: area.y,
67
+ show: false,
67
68
  useContentSize: true,
68
69
  transparent: true,
69
70
  frame: false,
@@ -76,9 +77,14 @@ function createWindow() {
76
77
  contextIsolation: true,
77
78
  nodeIntegration: false,
78
79
  sandbox: false,
80
+ paintWhenInitiallyHidden: false,
79
81
  },
80
82
  })
81
83
 
84
+ mainWindow.once('ready-to-show', () => {
85
+ mainWindow.show()
86
+ })
87
+
82
88
  mainWindow.setAlwaysOnTop(true, 'screen-saver')
83
89
  mainWindow.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true })
84
90
  setClickThrough(true)
@@ -26,6 +26,14 @@ const VERSION = process.env.DSH_PET_ELECTRON_VERSION || '43.3.0'
26
26
  const MIRROR = process.env.DSH_PET_ELECTRON_MIRROR || 'https://npmmirror.com/mirrors/electron/'
27
27
  const TARGET_DIR = resolve(HOME, 'electron')
28
28
  const EXE = join(TARGET_DIR, 'electron.exe')
29
+ const REQUIRED_FILES = [
30
+ 'electron.exe',
31
+ 'icudtl.dat',
32
+ 'resources.pak',
33
+ 'snapshot_blob.bin',
34
+ 'chrome_100_percent.pak',
35
+ 'v8_context_snapshot.bin',
36
+ ]
29
37
 
30
38
  async function download(url, dest) {
31
39
  const response = await fetch(url, { redirect: 'follow' })
@@ -39,14 +47,21 @@ function extractZip(zipPath, targetDir) {
39
47
  mkdirSync(targetDir, { recursive: true })
40
48
  // Windows 自带 tar(bsdtar)可以直接解压 zip;失败时退回 PowerShell Expand-Archive。
41
49
  const tar = spawnSync('tar', ['-xf', zipPath, '-C', targetDir], { stdio: 'inherit' })
42
- if (tar.status === 0) return
43
- const ps = spawnSync('powershell', [
44
- '-NoProfile',
45
- '-Command',
46
- `Expand-Archive -LiteralPath '${zipPath}' -DestinationPath '${targetDir}' -Force`,
47
- ], { stdio: 'inherit' })
48
- if (ps.status !== 0) {
49
- throw new Error('failed to extract Electron zip')
50
+ if (tar.status !== 0) {
51
+ const ps = spawnSync('powershell', [
52
+ '-NoProfile',
53
+ '-Command',
54
+ `Expand-Archive -LiteralPath '${zipPath}' -DestinationPath '${targetDir}' -Force`,
55
+ ], { stdio: 'inherit' })
56
+ if (ps.status !== 0) {
57
+ throw new Error('failed to extract Electron zip')
58
+ }
59
+ }
60
+ // 校验关键文件是否完整;不完整说明下载/解压失败,清理后重试。
61
+ const missing = REQUIRED_FILES.filter((name) => !existsSync(join(targetDir, name)))
62
+ if (missing.length > 0) {
63
+ rmSync(targetDir, { recursive: true, force: true })
64
+ throw new Error(`Electron zip incomplete, missing: ${missing.join(', ')}`)
50
65
  }
51
66
  }
52
67