main.js 673 B

1234567891011121314151617181920212223242526272829303132
  1. const { app, BrowserWindow, shell } = require('electron/main')
  2. let mainWindow = null
  3. function createWindow () {
  4. const windowOptions = {
  5. width: 600,
  6. height: 400,
  7. title: 'Get version information',
  8. webPreferences: {
  9. contextIsolation: false,
  10. nodeIntegration: true
  11. }
  12. }
  13. mainWindow = new BrowserWindow(windowOptions)
  14. mainWindow.loadFile('index.html')
  15. mainWindow.on('closed', () => {
  16. mainWindow = null
  17. })
  18. // Open external links in the default browser
  19. mainWindow.webContents.on('will-navigate', (event, url) => {
  20. event.preventDefault()
  21. shell.openExternal(url)
  22. })
  23. }
  24. app.whenReady().then(() => {
  25. createWindow()
  26. })