-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
46 lines (43 loc) · 1.16 KB
/
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
34
35
36
37
38
39
40
41
42
43
44
45
46
const {app, BrowserWindow, ipcMain, Notification} = require('electron')
let mainWindow;
function handleIPC() {
ipcMain.handle('notification', async (e, {body, title, actions, closeButtonText}) => {
let res = await new Promise((resolve, reject) => {
console.log({
title,
body,
actions,
closeButtonText
})
let notification = new Notification({
title,
body,
actions,
closeButtonText
})
notification.show()
notification.on('action', function(event) {
resolve({event: 'action'})
})
notification.on('close', function(event) {
resolve({event: 'close'})
})
})
return res
})
}
function createMainWindow() {
mainWindow = new BrowserWindow({
width: 450,
height: 530,
webPreferences: {
nodeIntegration: true
}
})
mainWindow.loadFile('./index.html')
return mainWindow
}
app.whenReady().then(() => {
handleIPC()
createMainWindow()
})