-
-
Notifications
You must be signed in to change notification settings - Fork 283
Expand file tree
/
Copy pathstart.js
More file actions
32 lines (26 loc) · 725 Bytes
/
Copy pathstart.js
File metadata and controls
32 lines (26 loc) · 725 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
// scripts/start.js
const { spawn } = require('child_process');
const path = require('path');
// 设置 NODE_ENV 为 development
process.env.NODE_ENV = 'development';
const platform = process.platform;
let cmd, args, options;
if (platform === 'win32') {
// Windows: 先切换代码页为 UTF-8,再启动 electron
cmd = 'cmd.exe';
args = ['/c', 'chcp 65001 >nul && electron .'];
} else {
// macOS / Linux: 直接运行 electron
cmd = 'electron';
args = ['.'];
}
options = {
stdio: 'inherit',
shell: false, // 非 Windows 不需要 shell;Windows 已用 cmd.exe
env: process.env,
cwd: process.cwd(),
};
const child = spawn(cmd, args, options);
child.on('exit', (code) => {
process.exit(code);
});