Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. const electron = require('electron');
  2. const path = require('path');
  3. const url = require('url');
  4. const { app, BrowserWindow, Menu } = electron;
  5. require('electron-reload')(__dirname, {
  6. electron: path.join(__dirname, 'node_modules', '.bin', 'electron')
  7. });
  8. process.env['ELECTRON_DISABLE_SECURITY_WARNINGS'] = 'true';
  9.  
  10. let mainWindow, lab01;
  11.  
  12. // Do this when our app is ready
  13. app.on('ready', () => {
  14. mainWindowLoad();
  15. const menu = Menu.buildFromTemplate(mainMenuTemplate);
  16. Menu.setApplicationMenu(menu);
  17. });
  18.  
  19. // Create lab01 window
  20. const lab01window = () => {
  21. lab01 = new BrowserWindow({
  22. webPreferences: {
  23. nodeIntegration: false
  24. },
  25. title: 'Lab 01'
  26. });
  27.  
  28. lab01.loadURL(`file://${__dirname}/lab01.html`);
  29. };
  30.  
  31. const mainWindowLoad = () => {
  32. mainWindow = new BrowserWindow({
  33. webPreferences: {
  34. nodeIntegration: false
  35. }
  36. });
  37. //load index.html file
  38. mainWindow.loadURL(`file://${__dirname}/index.html`);
  39. };
  40.  
  41. // Template for our application's menu
  42. const mainMenuTemplate = [
  43. {
  44. label: 'Devtool',
  45. accelerator: 'Ctrl+D',
  46. click() {
  47. mainWindow.webContents.openDevTools();
  48. }
  49. },
  50. {
  51. label: 'Reload',
  52. accelerator: 'Ctrl+R',
  53. click() {
  54. mainWindow.reload();
  55. }
  56. },
  57. {
  58. label: 'Lab 1',
  59. click() {
  60. lab01window();
  61. }
  62. }
  63. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement