2021-03-22 20:11:03 +00:00
|
|
|
const { app, BrowserWindow, ipcMain } = require('electron');
|
2023-06-15 14:42:27 +00:00
|
|
|
const path = require('node:path');
|
2021-03-22 20:11:03 +00:00
|
|
|
|
|
|
|
async function createWindow () {
|
|
|
|
const mainWindow = new BrowserWindow({
|
|
|
|
show: false,
|
|
|
|
webPreferences: {
|
2022-07-11 23:28:09 +00:00
|
|
|
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();
|
|
|
|
});
|