main.js 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. const { app, BrowserWindow } = require('electron');
  2. const path = require('path');
  3. function createWindow () {
  4. const win = new BrowserWindow({
  5. width: 2000,
  6. height: 1800,
  7. minWidth: 400,
  8. minHeight: 500,
  9. center: true,
  10. webPreferences: {
  11. nodeIntegration: true,
  12. contextIsolation: false,
  13. enableRemoteModule: true
  14. }
  15. });
  16. // 判断是否为开发环境
  17. // const isDev = process.env.NODE_ENV === 'development' || !app.isPackaged;
  18. //
  19. // if (isDev) {
  20. // 开发环境:加载 Vue CLI 开发服务器
  21. win.loadURL('http://localhost:8080');
  22. // 开发环境下打开开发者工具
  23. // win.webContents.openDevTools();
  24. // } else {
  25. // // 生产环境:加载构建后的文件
  26. // win.loadFile(path.join(__dirname, 'dist', 'index.html'));
  27. // }
  28. }
  29. app.whenReady().then(createWindow);
  30. app.on('activate', () => {
  31. if (BrowserWindow.getAllWindows().length === 0) {
  32. createWindow();
  33. }
  34. });
  35. app.on('window-all-closed', () => {
  36. if (process.platform !== 'darwin') {
  37. app.quit();
  38. }
  39. });