Sui Chen | b65280f | 2020-06-30 18:14:03 -0700 | [diff] [blame] | 1 | // Modules to control application life and create native browser window |
| 2 | const {app, BrowserWindow} = require('electron'); |
| 3 | const path = require('path'); |
| 4 | |
| 5 | function createWindow() { |
| 6 | // Create the browser window. |
| 7 | const mainWindow = new BrowserWindow({ |
| 8 | width: 1440, |
| 9 | height: 900, |
| 10 | webPreferences: { |
Sui Chen | b65280f | 2020-06-30 18:14:03 -0700 | [diff] [blame] | 11 | nodeIntegration: |
Sui Chen | 27cf933 | 2021-11-03 16:20:28 -0700 | [diff] [blame] | 12 | true, // For opening file dialog from the renderer process |
| 13 | enableRemoteModule: true // For require('electron').remote |
Sui Chen | b65280f | 2020-06-30 18:14:03 -0700 | [diff] [blame] | 14 | } |
| 15 | }); |
| 16 | |
| 17 | // and load the index.html of the app. |
| 18 | mainWindow.loadFile('index.html'); |
| 19 | |
| 20 | // Open the DevTools. |
| 21 | // mainWindow.webContents.openDevTools() |
| 22 | } |
| 23 | |
| 24 | // This method will be called when Electron has finished |
| 25 | // initialization and is ready to create browser windows. |
| 26 | // Some APIs can only be used after this event occurs. |
| 27 | app.whenReady().then(createWindow); |
| 28 | |
| 29 | // Quit when all windows are closed. |
| 30 | app.on('window-all-closed', function() { |
| 31 | // On macOS it is common for applications and their menu bar |
| 32 | // to stay active until the user quits explicitly with Cmd + Q |
| 33 | if (process.platform !== 'darwin') app.quit(); |
| 34 | }) |
| 35 | |
| 36 | app.on('activate', function() { |
| 37 | // On macOS it's common to re-create a window in the app when the |
| 38 | // dock icon is clicked and there are no other windows open. |
| 39 | if (BrowserWindow.getAllWindows().length === 0) createWindow(); |
| 40 | }); |
| 41 | |
| 42 | // In this file you can include the rest of your app's specific main process |
| 43 | // code. You can also put them in separate files and require them here. |