electron.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. const electron = require('electron');
  2. const { app, crashReporter } = require('electron')
  3. onsole.log(app.getPath('crashDumps'))
  4. crashReporter.start({ submitURL: '', uploadToServer: false })
  5. // Module to control application life.
  6. //const app = electron.app;
  7. // Module to create native browser window.
  8. const BrowserWindow = electron.BrowserWindow;
  9. const path = require('path');
  10. const url = require('url');
  11. const isDev = require('electron-is-dev');
  12. // Keep a global reference of the window object, if you don't, the window will
  13. // be closed automatically when the JavaScript object is garbage collected.
  14. let mainWindow;
  15. function createWindow() {
  16. // Create the browser window.
  17. mainWindow = new BrowserWindow({width: 1280, height: 800});
  18. // and load the index.html of the app.
  19. mainWindow.loadURL(isDev ? 'http://localhost:3000' : `file://${path.join(__dirname, '../build/index.html')}`);
  20. // Open the DevTools.
  21. mainWindow.menuBarVisible=false;
  22. // Emitted when the window is closed.
  23. mainWindow.on('closed', function () {
  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. // On OS X it is common for applications and their menu bar
  37. // to stay active until the user quits explicitly with Cmd + Q
  38. if (process.platform !== 'darwin') {
  39. app.quit()
  40. }
  41. });
  42. app.on('activate', function () {
  43. // On OS X it's common to re-create a window in the app when the
  44. // dock icon is clicked and there are no other windows open.
  45. if (mainWindow === null) {
  46. createWindow()
  47. }
  48. });
  49. // In this file you can include the rest of your app's specific main process
  50. // code. You can also put them in separate files and require them here.