6502SimDesktop/main.js

41 lines
928 B
JavaScript
Raw Normal View History

2017-03-12 05:51:09 +00:00
const {app, Menu, BrowserWindow} = require('electron')
2017-03-10 20:41:36 +00:00
const path = require('path')
const url = require('url')
2017-03-12 05:51:09 +00:00
const { OSXtemplate, PCtemplate } = require('./app/electron/menu')
2017-03-10 20:41:36 +00:00
let mainWindow
function createWindow () {
2017-03-12 05:51:09 +00:00
mainWindow = new BrowserWindow({width: 700, height: 600})
2017-03-10 20:41:36 +00:00
mainWindow.loadURL(url.format({
pathname: path.join(__dirname, 'app/index.html'),
protocol: 'file:',
slashes: true
}))
2017-03-12 05:51:09 +00:00
if(process.platform === 'darwin') {
Menu.setApplicationMenu(Menu.buildFromTemplate(OSXtemplate));
} else if(process.platform !== 'darwin') {
BrowserWindow.setMenu(Menu.buildFromTemplate(PCtemplate))
}
2017-03-10 20:41:36 +00:00
mainWindow.on('closed', function () {
mainWindow = null
})
}
app.on('ready', createWindow)
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
if (mainWindow === null) {
createWindow()
}
2017-03-12 05:51:09 +00:00
})