main.js 731 B

1234567891011121314151617181920212223242526272829303132
  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. // 关键:把应用菜单设为空
  13. Menu.setApplicationMenu(null);
  14. // 加载 Taro 编译后的 H5 页面
  15. // win.loadFile('./dist/index.html');
  16. win.loadFile(path.join(__dirname, './dist/h5/index.html'));
  17. }
  18. app.whenReady().then(createWindow);
  19. app.on('window-all-closed', () => {
  20. if (process.platform !== 'darwin') {
  21. app.quit();
  22. }
  23. });
  24. app.on('activate', () => {
  25. if (BrowserWindow.getAllWindows().length === 0) {
  26. createWindow();
  27. }
  28. });