2023-08-28 11:23:10 +00:00
|
|
|
const { app, BrowserWindow, Notification } = require('electron/main')
|
2020-11-30 07:48:39 +00:00
|
|
|
|
|
|
|
function createWindow () {
|
|
|
|
const win = new BrowserWindow({
|
|
|
|
width: 800,
|
2021-05-27 01:18:50 +00:00
|
|
|
height: 600
|
2020-11-30 07:48:39 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
win.loadFile('index.html')
|
|
|
|
}
|
|
|
|
|
2021-05-27 01:18:50 +00:00
|
|
|
const NOTIFICATION_TITLE = 'Basic Notification'
|
|
|
|
const NOTIFICATION_BODY = 'Notification from the Main process'
|
|
|
|
|
2020-11-30 07:48:39 +00:00
|
|
|
function showNotification () {
|
2021-05-27 01:18:50 +00:00
|
|
|
new Notification({ title: NOTIFICATION_TITLE, body: NOTIFICATION_BODY }).show()
|
2020-11-30 07:48:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
app.whenReady().then(createWindow).then(showNotification)
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|