electron/spec/fixtures/apps/libuv-hang/main.js

38 lines
753 B
JavaScript
Raw Normal View History

2021-03-22 20:11:03 +00:00
const { app, BrowserWindow, ipcMain } = require('electron');
const path = require('path');
async function createWindow () {
const mainWindow = new BrowserWindow({
show: false,
webPreferences: {
preload: path.join(__dirname, 'preload.js'),
sandbox: false
2021-03-22 20:11:03 +00:00
}
});
await mainWindow.loadFile('index.html');
}
app.whenReady().then(() => {
createWindow();
app.on('activate', function () {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});
let count = 0;
ipcMain.handle('reload-successful', () => {
if (count === 2) {
app.quit();
} else {
count++;
return count;
}
});
app.on('window-all-closed', function () {
if (process.platform !== 'darwin') app.quit();
});