main.js 564 B

123456789101112131415161718192021222324252627282930
  1. const { app, BrowserWindow } = require('electron/main')
  2. const path = require('node:path')
  3. function createWindow () {
  4. const win = new BrowserWindow({
  5. width: 800,
  6. height: 600,
  7. webPreferences: {
  8. preload: path.join(__dirname, 'preload.js')
  9. }
  10. })
  11. win.loadFile('index.html')
  12. }
  13. app.whenReady().then(() => {
  14. createWindow()
  15. app.on('activate', () => {
  16. if (BrowserWindow.getAllWindows().length === 0) {
  17. createWindow()
  18. }
  19. })
  20. })
  21. app.on('window-all-closed', () => {
  22. if (process.platform !== 'darwin') {
  23. app.quit()
  24. }
  25. })