|
| 1 | +import { remote } from 'electron'; |
| 2 | +import webview from '../webview'; |
| 3 | +import sidebar from '../sidebar'; |
| 4 | +import tray from '../tray'; |
| 5 | + |
| 6 | +const isMac = process.platform === 'darwin'; |
| 7 | +const certificate = remote.require('./background').certificate; |
| 8 | + |
| 9 | +const viewTemplate = [ |
| 10 | + { |
| 11 | + label: 'Original Zoom', |
| 12 | + accelerator: 'CommandOrControl+0', |
| 13 | + role: 'resetzoom' |
| 14 | + }, |
| 15 | + { |
| 16 | + label: 'Zoom In', |
| 17 | + accelerator: 'CommandOrControl+Plus', |
| 18 | + role: 'zoomin' |
| 19 | + }, |
| 20 | + { |
| 21 | + label: 'Zoom Out', |
| 22 | + accelerator: 'CommandOrControl+-', |
| 23 | + role: 'zoomout' |
| 24 | + }, |
| 25 | + { |
| 26 | + type: 'separator' |
| 27 | + }, |
| 28 | + { |
| 29 | + label: 'Current Server - Reload', |
| 30 | + accelerator: 'CommandOrControl+R', |
| 31 | + click: function () { |
| 32 | + const activeWebview = webview.getActive(); |
| 33 | + if (activeWebview) { |
| 34 | + activeWebview.reload(); |
| 35 | + } |
| 36 | + } |
| 37 | + }, |
| 38 | + { |
| 39 | + label: 'Current Server - Toggle DevTools', |
| 40 | + accelerator: isMac ? 'Command+Alt+I' : 'Ctrl+Shift+I', |
| 41 | + click: function () { |
| 42 | + const activeWebview = webview.getActive(); |
| 43 | + if (activeWebview) { |
| 44 | + activeWebview.openDevTools(); |
| 45 | + } |
| 46 | + } |
| 47 | + }, |
| 48 | + { |
| 49 | + type: 'separator' |
| 50 | + }, |
| 51 | + { |
| 52 | + label: 'Application - Reload', |
| 53 | + accelerator: 'CommandOrControl+Shift+R', |
| 54 | + click: function () { |
| 55 | + var mainWindow = remote.getCurrentWindow(); |
| 56 | + if (mainWindow.destroyTray) { |
| 57 | + mainWindow.destroyTray(); |
| 58 | + } |
| 59 | + mainWindow.reload(); |
| 60 | + } |
| 61 | + }, |
| 62 | + { |
| 63 | + label: 'Application - Toggle DevTools', |
| 64 | + click: function () { |
| 65 | + remote.getCurrentWindow().toggleDevTools(); |
| 66 | + } |
| 67 | + }, |
| 68 | + { |
| 69 | + type: 'separator', |
| 70 | + id: 'toggle' |
| 71 | + }, |
| 72 | + { |
| 73 | + label: 'Toggle Server List', |
| 74 | + click: function () { |
| 75 | + sidebar.toggle(); |
| 76 | + } |
| 77 | + }, |
| 78 | + { |
| 79 | + type: 'separator' |
| 80 | + }, |
| 81 | + { |
| 82 | + label: 'Clear', |
| 83 | + submenu: [ |
| 84 | + { |
| 85 | + label: 'Clear Trusted Certificates', |
| 86 | + click: function () { |
| 87 | + certificate.clear(); |
| 88 | + } |
| 89 | + } |
| 90 | + ] |
| 91 | + } |
| 92 | +]; |
| 93 | + |
| 94 | +if (isMac) { |
| 95 | + viewTemplate.push({ |
| 96 | + label: 'Toggle Tray Icon', |
| 97 | + click: function () { |
| 98 | + tray.toggle(); |
| 99 | + }, |
| 100 | + position: 'after=toggle' |
| 101 | + }); |
| 102 | +} else { |
| 103 | + viewTemplate.push({ |
| 104 | + label: 'Toggle Menu Bar', |
| 105 | + click: function () { |
| 106 | + const current = localStorage.getItem('autohideMenu') === 'true'; |
| 107 | + remote.getCurrentWindow().setAutoHideMenuBar(!current); |
| 108 | + localStorage.setItem('autohideMenu', JSON.stringify(!current)); |
| 109 | + }, |
| 110 | + position: 'after=toggle' |
| 111 | + }); |
| 112 | +} |
| 113 | + |
| 114 | +export default viewTemplate; |
0 commit comments