main.js 747 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const electron = require('electron');
  2. const app = electron.app;
  3. const BrowserWindow = electron.BrowserWindow;
  4. let mainWindow;
  5. function createWindow() {
  6. mainWindow = new BrowserWindow({
  7. width: 800,
  8. height: 600,
  9. webPreferences: {
  10. nodeIntegration: true,
  11. worldSafeExecuteJavaScript: true,
  12. sandbox: false,
  13. contextIsolation: false
  14. }
  15. });
  16. mainWindow.loadURL(`file://${__dirname}/electron-index.html`);
  17. mainWindow.webContents.openDevTools();
  18. mainWindow.on('closed', function () {
  19. mainWindow = null;
  20. });
  21. }
  22. app.on('ready', createWindow);
  23. app.on('window-all-closed', function () {
  24. if (process.platform !== 'darwin') {
  25. app.quit();
  26. }
  27. });
  28. app.on('activate', function () {
  29. if (mainWindow === null) {
  30. createWindow();
  31. }
  32. });