2018-10-03 19:27:40 -04:00
|
|
|
const { app, BrowserWindow, webFrame, Menu, dialog } = require('electron')
|
2017-11-04 20:52:05 -04:00
|
|
|
const path = require('path')
|
|
|
|
const url = require('url')
|
2017-12-26 17:14:58 -05:00
|
|
|
const shell = require('electron').shell
|
2017-11-04 20:52:05 -04:00
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
let is_shown = true
|
2017-11-04 20:52:05 -04:00
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.on('ready', () => {
|
2018-09-13 17:38:14 -04:00
|
|
|
app.win = new BrowserWindow({
|
2018-10-03 19:27:40 -04:00
|
|
|
width: 405,
|
|
|
|
height: 420,
|
|
|
|
minWidth: 405,
|
2018-09-13 17:38:14 -04:00
|
|
|
minHeight: 420,
|
2018-10-03 19:27:40 -04:00
|
|
|
webPreferences: { zoomFactor: 1.0 },
|
|
|
|
backgroundColor: '#000',
|
|
|
|
frame: false,
|
|
|
|
autoHideMenuBar: true,
|
2018-09-13 17:38:14 -04:00
|
|
|
icon: __dirname + '/icon.ico'
|
|
|
|
})
|
2018-10-03 19:27:40 -04:00
|
|
|
|
|
|
|
app.win.loadURL(`file://${__dirname}/sources/index.html`)
|
2018-09-14 16:13:39 -04:00
|
|
|
// app.inspect();
|
2018-10-03 19:27:40 -04:00
|
|
|
|
2018-01-12 22:03:21 -05:00
|
|
|
app.win.on('closed', () => {
|
2017-11-04 20:52:05 -04:00
|
|
|
win = null
|
|
|
|
app.quit()
|
|
|
|
})
|
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.win.on('hide', function () {
|
|
|
|
is_shown = false
|
2017-11-04 20:52:05 -04:00
|
|
|
})
|
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.win.on('show', function () {
|
|
|
|
is_shown = true
|
2017-11-04 20:52:05 -04:00
|
|
|
})
|
2018-09-13 17:38:14 -04:00
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.on('window-all-closed', () => {
|
2018-09-13 17:38:14 -04:00
|
|
|
app.quit()
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (app.win === null) {
|
|
|
|
createWindow()
|
2018-10-03 19:27:40 -04:00
|
|
|
} else {
|
|
|
|
app.win.show()
|
2018-09-13 17:38:14 -04:00
|
|
|
}
|
|
|
|
})
|
2017-11-04 20:52:05 -04:00
|
|
|
})
|
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.inspect = function () {
|
|
|
|
app.win.toggleDevTools()
|
2018-09-13 17:38:14 -04:00
|
|
|
}
|
2017-11-04 20:52:05 -04:00
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.toggle_fullscreen = function () {
|
|
|
|
app.win.setFullScreen(!app.win.isFullScreen())
|
2018-09-13 17:38:14 -04:00
|
|
|
}
|
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.toggle_visible = function () {
|
|
|
|
if (process.platform == 'win32') {
|
|
|
|
if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() }
|
|
|
|
} else {
|
|
|
|
if (is_shown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() }
|
2018-09-13 23:34:07 -04:00
|
|
|
}
|
2018-09-13 17:38:14 -04:00
|
|
|
}
|
|
|
|
|
2018-10-03 19:27:40 -04:00
|
|
|
app.inject_menu = function (menu) {
|
|
|
|
try {
|
|
|
|
Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
|
|
|
|
} catch (err) {
|
|
|
|
console.warn('Cannot inject menu.')
|
2018-09-13 23:34:07 -04:00
|
|
|
}
|
2018-10-03 19:27:40 -04:00
|
|
|
}
|