2017-05-17 06:26:46 +00:00
|
|
|
const {app, BrowserWindow} = require('electron')
|
|
|
|
const path = require('path')
|
|
|
|
const url = require('url')
|
2017-11-19 20:08:52 +00:00
|
|
|
const fs = require('fs')
|
2017-05-17 06:26:46 +00:00
|
|
|
|
|
|
|
// Keep a global reference of the window object, if you don't, the window will
|
|
|
|
// be closed automatically when the JavaScript object is garbage collected.
|
|
|
|
let win
|
|
|
|
|
|
|
|
function createWindow() {
|
2017-12-02 07:59:25 +00:00
|
|
|
win = new BrowserWindow({
|
|
|
|
width: 980,
|
|
|
|
height: 552,
|
|
|
|
icon: getPlatformIcon('WesterosSealSquare'),
|
|
|
|
frame: false,
|
|
|
|
webPreferences: {
|
|
|
|
preload: path.join(__dirname, 'app', 'assets', 'js', 'preloader.js')
|
|
|
|
}
|
|
|
|
})
|
2017-05-17 06:26:46 +00:00
|
|
|
|
2018-02-20 00:13:10 +00:00
|
|
|
//ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length)))
|
2017-11-19 20:08:52 +00:00
|
|
|
|
2017-05-17 06:26:46 +00:00
|
|
|
win.loadURL(url.format({
|
2018-02-20 00:13:10 +00:00
|
|
|
pathname: path.join(__dirname, 'app', 'app.html'),
|
2017-05-17 06:26:46 +00:00
|
|
|
protocol: 'file:',
|
|
|
|
slashes: true
|
|
|
|
}))
|
|
|
|
|
|
|
|
win.setMenu(null)
|
|
|
|
|
2017-08-27 05:13:48 +00:00
|
|
|
win.setResizable(true)
|
|
|
|
|
2017-05-17 06:26:46 +00:00
|
|
|
win.on('closed', () => {
|
|
|
|
win = null
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
function getPlatformIcon(filename){
|
|
|
|
const opSys = process.platform
|
|
|
|
if (opSys === 'darwin') {
|
|
|
|
filename = filename + '.icns'
|
|
|
|
} else if (opSys === 'win32') {
|
|
|
|
filename = filename + '.ico'
|
|
|
|
} else {
|
|
|
|
filename = filename + '.png'
|
|
|
|
}
|
|
|
|
|
|
|
|
return path.join(__dirname, 'app', 'assets', 'images', filename)
|
|
|
|
}
|
|
|
|
|
|
|
|
app.on('ready', createWindow);
|
|
|
|
|
|
|
|
app.on('window-all-closed', () => {
|
|
|
|
// On macOS it is common for applications and their menu bar
|
|
|
|
// to stay active until the user quits explicitly with Cmd + Q
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', () => {
|
|
|
|
// On macOS it's common to re-create a window in the app when the
|
|
|
|
// dock icon is clicked and there are no other windows open.
|
|
|
|
if (win === null) {
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|