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.

43 lines
1.4 KiB

10 years ago
  1. // Modules to control application life and create native browser window
  2. const {app, BrowserWindow} = require('electron')
  3. const path = require('path')
  4. function createWindow () {
  5. // Create the browser window.
  6. const mainWindow = new BrowserWindow({
  7. width: 800,
  8. height: 600,
  9. webPreferences: {
  10. preload: path.join(__dirname, 'preload.js')
  11. }
  12. })
  13. // and load the index.html of the app.
  14. mainWindow.loadFile('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.whenReady().then(() => {
  22. createWindow()
  23. app.on('activate', function () {
  24. // On macOS it's common to re-create a window in the app when the
  25. // dock icon is clicked and there are no other windows open.
  26. if (BrowserWindow.getAllWindows().length === 0) createWindow()
  27. })
  28. })
  29. // Quit when all windows are closed, except on macOS. There, it's common
  30. // for applications and their menu bar to stay active until the user quits
  31. // explicitly with Cmd + Q.
  32. app.on('window-all-closed', function () {
  33. if (process.platform !== 'darwin') app.quit()
  34. })
  35. // In this file you can include the rest of your app's specific main process
  36. // code. You can also put them in separate files and require them here.