const { app, BrowserWindow } = require('electron') const path = require('path') const devServerUrl = process.env.ELECTRON_RENDERER_URL const rendererEntry = path.join(__dirname, '..', 'dist', 'build', 'h5', 'index.html') if (devServerUrl) { app.commandLine.appendSwitch('disable-http-cache') } function createWindow() { const win = new BrowserWindow({ width: 1200, height: 800, webPreferences: { preload: path.join(__dirname, 'preload.js'), contextIsolation: true, nodeIntegration: false, }, }) if (devServerUrl) { win.webContents.session.clearCache().catch(() => {}) win.loadURL(devServerUrl) win.webContents.openDevTools({ mode: 'detach' }) return } win.loadFile(rendererEntry) } app.whenReady().then(() => { createWindow() app.on('activate', () => { if (BrowserWindow.getAllWindows().length === 0) { createWindow() } }) }) app.on('window-all-closed', () => { if (process.platform !== 'darwin') { app.quit() } })