main.js 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. // Modules to control application life and create native browser window
  2. const { app, BrowserWindow } = require('electron/main')
  3. function createWindow () {
  4. // Create the browser window.
  5. const mainWindow = new BrowserWindow({
  6. width: 800,
  7. height: 600
  8. })
  9. // and load the index.html of the app.
  10. mainWindow.loadFile('index.html')
  11. }
  12. // This method will be called when Electron has finished
  13. // initialization and is ready to create browser windows.
  14. // Some APIs can only be used after this event occurs.
  15. app.whenReady().then(() => {
  16. createWindow()
  17. app.on('activate', function () {
  18. // On macOS it's common to re-create a window in the app when the
  19. // dock icon is clicked and there are no other windows open.
  20. if (BrowserWindow.getAllWindows().length === 0) createWindow()
  21. })
  22. })
  23. // Quit when all windows are closed, except on macOS. There, it's common
  24. // for applications and their menu bar to stay active until the user quits
  25. // explicitly with Cmd + Q.
  26. app.on('window-all-closed', function () {
  27. if (process.platform !== 'darwin') app.quit()
  28. })