main.js 660 B

12345678910111213141516171819202122232425262728293031
  1. const { app, BrowserWindow } = require('electron');
  2. const path = require('path');
  3. function createWindow() {
  4. const win = new BrowserWindow({
  5. width: 800,
  6. height: 600,
  7. webPreferences: {
  8. nodeIntegration: true,
  9. contextIsolation: false,
  10. },
  11. });
  12. // 加载 Taro 编译后的 H5 页面
  13. // win.loadFile('./dist/index.html');
  14. win.loadFile(path.join(__dirname, './dist/h5/index.html'));
  15. }
  16. app.whenReady().then(createWindow);
  17. app.on('window-all-closed', () => {
  18. if (process.platform !== 'darwin') {
  19. app.quit();
  20. }
  21. });
  22. app.on('activate', () => {
  23. if (BrowserWindow.getAllWindows().length === 0) {
  24. createWindow();
  25. }
  26. });