electron.js 558 B

1234567891011121314151617181920212223242526272829
  1. const { app, BrowserWindow } = require('electron');
  2. const path = require('path');
  3. function createWindow() {
  4. const mainWindow = new BrowserWindow({
  5. width: 1600,
  6. height: 900,
  7. webPreferences: {
  8. nodeIntegration: false,
  9. contextIsolation: true
  10. },
  11. });
  12. mainWindow.loadFile('index.html');
  13. }
  14. app.on('ready', createWindow);
  15. app.on('window-all-closed', () => {
  16. if (process.platform !== 'darwin') {
  17. app.quit();
  18. }
  19. });
  20. app.on('activate', () => {
  21. if (BrowserWindow.getAllWindows().length === 0) {
  22. createWindow();
  23. }
  24. });