main.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. // Modules to control application life and create native browser window
  2. const {app,Menu, BrowserWindow} = require('electron')
  3. const path = require('path')
  4. function createWindow() {
  5. // Create the browser window.
  6. const mainWindow = new BrowserWindow({
  7. width: 1920,
  8. height: 1080,
  9. minWidth:1000,//窗口的最小宽度,单位: 像素值,
  10. minHeight:800,//窗口的最小高度,单位: 像素值,
  11. show:false,
  12. webPreferences: {
  13. preload: path.join(__dirname, 'preload.js')
  14. }
  15. })
  16. // 隐藏菜单栏
  17. Menu.setApplicationMenu(null)
  18. // and load the index.html of the app.
  19. // mainWindow.loadURL('http://192.168.0.12:8000/')
  20. // mainWindow.loadURL('http://127.0.0.1:8080/')
  21. mainWindow.loadURL('http://localhost:8000/gen/a')
  22. // mainWindow.loadFile('jsoneditor.html')
  23. // Open the DevTools.
  24. // mainWindow.webContents.openDevTools()
  25. mainWindow.maximize()
  26. mainWindow.show()
  27. }
  28. // This method will be called when Electron has finished
  29. // initialization and is ready to create browser windows.
  30. // Some APIs can only be used after this event occurs.
  31. app.whenReady().then(() => {
  32. createWindow()
  33. app.on('activate', function () {
  34. // On macOS it's common to re-create a window in the app when the
  35. // dock icon is clicked and there are no other windows open.
  36. if (BrowserWindow.getAllWindows().length === 0) createWindow()
  37. })
  38. })
  39. // Quit when all windows are closed.
  40. app.on('window-all-closed', function () {
  41. // On macOS it is common for applications and their menu bar
  42. // to stay active until the user quits explicitly with Cmd + Q
  43. if (process.platform !== 'darwin') app.quit()
  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.