@sunshine-star/dsh-access-pc 0.1.4 → 0.1.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunshine-star/dsh-access-pc",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "DSH Access PC client (Electron shell around the hub console)",
5
5
  "main": "main.js",
6
6
  "bin": {
@@ -19,11 +19,27 @@ const iconIco = path.join(appDir, 'assets', 'icon.ico')
19
19
  const iconPng = path.join(appDir, 'assets', 'icon.png')
20
20
 
21
21
  function electronBinary() {
22
+ // npm 先跑本包 postinstall、再跑 electron 的下载脚本,此时 require('electron')
23
+ // 可能还没有 path.txt,返回 undefined;直接按标准布局给出预期路径。
24
+ const expected = path.join(
25
+ appDir,
26
+ 'node_modules',
27
+ 'electron',
28
+ 'dist',
29
+ process.platform === 'win32'
30
+ ? 'electron.exe'
31
+ : process.platform === 'darwin'
32
+ ? path.join('Electron.app', 'Contents', 'MacOS', 'Electron')
33
+ : 'electron',
34
+ )
35
+ if (fs.existsSync(expected)) return expected
22
36
  try {
23
- return require('electron')
24
- } catch (error) {
25
- throw new Error(`找不到 Electron:${error.message}`)
37
+ const resolved = require('electron')
38
+ if (typeof resolved === 'string' && resolved) return resolved
39
+ } catch {
40
+ // 忽略:用预期路径
26
41
  }
42
+ return expected
27
43
  }
28
44
 
29
45
  function desktopDir() {