-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.mjs
32 lines (28 loc) · 852 Bytes
/
main.mjs
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
import isDev from 'electron-is-dev';
import { app, BrowserWindow } from 'electron';
function createWindow() {
const mainWindow = new BrowserWindow({
width: 800,
height: 630,
autoHideMenuBar: true,
icon: './public/images/pdf.png',
});
if (isDev) {
// 開發階段直接與 React 連線
mainWindow.loadURL('http://localhost:3000/');
// 開啟 DevTools.
mainWindow.webContents.openDevTools();
} else {
// 產品階段直接讀取 React 打包好的
mainWindow.loadFile('./build/index.html');
}
}
app.whenReady().then(() => {
createWindow();
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow();
});
});
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});