You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.6 KiB

10 years ago
10 years ago
10 years ago
  1. 'use strict';
  2. const electron = require('electron');
  3. const app = electron.app; // Module to control application life.
  4. const BrowserWindow = electron.BrowserWindow; // Module to create native browser window.
  5. // Keep a global reference of the window object, if you don't, the window will
  6. // be closed automatically when the JavaScript object is garbage collected.
  7. let mainWindow;
  8. // Quit when all windows are closed.
  9. app.on('window-all-closed', function () {
  10. // On OS X it is common for applications and their menu bar
  11. // to stay active until the user quits explicitly with Cmd + Q
  12. if (process.platform !== 'darwin') {
  13. app.quit();
  14. }
  15. });
  16. app.on('activate', function () {
  17. // On OS X it's common to re-create a window in the app when the
  18. // dock icon is clicked and there are no other windows open.
  19. if (mainWindow === null) {
  20. app.emit('ready');
  21. }
  22. });
  23. // This method will be called when Electron has finished
  24. // initialization and is ready to create browser windows.
  25. app.on('ready', function() {
  26. // Create the browser window.
  27. mainWindow = new BrowserWindow({width: 800, height: 600});
  28. // and load the index.html of the app.
  29. mainWindow.loadURL('file://' + __dirname + '/index.html');
  30. // Open the DevTools.
  31. mainWindow.webContents.openDevTools();
  32. // Emitted when the window is closed.
  33. mainWindow.on('closed', function() {
  34. // Dereference the window object, usually you would store windows
  35. // in an array if your app supports multi windows, this is the time
  36. // when you should delete the corresponding element.
  37. mainWindow = null;
  38. });
  39. });