Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. const { app, BrowserWindow } = require('electron');
  2. const path = require('path')
  3.  
  4. // Keep a global reference of the window object, if you don't, the window will
  5. // be closed automatically when the JavaScript object is garbage collected.
  6. let mainWindow;
  7.  
  8. function createWindow() {
  9. const mode = process.env.NODE_ENV;
  10. mainWindow = new BrowserWindow({
  11. width: 900,
  12. height: 680,
  13. });
  14.  
  15. mainWindow.loadURL(`file://${path.join(__dirname, '../public/index.html')}`);
  16. mainWindow.on('closed', () => {
  17. mainWindow = null;
  18. });
  19. }
  20.  
  21. // This method will be called when Electron has finished
  22. // initialization and is ready to create browser windows.
  23. // Some APIs can only be used after this event occurs.
  24. app.on('ready', createWindow);
  25.  
  26. // Quit when all windows are closed.
  27. app.on('window-all-closed', () => {
  28. // On macOS it is common for applications and their menu bar
  29. // to stay active until the user quits explicitly with Cmd + Q
  30. if (process.platform !== 'darwin') {
  31. app.quit();
  32. }
  33. });
  34.  
  35. app.on('activate', () => {
  36. // On macOS it's common to re-create a window in the app when the
  37. // dock icon is clicked and there are no other windows open.
  38. if (mainWindow === null) {
  39. createWindow();
  40. }
  41. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement