forked from Jerga99/electron-react-boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
33 lines (26 loc) · 758 Bytes
/
main.js
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
33
const { BrowserWindow, app, ipcMain, Notification } = require('electron');
const path = require('path');
const isDev = !app.isPackaged;
function createWindow() {
const win = new BrowserWindow({
width: 1200,
height: 800,
backgroundColor: "white",
webPreferences: {
nodeIntegration: false,
worldSafeExecuteJavaScript: true,
contextIsolation: true,
preload: path.join(__dirname, 'preload.js')
}
})
win.loadFile('index.html');
}
if (isDev) {
require('electron-reload')(__dirname, {
electron: path.join(__dirname, 'node_modules', '.bin', 'electron')
})
}
ipcMain.on('notify', (_, message) => {
new Notification({title: 'Notifiation', body: message}).show();
})
app.whenReady().then(createWindow)