electron.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const electron = require('electron');
  2. const remote = electron.remote;
  3. const dialog = electron.dialog;
  4. var fs = require('fs');
  5. var path = require('path');
  6. // Module to control application life.
  7. const app = electron.app
  8. // Module to create native browser window.
  9. const BrowserWindow = electron.BrowserWindow
  10. // Keep a global reference of the window object, if you don't, the window will
  11. // be closed automatically when the JavaScript object is garbage collected.
  12. let mainWindow
  13. function createWindow()
  14. {
  15. // Create the browser window.
  16. mainWindow = new BrowserWindow({width: 1600, height: 1200})
  17. // and load the index.html of the app.
  18. mainWindow.loadURL(`file://${__dirname}/index.html?dev=1&test=1&db=0&gapi=0&od=0&analytics=0&picker=0&mode=device&browser=0&p=electron`)
  19. // Open the DevTools.
  20. mainWindow.webContents.openDevTools()
  21. // Emitted when the window is closed.
  22. mainWindow.on('closed', function()
  23. {
  24. // Dereference the window object, usually you would store windows
  25. // in an array if your app supports multi windows, this is the time
  26. // when you should delete the corresponding element.
  27. mainWindow = null
  28. })
  29. }
  30. // This method will be called when Electron has finished
  31. // initialization and is ready to create browser windows.
  32. // Some APIs can only be used after this event occurs.
  33. app.on('ready', createWindow)
  34. // Quit when all windows are closed.
  35. app.on('window-all-closed', function()
  36. {
  37. // On OS X it is common for applications and their menu bar
  38. // to stay active until the user quits explicitly with Cmd + Q
  39. if (process.platform !== 'darwin')
  40. {
  41. app.quit()
  42. }
  43. })
  44. app.on('activate', function()
  45. {
  46. // On OS X it's common to re-create a window in the app when the
  47. // dock icon is clicked and there are no other windows open.
  48. if (mainWindow === null)
  49. {
  50. createWindow()
  51. }
  52. })
  53. // In this file you can include the rest of your app's specific main process
  54. // code. You can also put them in separate files and require them here.