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.

50 lines
1.7 KiB

10 years ago
10 years ago
  1. // Modules to control application life and create native browser window
  2. const {app, BrowserWindow} = require('electron')
  3. // Keep a global reference of the window object, if you don't, the window will
  4. // be closed automatically when the JavaScript object is garbage collected.
  5. let mainWindow
  6. function createWindow () {
  7. // Create the browser window.
  8. mainWindow = new BrowserWindow({width: 800, height: 600})
  9. // and load the index.html of the app.
  10. mainWindow.loadFile('index.html')
  11. // Open the DevTools.
  12. // mainWindow.webContents.openDevTools()
  13. // Emitted when the window is closed.
  14. mainWindow.on('closed', function () {
  15. // Dereference the window object, usually you would store windows
  16. // in an array if your app supports multi windows, this is the time
  17. // when you should delete the corresponding element.
  18. mainWindow = null
  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. // Quit when all windows are closed.
  26. app.on('window-all-closed', function () {
  27. // On OS X it is common for applications and their menu bar
  28. // to stay active until the user quits explicitly with Cmd + Q
  29. if (process.platform !== 'darwin') {
  30. app.quit()
  31. }
  32. })
  33. app.on('activate', function () {
  34. // On OS X it's common to re-create a window in the app when the
  35. // dock icon is clicked and there are no other windows open.
  36. if (mainWindow === null) {
  37. createWindow()
  38. }
  39. })
  40. // In this file you can include the rest of your app's specific main process
  41. // code. You can also put them in separate files and require them here.