main.js 958 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. const electron = require( 'electron' );
  2. const app = electron.app;
  3. const BrowserWindow = electron.BrowserWindow;
  4. const path = require( 'path' );
  5. const url = require( 'url' );
  6. // Keep a global reference of the window object, if you don't, the window will
  7. // be closed automatically when the JavaScript object is garbage collected.
  8. let mainWindow;
  9. function createWindow() {
  10. mainWindow = new BrowserWindow( { webPreferences: {
  11. nodeIntegration: false
  12. } } );
  13. mainWindow.maximize();
  14. mainWindow.setMenu( null );
  15. mainWindow.loadURL( url.format( {
  16. pathname: path.join( __dirname, 'index.html' ),
  17. protocol: 'file:',
  18. slashes: true
  19. } ) );
  20. mainWindow.on( 'closed', function () {
  21. mainWindow = null;
  22. } );
  23. }
  24. app.on( 'ready', createWindow );
  25. app.on( 'window-all-closed', function () {
  26. if ( process.platform !== 'darwin' ) {
  27. app.quit();
  28. }
  29. } );
  30. app.on( 'activate', function () {
  31. if ( mainWindow === null ) {
  32. createWindow();
  33. }
  34. } );