windows95/src/index.js

56 lines
1.1 KiB
JavaScript
Raw Normal View History

2018-08-23 07:25:17 +02:00
const { app, BrowserWindow } = require('electron')
2018-08-23 07:03:28 +02:00
const path = require('path')
const { createMenu } = require('./menu')
2018-08-25 05:55:03 +02:00
const { setupProtocol } = require('./es6')
2018-08-23 04:51:31 +02:00
if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
2018-08-23 07:03:28 +02:00
app.quit()
2018-08-23 04:51:31 +02:00
}
2018-08-25 05:55:18 +02:00
if (app.isPackaged) {
require('update-electron-app')({
repo: 'felixrieseberg/windows95',
updateInterval: '1 hour'
})
}
2018-08-23 07:25:17 +02:00
let mainWindow
2018-08-23 04:51:31 +02:00
const createWindow = () => {
// Create the browser window.
mainWindow = new BrowserWindow({
width: 1024,
height: 768,
2018-08-23 04:51:31 +02:00
useContentSize: true,
2018-08-23 07:03:28 +02:00
webPreferences: {
2018-08-25 05:55:03 +02:00
nodeIntegration: false,
2018-08-23 07:03:28 +02:00
preload: path.join(__dirname, 'preload.js')
}
2018-08-23 07:25:17 +02:00
})
2018-08-23 04:51:31 +02:00
2018-08-25 05:55:03 +02:00
mainWindow.loadURL(`file://${__dirname}/renderer/index.html`)
2018-08-23 04:51:31 +02:00
mainWindow.on('closed', () => {
2018-08-23 07:25:17 +02:00
mainWindow = null
2018-08-23 07:03:28 +02:00
})
}
2018-08-23 04:51:31 +02:00
2018-08-23 07:03:28 +02:00
app.on('ready', async () => {
2018-08-25 05:55:03 +02:00
await setupProtocol()
2018-08-23 07:03:28 +02:00
await createMenu()
2018-08-25 05:55:03 +02:00
2018-08-23 07:03:28 +02:00
createWindow()
})
2018-08-23 04:51:31 +02:00
// Quit when all windows are closed.
app.on('window-all-closed', () => {
2018-08-23 07:03:28 +02:00
app.quit()
})
2018-08-23 04:51:31 +02:00
app.on('activate', () => {
if (mainWindow === null) {
2018-08-23 07:03:28 +02:00
createWindow()
2018-08-23 04:51:31 +02:00
}
2018-08-23 07:03:28 +02:00
})