main.js 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // Modules to control application life and create native browser window
  2. const {app, BrowserWindow, ipcMain, dialog } = require('electron')
  3. const path = require('path')
  4. const titleBarStyle = (process.platform === 'darwin') ? 'hiddenInset' : 'default';
  5. const frameWin = (process.platform === 'darwin') ? false : true;
  6. function createWindow () {
  7. // Create the browser window.
  8. const mainWindow = new BrowserWindow({
  9. titleBarStyle: titleBarStyle,
  10. autoHideMenuBar: true,
  11. vibrancy: 'dark',
  12. width: 640,
  13. height: 600,
  14. minWidth: 400,
  15. minHeight: 400,
  16. show: true,
  17. skipTaskbar: true,
  18. transparent: false,
  19. frame: frameWin,
  20. fullScreenable: true,
  21. resizable: true,
  22. backgroundColor: "black", //background,
  23. paintWhenInitiallyHidden: true,
  24. webPreferences: {
  25. preload: path.join(__dirname, 'preload.js'),
  26. // contextIsolation: false,
  27. // nodeIntegration: true,
  28. }
  29. })
  30. // and load the index.html of the app.
  31. mainWindow.loadFile('index.html')
  32. // Open the DevTools.
  33. // mainWindow.webContents.openDevTools()
  34. }
  35. // This method will be called when Electron has finished
  36. // initialization and is ready to create browser windows.
  37. // Some APIs can only be used after this event occurs.
  38. app.whenReady().then(() => {
  39. createWindow()
  40. ipcMain.handle('dialog', (event, method, params) => {
  41. return dialog[method](params);
  42. });
  43. app.on('activate', function () {
  44. // On macOS it's common to re-create a window in the app when the
  45. // dock icon is clicked and there are no other windows open.
  46. if (BrowserWindow.getAllWindows().length === 0) createWindow()
  47. })
  48. })
  49. // Quit when all windows are closed, except on macOS. There, it's common
  50. // for applications and their menu bar to stay active until the user quits
  51. // explicitly with Cmd + Q.
  52. app.on('window-all-closed', function () {
  53. if (process.platform !== 'darwin') app.quit()
  54. })
  55. // In this file you can include the rest of your app's specific main process
  56. // code. You can also put them in separate files and require them here.