-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
83 lines (67 loc) · 2.18 KB
/
index.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
const electron = require('electron');
const {app, BrowserWindow, Notification, Tray, Menu, ipcMain} = electron;
let tray = null;
let mainWindow = null;
const createMainWindow = ()=>{
mainWindow = new BrowserWindow({
with: 800,
height: 600,
// show: false, systray
//Expose Nodejs in the browser using contextBridge + ipc
// webPreferences:{
// preload: `${__dirname}/preload.js`
// }
});
mainWindow.loadURL(`file://${__dirname}/mainWindow.html`);
}
app.whenReady().then(()=>{
createMainWindow();
//SYS TRAY
// tray = new Tray(`${__dirname}/iconTemplate.png`);
// const contextMenu = Menu.buildFromTemplate([
// // { label: 'Item1', type: 'radio' },
// // { label: 'Item2', type: 'radio' },
// // { label: 'Item3', type: 'radio', checked: true },
// // { label: 'Item4', type: 'radio' }
// { label: 'Item1'},
// { label: 'Item2'},
// { label: 'Item3'},
// { label: 'Item4', click: ()=>{
// createMainWindow();
// mainWindow.show();
// }}
// ])
// tray.setToolTip('This is my application.')
// tray.setContextMenu(contextMenu)
//NOTIFICATION
// const notification = new Notification({
// title: 'Custom Notification',
// subtitle: 'Subtitle of the Notification'
// });
// notification.show();
//backgroundThrottling GOTCHA:
// tray = new Tray(`${__dirname}/iconTemplate.png`);
// const contextMenu = Menu.buildFromTemplate([
// { label: 'open window', click: ()=>{
// mainWindow.show();
// }}
// ])
// tray.setContextMenu(contextMenu)
//backgroundThrottling GOTCHA:
// mainWindow.on('close', (e)=>{
// e.preventDefault();
// mainWindow.hide();
// })
})
//systray + backgroundThrottling GOTCHA
// app.on('window-all-closed', () => {
// if (process.platform !== 'darwin') app.quit()
// })
// //ipc
// ipcMain.on('asynchronous-message', (event, arg) => {
// console.log(arg);
// //shortcut
// event.reply("asynchronous-reply","pong");
// //specific window
// mainWindow.webContents.send("asynchronous-reply","pong");
// })