2021-07-22 13:38:11 +00:00
|
|
|
const { app, ipcMain, BrowserWindow } = require('electron');
|
2023-06-15 14:42:27 +00:00
|
|
|
const path = require('node:path');
|
|
|
|
const http = require('node:http');
|
2021-07-22 13:38:11 +00:00
|
|
|
|
|
|
|
function createWindow () {
|
|
|
|
const mainWindow = new BrowserWindow({
|
|
|
|
webPreferences: {
|
|
|
|
webSecurity: false,
|
|
|
|
preload: path.join(__dirname, 'preload.js')
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
mainWindow.loadFile('index.html');
|
|
|
|
mainWindow.webContents.on('render-process-gone', () => {
|
|
|
|
process.exit(1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
const server = http.createServer((_req, res) => {
|
|
|
|
res.end('<title>hello</title>');
|
|
|
|
}).listen(7001, '127.0.0.1');
|
|
|
|
|
|
|
|
app.whenReady().then(() => {
|
|
|
|
createWindow();
|
|
|
|
app.on('activate', () => {
|
|
|
|
if (BrowserWindow.getAllWindows().length === 0) {
|
|
|
|
createWindow();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
app.on('window-all-closed', function () {
|
|
|
|
if (process.platform !== 'darwin') app.quit();
|
|
|
|
});
|
|
|
|
|
|
|
|
ipcMain.on('test-done', () => {
|
|
|
|
console.log('test passed');
|
|
|
|
server.close();
|
|
|
|
process.exit(0);
|
|
|
|
});
|