const { app, BrowserWindow, session, Menu, ipcMain } = require('electron'); const path = require('path'); ipcMain.on('quit-app', () => { app.quit(); }); app.commandLine.appendSwitch('ignore-certificate-errors'); function createWindow() { const win = new BrowserWindow({ icon: path.join(__dirname, 'assets/icon.png'), webPreferences: { preload: path.join(__dirname, 'preload.js'), contextIsolation: true, }, show: false }); win.maximize(); win.show(); if (process.env.NODE_ENV === 'development') { win.loadURL('https://localhost:8001'); win.webContents.openDevTools(); } else { win.loadFile(path.join(__dirname, 'dist/index.html')); } } app.whenReady().then(() => { session.defaultSession.setCertificateVerifyProc((request, callback) => { // Разрешаем для: // 1. localhost // 2. Всех IP в локальной сети (192.168.x.x, 10.x.x.x и т.д.) // 3. Конкретного домена (если есть) if ( request.hostname === 'localhost' || request.hostname === '127.0.0.1' || request.hostname === '0.0.0.0' || /^(192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)/.test(request.hostname) ) { return callback(0); } callback(-2); }); Menu.setApplicationMenu(null); createWindow(); }); app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit(); } }); app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow(); } });