You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
potato-launcher/index.js

77 lines
1.3 KiB

const { app, BrowserWindow, ipcMain } = require('electron')
const path = require('path')
// add var for window
let appWindow = null
// add events
app.on('ready', handleReady)
app.on('activate', handleActivate)
app.on('window-all-closed', handleAllClosed)
/**
* create window for app
*
*
*/
function handleReady() {
// create window
appWindow = new BrowserWindow({
frame: false,
webPreferences: {
nodeIntegration: true,
nodeIntegrationInWorker: false,
contextIsolation: false,
webSecurity: true,
enableRemoteModule: true
}
})
// max size of window
appWindow.maximize()
appWindow.setMenu(null)
// loading
appWindow.loadURL('file://' + __dirname + '/dist/index.html')
// add event if window closed
appWindow.on('closed', handleClose)
if (process.env.debug) {
appWindow.webContents.openDevTools()
}
// adding events for ipcMain
ipcMain.on('getPathUserData', (event) => {
event.returnValue = app.getPath('userData')
})
}
/**
* handle close window
*
*/
function handleClose() {
appWindow = null
}
/**
*
*
*/
function handleAllClosed() {
if (process.platform !== 'darwin') {
app.quit()
}
}
/**
*
*
*/
function handleActivate() {
if (appWindow === null) {
createAppWindow()
}
}