index.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. const { app, BrowserWindow } = require('electron');
  2. const path = require('path');
  3. // Handle creating/removing shortcuts on Windows when installing/uninstalling.
  4. if (require('electron-squirrel-startup')) { // eslint-disable-line global-require
  5. app.quit();
  6. }
  7. const createWindow = () => {
  8. // Create the browser window.
  9. const mainWindow = new BrowserWindow({
  10. width: 800,
  11. height: 600,
  12. });
  13. // and load the index.html of the app.
  14. mainWindow.loadFile(path.join(__dirname, 'index.html'));
  15. // Open the DevTools.
  16. mainWindow.webContents.openDevTools();
  17. };
  18. // This method will be called when Electron has finished
  19. // initialization and is ready to create browser windows.
  20. // Some APIs can only be used after this event occurs.
  21. app.on('ready', createWindow);
  22. // Quit when all windows are closed.
  23. app.on('window-all-closed', () => {
  24. // On OS X it is common for applications and their menu bar
  25. // to stay active until the user quits explicitly with Cmd + Q
  26. if (process.platform !== 'darwin') {
  27. app.quit();
  28. }
  29. });
  30. app.on('activate', () => {
  31. // On OS X it's common to re-create a window in the app when the
  32. // dock icon is clicked and there are no other windows open.
  33. if (BrowserWindow.getAllWindows().length === 0) {
  34. createWindow();
  35. }
  36. });
  37. // In this file you can include the rest of your app's specific main process
  38. // code. You can also put them in separate files and import them here.