mirror of
https://github.com/usebruno/bruno.git
synced 2024-11-25 09:23:17 +01:00
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
// Modules
|
|
const {app, BrowserWindow} = require('electron')
|
|
|
|
// 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 mainWindow
|
|
|
|
// Create a new BrowserWindow when `app` is ready
|
|
function createWindow () {
|
|
|
|
mainWindow = new BrowserWindow({
|
|
width: 1000, height: 800,
|
|
webPreferences: {
|
|
// Disable 'contextIsolation' to allow 'nodeIntegration'
|
|
// 'contextIsolation' defaults to "true" as from Electron v12
|
|
contextIsolation: false,
|
|
nodeIntegration: true
|
|
}
|
|
})
|
|
|
|
// Load index.html into the new BrowserWindow
|
|
mainWindow.loadFile('index.html')
|
|
|
|
// Open DevTools - Remove for PRODUCTION!
|
|
// mainWindow.webContents.openDevTools();
|
|
|
|
// Listen for window being closed
|
|
mainWindow.on('closed', () => {
|
|
mainWindow = null
|
|
})
|
|
}
|
|
|
|
// Electron `app` is ready
|
|
app.on('ready', createWindow)
|
|
|
|
// Quit when all windows are closed - (Not macOS - Darwin)
|
|
app.on('window-all-closed', () => {
|
|
if (process.platform !== 'darwin') app.quit()
|
|
})
|
|
|
|
// When app icon is clicked and app is running, (macOS) recreate the BrowserWindow
|
|
app.on('activate', () => {
|
|
if (mainWindow === null) createWindow()
|
|
})
|