pointvec/desktop/main.js

78 lines
1.6 KiB
JavaScript
Raw Normal View History

2019-02-06 23:06:55 -05:00
const { app, BrowserWindow, webFrame, Menu } = 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
2019-01-08 23:53:28 -05:00
let isShown = true
2017-11-04 20:52:05 -04:00
2019-02-06 23:06:55 -05:00
app.win = null
2018-10-03 19:27:40 -04:00
app.on('ready', () => {
2018-09-13 17:38:14 -04:00
app.win = new BrowserWindow({
2019-04-21 21:09:42 -04:00
width: 660,
height: 390,
2019-02-06 23:06:55 -05:00
minWidth: 320,
minHeight: 320,
2019-02-16 17:51:09 -05:00
backgroundColor: '#000',
2019-02-06 23:06:55 -05:00
resizable: true,
icon: __dirname + '/icon.ico',
2019-02-21 01:13:29 -05:00
resizable: true,
2019-04-21 19:36:12 -04:00
webPreferences: { zoomFactor: 1.0 },
2019-02-21 01:13:29 -05:00
frame: process.platform !== 'darwin',
skipTaskbar: process.platform === 'darwin',
autoHideMenuBar: process.platform === 'darwin'
2018-09-13 17:38:14 -04:00
})
2018-10-03 19:27:40 -04:00
app.win.loadURL(`file://${__dirname}/sources/index.html`)
2019-04-21 19:49:47 -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 () {
2019-01-08 23:53:28 -05:00
isShown = false
2017-11-04 20:52:05 -04:00
})
2018-10-03 19:27:40 -04:00
app.win.on('show', function () {
2019-01-08 23:53:28 -05:00
isShown = 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
2019-01-09 16:00:52 -05:00
app.toggleFullscreen = function () {
2018-10-03 19:27:40 -04:00
app.win.setFullScreen(!app.win.isFullScreen())
2018-09-13 17:38:14 -04:00
}
2019-01-09 16:00:52 -05:00
app.toggleVisible = function () {
2019-02-06 23:06:55 -05:00
if (process.platform === 'win32') {
2018-10-03 19:27:40 -04:00
if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() }
} else {
2019-01-08 23:53:28 -05:00
if (isShown && !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
}
2019-02-06 23:06:55 -05:00
app.injectMenu = function (menu) {
2018-10-03 19:27:40 -04:00
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
}