2020-01-13 06:35:56 +00:00
|
|
|
// Modules to control application life and create native browser window
|
2020-09-14 17:36:54 +00:00
|
|
|
const { app, BrowserWindow, ipcMain } = require('electron')
|
2020-01-13 06:35:56 +00:00
|
|
|
|
2020-09-14 17:36:54 +00:00
|
|
|
ipcMain.on('new-window', (event, { url, width, height }) => {
|
|
|
|
const win = new BrowserWindow({ width, height })
|
|
|
|
win.loadURL(url)
|
|
|
|
})
|
2020-01-13 06:35:56 +00:00
|
|
|
|
|
|
|
function createWindow () {
|
|
|
|
// Create the browser window.
|
2020-09-14 17:36:54 +00:00
|
|
|
const mainWindow = new BrowserWindow({
|
2020-01-13 06:35:56 +00:00
|
|
|
width: 800,
|
|
|
|
height: 600,
|
|
|
|
webPreferences: {
|
|
|
|
nodeIntegration: true
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// and load the index.html of the app.
|
|
|
|
mainWindow.loadFile('index.html')
|
|
|
|
}
|
|
|
|
|
|
|
|
// This method will be called when Electron has finished
|
|
|
|
// initialization and is ready to create browser windows.
|
|
|
|
// Some APIs can only be used after this event occurs.
|
2020-02-03 22:43:22 +00:00
|
|
|
app.whenReady().then(createWindow)
|
2020-01-13 06:35:56 +00:00
|
|
|
|
|
|
|
// Quit when all windows are closed.
|
|
|
|
app.on('window-all-closed', function () {
|
2020-03-31 04:06:25 +00:00
|
|
|
// On macOS it is common for applications and their menu bar
|
2020-01-13 06:35:56 +00:00
|
|
|
// to stay active until the user quits explicitly with Cmd + Q
|
|
|
|
if (process.platform !== 'darwin') {
|
|
|
|
app.quit()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
app.on('activate', function () {
|
2020-03-31 04:06:25 +00:00
|
|
|
// On macOS it is common to re-create a window in the app when the
|
2020-01-13 06:35:56 +00:00
|
|
|
// dock icon is clicked and there are no other windows open.
|
|
|
|
if (mainWindow === null) {
|
|
|
|
createWindow()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
// In this file you can include the rest of your app's specific main process
|
|
|
|
// code. You can also put them in separate files and require them here.
|