default_app.js 814 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. 'use strict'
  2. const { app, BrowserWindow } = require('electron')
  3. const path = require('path')
  4. let mainWindow = null
  5. // Quit when all windows are closed.
  6. app.on('window-all-closed', () => {
  7. app.quit()
  8. })
  9. exports.load = async (appUrl) => {
  10. await app.whenReady()
  11. const options = {
  12. width: 900,
  13. height: 600,
  14. autoHideMenuBar: true,
  15. backgroundColor: '#FFFFFF',
  16. webPreferences: {
  17. contextIsolation: true,
  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. }