application-menu.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. const {Menu, shell} = require('electron')
  2. const demo = require('./function/demo-application-menu');
  3. let template = [
  4. {
  5. label: 'Fichier',
  6. submenu: [
  7. {
  8. label: 'Nouveau',
  9. accelerator: 'CmdOrCtrl+N',
  10. click: () => {
  11. mainWindow.webContents.send('new-note');
  12. }
  13. },
  14. {
  15. label: 'Importer',
  16. click: () => {
  17. console.log('Reset');
  18. }
  19. },
  20. {
  21. type: 'separator'
  22. },
  23. {
  24. label: 'Reset',
  25. click: () => {
  26. mainWindow.webContents.send('reset-app');
  27. }
  28. }
  29. ]
  30. },
  31. {
  32. label: 'Demo',
  33. submenu: [
  34. {
  35. label: 'Test',
  36. click: () => {
  37. console.log('Reset');
  38. }
  39. }
  40. ]
  41. },
  42. {
  43. label: 'Fenêtre',
  44. submenu: [
  45. {
  46. label: 'Pleine écran',
  47. accelerator: (() => {
  48. if (process.platform === 'darwin') {
  49. return 'Ctrl+Command+F'
  50. } else {
  51. return 'F11'
  52. }
  53. })(),
  54. click: (item, focusedWindow) => {
  55. if (focusedWindow) {
  56. focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
  57. }
  58. }
  59. },
  60. {
  61. label: 'Minimiser',
  62. accelerator: 'CmdOrCtrl+M',
  63. role: 'minimize'
  64. },
  65. {
  66. label: 'Fermer',
  67. accelerator: 'CmdOrCtrl+W',
  68. role: 'close'
  69. },
  70. {
  71. type: 'separator'
  72. },
  73. {
  74. label: 'Outils Developpeur',
  75. accelerator: (() => {
  76. if (process.platform === 'darwin') {
  77. return 'Alt+Command+I'
  78. } else {
  79. return 'Ctrl+Shift+I'
  80. }
  81. })(),
  82. click: (item, focusedWindow) => {
  83. if (focusedWindow) {
  84. focusedWindow.toggleDevTools()
  85. }
  86. }
  87. }
  88. ]
  89. },
  90. {
  91. label: 'À propos',
  92. submenu: [
  93. {
  94. label: 'Electron',
  95. click: () => {
  96. shell.openExternal('https://www.electronjs.org');
  97. }
  98. },
  99. {
  100. label: 'Electronotes',
  101. click: () => {
  102. shell.openExternal('https://gitlab.univ-artois.fr/arthur_brandao/conf-electron');
  103. }
  104. }
  105. ]
  106. }
  107. ];
  108. const menu = Menu.buildFromTemplate(template);
  109. Menu.setApplicationMenu(menu);