test
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.

main.js 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Modules to control application life and create native browser window
  2. const {app, BrowserWindow} = require('electron')
  3. const path = require('path')
  4. // Keep a global reference of the window object, if you don't, the window will
  5. // be closed automatically when the JavaScript object is garbage collected.
  6. let mainWindow
  7. function createWindow () {
  8. // Create the browser window.
  9. mainWindow = new BrowserWindow({
  10. width: 1300,
  11. height: 600,
  12. webPreferences: {
  13. preload: path.join(__dirname, 'preload.js')
  14. }
  15. });
  16. // and load the index.html of the app.
  17. // mainWindow.loadFile('index.html')
  18. mainWindow.loadURL('http://192.168.20.245:9527/');
  19. // Open the DevTools.
  20. // mainWindow.webContents.openDevTools()
  21. // Emitted when the window is closed.
  22. mainWindow.on('closed', function () {
  23. // Dereference the window object, usually you would store windows
  24. // in an array if your app supports multi windows, this is the time
  25. // when you should delete the corresponding element.
  26. mainWindow = null
  27. });
  28. mainWindow.webContents.openDevTools()
  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 macOS 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') app.quit()
  39. })
  40. app.on('activate', function () {
  41. // On macOS it's common to re-create a window in the app when the
  42. // dock icon is clicked and there are no other windows open.
  43. if (mainWindow === null) createWindow()
  44. })
  45. // In this file you can include the rest of your app's specific main process
  46. // code. You can also put them in separate files and require them here.