-
Notifications
You must be signed in to change notification settings - Fork 5
/
preload.js
40 lines (38 loc) · 1.12 KB
/
preload.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
const { ipcRenderer, contextBridge } = require('electron');
contextBridge.exposeInMainWorld(
'api', {
send: (channel, data) => {
console.log(channel, data);
let validChannels = [
"quit-app",
"show-preferences",
"convert_again",
"convert-file",
"open-external-link",
];
if (validChannels.includes(channel)) {
ipcRenderer.send(channel, data);
}
},
receive: (channel, func) => {
console.log(channel, func);
let validChannels = ["fromMain"];
if (validChannels.includes(channel)) {
// Deliberately strip event as it includes `sender`
ipcRenderer.on(channel, (event, ...args) => func(...args));
}
}
}
);
ipcRenderer.on('notify', (event, payload) => {
console.log(payload)
const notification = {
title: payload.title,
body: payload.body
}
const showNotification = new window.Notification(notification.title, notification);
// let notification = new Notification(payload.title, {
// body: payload.body
// })
// console.log(showNotification)
})