main.js 839 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. import { app, BrowserWindow } from 'electron'
  2. import path from 'path'
  3. import { fileURLToPath } from 'url'
  4. const __filename = fileURLToPath(import.meta.url)
  5. const __dirname = path.dirname(__filename)
  6. const isDev = process.env.NODE_ENV === 'development'
  7. function createWindow() {
  8. const win = new BrowserWindow({
  9. width: 1200,
  10. height: 800,
  11. webPreferences: {
  12. nodeIntegration: true,
  13. contextIsolation: false
  14. }
  15. })
  16. if (isDev) {
  17. win.loadURL('http://localhost:8003')
  18. } else {
  19. win.loadFile(path.join(__dirname, '../dist/index.html'))
  20. }
  21. }
  22. app.whenReady().then(() => {
  23. createWindow()
  24. app.on('activate', () => {
  25. if (BrowserWindow.getAllWindows().length === 0) {
  26. createWindow()
  27. }
  28. })
  29. })
  30. app.on('window-all-closed', () => {
  31. if (process.platform !== 'darwin') {
  32. app.quit()
  33. }
  34. })