electron/default_app/default_app.js

46 lines
1.2 KiB
JavaScript
Raw Normal View History

const {app, BrowserWindow, Notification} = require('electron')
2016-07-06 11:47:21 -07:00
const path = require('path')
2016-07-06 11:47:21 -07:00
let mainWindow = null
// Quit when all windows are closed.
app.on('window-all-closed', () => {
app.quit()
})
exports.load = (appUrl) => {
app.on('ready', () => {
2016-07-06 11:47:21 -07:00
const options = {
width: 800,
height: 600,
autoHideMenuBar: true,
2016-04-26 09:25:46 -07:00
backgroundColor: '#FFFFFF',
2017-03-15 19:34:21 +09:00
webPreferences: {
nodeIntegrationInWorker: true
},
2016-03-27 10:38:32 -07:00
useContentSize: true
2016-07-06 11:47:21 -07:00
}
if (process.platform === 'linux') {
options.icon = path.join(__dirname, 'icon.png')
}
mainWindow = new BrowserWindow(options)
mainWindow.loadURL(appUrl)
mainWindow.focus()
const n = new Notification({
title: 'Hello World',
body: 'This is the long and complicated body for this notification that just goes on and on and on and never really seems to stop',
silent: true,
2017-04-24 13:07:42 +10:00
icon: path.resolve('C:\\Users\\Samuel\\Downloads\\icon.png'),
hasReply: true,
replyPlaceholder: 'Type Here!!'
2017-04-24 13:07:42 +10:00
})
n.on('show', () => console.log('showed'))
n.on('click', () => console.info('clicked!!'))
n.on('reply', (e, reply) => console.log('Replied:', reply))
2017-04-24 13:07:42 +10:00
n.show()
})
}