pointvec/desktop/main.js
2019-04-22 08:36:12 +09:00

78 lines
1.6 KiB
JavaScript

const { app, BrowserWindow, webFrame, Menu } = require('electron')
const path = require('path')
const url = require('url')
const shell = require('electron').shell
let isShown = true
app.win = null
app.on('ready', () => {
app.win = new BrowserWindow({
width: 700,
height: 430,
minWidth: 320,
minHeight: 320,
backgroundColor: '#000',
resizable: true,
icon: __dirname + '/icon.ico',
resizable: true,
webPreferences: { zoomFactor: 1.0 },
frame: process.platform !== 'darwin',
skipTaskbar: process.platform === 'darwin',
autoHideMenuBar: process.platform === 'darwin'
})
app.win.loadURL(`file://${__dirname}/sources/index.html`)
// app.inspect()
app.win.on('closed', () => {
win = null
app.quit()
})
app.win.on('hide', function () {
isShown = false
})
app.win.on('show', function () {
isShown = true
})
app.on('window-all-closed', () => {
app.quit()
})
app.on('activate', () => {
if (app.win === null) {
createWindow()
} else {
app.win.show()
}
})
})
app.inspect = function () {
app.win.toggleDevTools()
}
app.toggleFullscreen = function () {
app.win.setFullScreen(!app.win.isFullScreen())
}
app.toggleVisible = function () {
if (process.platform === 'win32') {
if (!app.win.isMinimized()) { app.win.minimize() } else { app.win.restore() }
} else {
if (isShown && !app.win.isFullScreen()) { app.win.hide() } else { app.win.show() }
}
}
app.injectMenu = function (menu) {
try {
Menu.setApplicationMenu(Menu.buildFromTemplate(menu))
} catch (err) {
console.warn('Cannot inject menu.')
}
}