default_app.js 830 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. const { app, BrowserWindow } = require('electron')
  2. const path = require('path')
  3. let mainWindow = null
  4. // Quit when all windows are closed.
  5. app.on('window-all-closed', () => {
  6. app.quit()
  7. })
  8. exports.load = async (appUrl) => {
  9. await app.whenReady()
  10. const options = {
  11. width: 900,
  12. height: 600,
  13. autoHideMenuBar: true,
  14. backgroundColor: '#FFFFFF',
  15. webPreferences: {
  16. contextIsolation: true,
  17. nodeIntegration: false,
  18. preload: path.resolve(__dirname, 'renderer.js'),
  19. webviewTag: false
  20. },
  21. useContentSize: true,
  22. show: false
  23. }
  24. if (process.platform === 'linux') {
  25. options.icon = path.join(__dirname, 'icon.png')
  26. }
  27. mainWindow = new BrowserWindow(options)
  28. mainWindow.on('ready-to-show', () => mainWindow.show())
  29. mainWindow.loadURL(appUrl)
  30. mainWindow.focus()
  31. }