@vincentbanana/banana-gui 0.4.9 → 0.5.0

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/desktop/main.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  // Banana 桌面版主进程:拉起本地 GUI 服务,再用窗口加载它。
2
2
  // 界面资源仍来自本包 ui/,agent 内核来自 @vincentbanana/bananacli。
3
3
  const { app, BrowserWindow, Menu, shell, dialog } = require('electron');
4
- const { spawn } = require('node:child_process');
4
+ const { spawn, spawnSync } = require('node:child_process');
5
5
  const { createRequire } = require('node:module');
6
6
  const { join } = require('node:path');
7
7
  const { mkdirSync } = require('node:fs');
@@ -40,6 +40,21 @@ function serverArgs() {
40
40
  return ['--ui', '--no-open', ...extra];
41
41
  }
42
42
 
43
+ // 优先用系统 node 跑内核:Electron 自带的 node 版本和原生模块(PTY)不一定匹配,
44
+ // 系统 node 更稳。找不到再退回 electron.exe(ELECTRON_RUN_AS_NODE)。
45
+ function resolveNode() {
46
+ const candidate = process.env.BANANA_NODE || 'node';
47
+ try {
48
+ const probe = spawnSync(candidate, ['-v'], { encoding: 'utf8', windowsHide: true, timeout: 5000 });
49
+ if (probe.status === 0 && /^v\d+\./.test((probe.stdout || '').trim())) {
50
+ return { file: candidate, env: {} };
51
+ }
52
+ } catch {
53
+ // PATH 里没有 node,退回 Electron
54
+ }
55
+ return { file: process.execPath, env: { ELECTRON_RUN_AS_NODE: '1' } };
56
+ }
57
+
43
58
  function startServer() {
44
59
  let entry;
45
60
  try {
@@ -48,11 +63,13 @@ function startServer() {
48
63
  } catch (error) {
49
64
  throw new Error('找不到依赖 @vincentbanana/bananacli,请重新安装:npm install -g @vincentbanana/banana-gui');
50
65
  }
51
- child = spawn(process.execPath, [entry, ...serverArgs()], {
66
+ const node = resolveNode();
67
+ child = spawn(node.file, [entry, ...serverArgs()], {
52
68
  stdio: ['ignore', 'pipe', 'pipe'],
69
+ windowsHide: true,
53
70
  env: {
54
71
  ...process.env,
55
- ELECTRON_RUN_AS_NODE: '1',
72
+ ...node.env,
56
73
  BANANA_UI_DIR: process.env.BANANA_UI_DIR ?? join(__dirname, '..', 'ui'),
57
74
  },
58
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vincentbanana/banana-gui",
3
- "version": "0.4.9",
3
+ "version": "0.5.0",
4
4
  "description": "Banana 的图形界面:本地服务 + 浏览器。黑白主题,自绘图标,无第三方 UI 依赖",
5
5
  "type": "module",
6
6
  "engines": {
@@ -71,7 +71,7 @@
71
71
  "electron-builder": "^25.0.0"
72
72
  },
73
73
  "dependencies": {
74
- "@vincentbanana/bananacli": "^0.4.7"
74
+ "@vincentbanana/bananacli": "^0.4.8"
75
75
  },
76
76
  "license": "MIT",
77
77
  "publishConfig": {