6502SimDesktop/main.js

43 lines
968 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-29 23:49:51 +00:00
// mainWindow.webContents.openDevTools()
2017-03-10 20:41:36 +00:00
2017-03-12 05:51:09 +00:00
if(process.platform === 'darwin') {
2017-03-29 23:49:51 +00:00
Menu.setApplicationMenu(Menu.buildFromTemplate(OSXtemplate))
2017-03-12 05:51:09 +00:00
} else if(process.platform !== 'darwin') {
2017-05-08 03:39:10 +00:00
mainWindow.setMenu(Menu.buildFromTemplate(PCtemplate))
2017-03-12 05:51:09 +00:00
}
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-29 23:49:51 +00:00
})