|
1 | | -const { app, BrowserWindow, ipcMain } = require('electron'); |
2 | | -const path = require('path'); |
3 | | -const url = require('url'); |
4 | | -const { channels } = require('../src/shared/constants'); |
| 1 | +const { app, BrowserWindow, ipcMain } = require("electron"); |
| 2 | +const path = require("path"); |
| 3 | +const url = require("url"); |
| 4 | +const { channels } = require("../src/shared/constants"); |
5 | 5 |
|
6 | 6 | let mainWindow; |
7 | 7 |
|
8 | | -function createWindow () { |
9 | | - const startUrl = process.env.ELECTRON_START_URL || url.format({ |
10 | | - pathname: path.join(__dirname, '../index.html'), |
11 | | - protocol: 'file:', |
12 | | - slashes: true, |
| 8 | +function createWindow() { |
| 9 | + const startUrl = |
| 10 | + process.env.ELECTRON_START_URL || |
| 11 | + url.format({ |
| 12 | + pathname: path.join(__dirname, "../index.html"), |
| 13 | + protocol: "file:", |
| 14 | + slashes: true, |
| 15 | + }); |
| 16 | + mainWindow = new BrowserWindow({ |
| 17 | + width: 800, |
| 18 | + height: 600, |
| 19 | + webPreferences: { nodeIntegration: true }, |
13 | 20 | }); |
14 | | - mainWindow = new BrowserWindow({ width: 800, height: 600 }); |
15 | 21 | mainWindow.loadURL(startUrl); |
16 | | - mainWindow.on('closed', function () { |
| 22 | + mainWindow.on("closed", function() { |
17 | 23 | mainWindow = null; |
18 | 24 | }); |
19 | 25 | } |
20 | 26 |
|
21 | | -app.on('ready', createWindow); |
| 27 | +app.on("ready", createWindow); |
22 | 28 |
|
23 | | -app.on('window-all-closed', function () { |
24 | | - if (process.platform !== 'darwin') { |
| 29 | +app.on("window-all-closed", function() { |
| 30 | + if (process.platform !== "darwin") { |
25 | 31 | app.quit(); |
26 | 32 | } |
27 | 33 | }); |
28 | 34 |
|
29 | | -app.on('activate', function () { |
| 35 | +app.on("activate", function() { |
30 | 36 | if (mainWindow === null) { |
31 | 37 | createWindow(); |
32 | 38 | } |
33 | 39 | }); |
34 | 40 |
|
35 | 41 | ipcMain.on(channels.APP_INFO, (event) => { |
36 | | - event.sender.send(channels.APP_INFO, { |
| 42 | + event.sender.send(channels.APP_INFO, { |
37 | 43 | appName: app.getName(), |
38 | 44 | appVersion: app.getVersion(), |
39 | 45 | }); |
|
0 commit comments