electron-test/main.js

30 lines
725 B
JavaScript
Raw Normal View History

const { app, BrowserWindow } = require('electron')
if (process.env.ELECTRON_IGNORE_CERT_ERRORS === '1') {
app.commandLine.appendSwitch('ignore-certificate-errors')
}
function createWindow() {
const win = new BrowserWindow({
fullscreen: false,
autoHideMenuBar: true,
webPreferences: {
contextIsolation: true,
nodeIntegration: false,
sandbox: true
}
})
const targetUrl = process.env.APP_URL || 'https://www.baidu.com'
win.loadURL(targetUrl)
}
app.whenReady().then(() => {
createWindow()
app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) createWindow()
})
})
app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit()
})