|
| 1 | +// @ts-nocheck |
| 2 | +import * as isDev from 'electron-is-dev'; |
| 3 | +import { app, BrowserWindow } from 'electron'; |
| 4 | +// Modules to control application life and create native browser window |
| 5 | +import * as path from 'path'; |
| 6 | + |
| 7 | +function createWindow(): BrowserWindow { |
| 8 | + // Create the browser window. |
| 9 | + const mainWindow = new BrowserWindow({ |
| 10 | + width: 800, |
| 11 | + height: 600, |
| 12 | + webPreferences: { |
| 13 | + preload: path.join(__dirname, 'preload.js'), |
| 14 | + nodeIntegration: true, |
| 15 | + contextIsolation: false, |
| 16 | + }, |
| 17 | + }); |
| 18 | + |
| 19 | + // and load the index.html of the app. |
| 20 | + if (isDev) { |
| 21 | + // eslint-disable-next-line @iceworks/best-practices/no-http-url |
| 22 | + mainWindow.loadURL('http://localhost:3000'); |
| 23 | + } else { |
| 24 | + mainWindow.loadFile(path.resolve(__dirname, './assets/index.html')); |
| 25 | + } |
| 26 | + |
| 27 | + // mainWindow.webContents.openDevTools() |
| 28 | +} |
| 29 | + |
| 30 | +// This method will be called when Electron has finished |
| 31 | +// initialization and is ready to create browser windows. |
| 32 | +// Some APIs can only be used after this event occurs. |
| 33 | +app.on('ready', createWindow); |
| 34 | + |
| 35 | +// Quit when all windows are closed. |
| 36 | +app.on('window-all-closed', () => { |
| 37 | + // On macOS it is common for applications and their menu bar |
| 38 | + // to stay active until the user quits explicitly with Cmd + Q |
| 39 | + if (process.platform !== 'darwin') app.quit(); |
| 40 | +}); |
| 41 | + |
| 42 | +app.on('activate', () => { |
| 43 | + // On macOS it's common to re-create a window in the app when the |
| 44 | + // dock icon is clicked and there are no other windows open. |
| 45 | + if (BrowserWindow.getAllWindows().length === 0) createWindow(); |
| 46 | +}); |
| 47 | + |
| 48 | +// In this file you can include the rest of your app's specific main process |
| 49 | +// code. You can also put them in separate files and require them here. |
0 commit comments