|
@@ -1,127 +1,110 @@
|
|
|
-const {BrowserWindow, Menu, app, shell, dialog} = require('electron')
|
|
|
+const {Menu, shell} = require('electron')
|
|
|
+const demo = require('./function/demo-application-menu');
|
|
|
|
|
|
-let template = [{
|
|
|
- label: 'Edit',
|
|
|
- submenu: [{
|
|
|
- label: 'Lol',
|
|
|
- accelerator: 'CmdOrCtrl+Z',
|
|
|
- role: 'undo'
|
|
|
- }, {
|
|
|
- label: 'Redo',
|
|
|
- accelerator: 'Shift+CmdOrCtrl+Z',
|
|
|
- role: 'redo'
|
|
|
- }, {
|
|
|
- type: 'separator'
|
|
|
- }, {
|
|
|
- label: 'Cut',
|
|
|
- accelerator: 'CmdOrCtrl+X',
|
|
|
- role: 'cut'
|
|
|
- }, {
|
|
|
- label: 'Copy',
|
|
|
- accelerator: 'CmdOrCtrl+C',
|
|
|
- role: 'copy'
|
|
|
- }, {
|
|
|
- label: 'Paste',
|
|
|
- accelerator: 'CmdOrCtrl+V',
|
|
|
- role: 'paste'
|
|
|
- }, {
|
|
|
- label: 'Select All',
|
|
|
- accelerator: 'CmdOrCtrl+A',
|
|
|
- role: 'selectall'
|
|
|
- }]
|
|
|
-}, {
|
|
|
- label: 'View',
|
|
|
- submenu: [{
|
|
|
- label: 'Reload',
|
|
|
- accelerator: 'CmdOrCtrl+R',
|
|
|
- click: (item, focusedWindow) => {
|
|
|
- if (focusedWindow) {
|
|
|
- // on reload, start fresh and close any old
|
|
|
- // open secondary windows
|
|
|
- if (focusedWindow.id === 1) {
|
|
|
- BrowserWindow.getAllWindows().forEach(win => {
|
|
|
- if (win.id > 1) win.close()
|
|
|
- })
|
|
|
+let template = [
|
|
|
+ {
|
|
|
+ label: 'Fichier',
|
|
|
+ submenu: [
|
|
|
+ {
|
|
|
+ label: 'Nouveau',
|
|
|
+ click: () => {
|
|
|
+ console.log('Reset');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Importer',
|
|
|
+ click: () => {
|
|
|
+ console.log('Reset');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'separator'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Reset',
|
|
|
+ click: () => {
|
|
|
+ console.log('Reset');
|
|
|
}
|
|
|
- focusedWindow.reload()
|
|
|
- }
|
|
|
- }
|
|
|
- }, {
|
|
|
- label: 'Toggle Full Screen',
|
|
|
- accelerator: (() => {
|
|
|
- if (process.platform === 'darwin') {
|
|
|
- return 'Ctrl+Command+F'
|
|
|
- } else {
|
|
|
- return 'F11'
|
|
|
- }
|
|
|
- })(),
|
|
|
- click: (item, focusedWindow) => {
|
|
|
- if (focusedWindow) {
|
|
|
- focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
|
|
|
}
|
|
|
- }
|
|
|
- }, {
|
|
|
- label: 'Toggle Developer Tools',
|
|
|
- accelerator: (() => {
|
|
|
- if (process.platform === 'darwin') {
|
|
|
- return 'Alt+Command+I'
|
|
|
- } else {
|
|
|
- return 'Ctrl+Shift+I'
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Demo',
|
|
|
+ submenu: [
|
|
|
+ {
|
|
|
+ label: 'Test',
|
|
|
+ click: () => {
|
|
|
+ console.log('Reset');
|
|
|
+ }
|
|
|
}
|
|
|
- })(),
|
|
|
- click: (item, focusedWindow) => {
|
|
|
- if (focusedWindow) {
|
|
|
- focusedWindow.toggleDevTools()
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Fenêtre',
|
|
|
+ submenu: [
|
|
|
+ {
|
|
|
+ label: 'Pleine écran',
|
|
|
+ accelerator: (() => {
|
|
|
+ if (process.platform === 'darwin') {
|
|
|
+ return 'Ctrl+Command+F'
|
|
|
+ } else {
|
|
|
+ return 'F11'
|
|
|
+ }
|
|
|
+ })(),
|
|
|
+ click: (item, focusedWindow) => {
|
|
|
+ if (focusedWindow) {
|
|
|
+ focusedWindow.setFullScreen(!focusedWindow.isFullScreen())
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Minimiser',
|
|
|
+ accelerator: 'CmdOrCtrl+M',
|
|
|
+ role: 'minimize'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Fermer',
|
|
|
+ accelerator: 'CmdOrCtrl+W',
|
|
|
+ role: 'close'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: 'separator'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Outils Developpeur',
|
|
|
+ accelerator: (() => {
|
|
|
+ if (process.platform === 'darwin') {
|
|
|
+ return 'Alt+Command+I'
|
|
|
+ } else {
|
|
|
+ return 'Ctrl+Shift+I'
|
|
|
+ }
|
|
|
+ })(),
|
|
|
+ click: (item, focusedWindow) => {
|
|
|
+ if (focusedWindow) {
|
|
|
+ focusedWindow.toggleDevTools()
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }, {
|
|
|
- type: 'separator'
|
|
|
- }, {
|
|
|
- label: 'App Menu Demo',
|
|
|
- click: function (item, focusedWindow) {
|
|
|
- if (focusedWindow) {
|
|
|
- const options = {
|
|
|
- type: 'info',
|
|
|
- title: 'Application Menu Demo',
|
|
|
- buttons: ['Ok'],
|
|
|
- message: 'This demo is for the Menu section, showing how to create a clickable menu item in the application menu.'
|
|
|
+ ]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'À propos',
|
|
|
+ submenu: [
|
|
|
+ {
|
|
|
+ label: 'Electron',
|
|
|
+ click: () => {
|
|
|
+ shell.openExternal('https://www.electronjs.org');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ label: 'Electronotes',
|
|
|
+ click: () => {
|
|
|
+ shell.openExternal('https://gitlab.univ-artois.fr/arthur_brandao/conf-electron');
|
|
|
}
|
|
|
- dialog.showMessageBox(focusedWindow, options, function () {})
|
|
|
}
|
|
|
- }
|
|
|
- }]
|
|
|
-}, {
|
|
|
- label: 'Window',
|
|
|
- role: 'window',
|
|
|
- submenu: [{
|
|
|
- label: 'Minimize',
|
|
|
- accelerator: 'CmdOrCtrl+M',
|
|
|
- role: 'minimize'
|
|
|
- }, {
|
|
|
- label: 'Close',
|
|
|
- accelerator: 'CmdOrCtrl+W',
|
|
|
- role: 'close'
|
|
|
- }, {
|
|
|
- type: 'separator'
|
|
|
- }, {
|
|
|
- label: 'Reopen Window',
|
|
|
- accelerator: 'CmdOrCtrl+Shift+T',
|
|
|
- enabled: false,
|
|
|
- key: 'reopenMenuItem',
|
|
|
- click: () => {
|
|
|
- app.emit('activate')
|
|
|
- }
|
|
|
- }]
|
|
|
-}, {
|
|
|
- label: 'Help',
|
|
|
- role: 'help',
|
|
|
- submenu: [{
|
|
|
- label: 'Learn More',
|
|
|
- click: () => {
|
|
|
- shell.openExternal('http://electron.atom.io')
|
|
|
- }
|
|
|
- }]
|
|
|
-}];
|
|
|
+ ]
|
|
|
+ }
|
|
|
+];
|
|
|
|
|
|
const menu = Menu.buildFromTemplate(template);
|
|
|
Menu.setApplicationMenu(menu);
|