You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.5 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
10 years ago
  1. // Modules to control application life and create native browser window
  2. const { app, BrowserWindow } = require('electron')
  3. const path = require('node:path')
  4. function createWindow () {
  5. // Create the browser window.
  6. const mainWindow = new BrowserWindow({
  7. width: 1600,
  8. height: 1000,
  9. icon: path.join(__dirname, 'icon.ico'),
  10. webPreferences: {
  11. preload: path.join(__dirname, 'preload.js'),
  12. webSecurity: false, // 允许跨域
  13. }
  14. })
  15. //隐藏菜单
  16. mainWindow.setMenu(null);
  17. // and load the index.html of the app.
  18. //mainWindow.loadFile('index.html')
  19. mainWindow.loadFile('./dist/index.html')
  20. // Open the DevTools.
  21. mainWindow.webContents.openDevTools()
  22. }
  23. // This method will be called when Electron has finished
  24. // initialization and is ready to create browser windows.
  25. // Some APIs can only be used after this event occurs.
  26. app.whenReady().then(() => {
  27. createWindow()
  28. app.on('activate', function () {
  29. // On macOS it's common to re-create a window in the app when the
  30. // dock icon is clicked and there are no other windows open.
  31. if (BrowserWindow.getAllWindows().length === 0) createWindow()
  32. })
  33. })
  34. // Quit when all windows are closed, except on macOS. There, it's common
  35. // for applications and their menu bar to stay active until the user quits
  36. // explicitly with Cmd + Q.
  37. app.on('window-all-closed', function () {
  38. if (process.platform !== 'darwin') app.quit()
  39. })
  40. // In this file you can include the rest of your app's specific main process
  41. // code. You can also put them in separate files and require them here.