context-menu.js 1019 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const { Menu, MenuItem, app } = require('electron');
  2. const config = require('../../config');
  3. const func = require('./function/menu');
  4. const menu = new Menu();
  5. menu.append(new MenuItem({
  6. label: 'Nouveau',
  7. click: func.new
  8. }));
  9. menu.append(new MenuItem({
  10. label: 'Importer',
  11. click: func.import
  12. }));
  13. menu.append(new MenuItem({type: 'separator'}));
  14. menu.append(new MenuItem({
  15. label: 'Exporter en markdown',
  16. type: 'checkbox',
  17. checked: exportToMd,
  18. click: () => {
  19. exportToMd = !exportToMd;
  20. }
  21. }));
  22. menu.append(new MenuItem({
  23. label: 'Afficher chargement',
  24. type: 'checkbox',
  25. checked: false,
  26. click: () => {
  27. mainWindow.webContents.send('app-loader');
  28. }
  29. }));
  30. menu.append(new MenuItem({type: 'separator'}));
  31. menu.append(new MenuItem({
  32. label: 'Outils Developpeur',
  33. click: func.devTool
  34. }))
  35. app.on('browser-window-created', (event, win) => {
  36. win.webContents.on('context-menu', (evt, params) => {
  37. menu.popup(win, params.x, params.y);
  38. });
  39. });