index.jsView |
---|
7 | 7 … | var windows = {} |
8 | 8 … | var quitting = false |
9 | 9 … | |
10 | 10 … | console.log('STARTING electron') |
11 | | - |
12 | 11 … | electron.app.on('ready', () => { |
13 | | - |
14 | | - var menu = defaultMenu(electron.app, electron.shell) |
15 | | - var view = menu.find(x => x.label === 'View') |
16 | | - view.submenu = [ |
17 | | - { role: 'reload' }, |
18 | | - { role: 'toggledevtools' }, |
19 | | - { type: 'separator' }, |
20 | | - { role: 'resetzoom' }, |
21 | | - { role: 'zoomin' }, |
22 | | - { role: 'zoomout' }, |
23 | | - { type: 'separator' }, |
24 | | - { role: 'togglefullscreen' } |
25 | | - ] |
26 | | - var win = menu.find(x => x.label === 'Window') |
27 | | - win.submenu = [ |
28 | | - { role: 'minimize' }, |
29 | | - { role: 'zoom' }, |
30 | | - { role: 'close', label: 'Close Window', accelerator: 'CmdOrCtrl+Shift+W' }, |
31 | | - { type: 'separator' }, |
32 | | - { |
33 | | - label: 'Close Tab', |
34 | | - accelerator: 'CmdOrCtrl+W', |
35 | | - click () { |
36 | | - windows.main.webContents.send('closeTab') |
37 | | - } |
38 | | - }, |
39 | | - { |
40 | | - label: 'Select Next Tab', |
41 | | - accelerator: 'CmdOrCtrl+Shift+]', |
42 | | - click () { |
43 | | - windows.main.webContents.send('nextTab') |
44 | | - } |
45 | | - }, |
46 | | - { |
47 | | - label: 'Select Previous Tab', |
48 | | - accelerator: 'CmdOrCtrl+Shift+[', |
49 | | - click () { |
50 | | - windows.main.webContents.send('previousTab') |
51 | | - } |
52 | | - }, |
53 | | - { type: 'separator' }, |
54 | | - { role: 'front' } |
55 | | - ] |
| 12 … | + startMenus() |
56 | 13 … | |
57 | | - Menu.setApplicationMenu(Menu.buildFromTemplate(menu)) |
58 | | - |
59 | 14 … | startBackgroundProcess() |
60 | | - |
61 | 15 … | |
62 | 16 … | electron.ipcMain.once('server-started', function (ev, config) { |
63 | 17 … | openMainWindow() |
64 | 18 … | }) |
158 | 112 … | |
159 | 113 … | window.loadURL('file://' + Path.join(__dirname, 'assets', 'base.html')) |
160 | 114 … | return window |
161 | 115 … | } |
| 116 … | + |
| 117 … | +function startMenus () { |
| 118 … | + var menu = defaultMenu(electron.app, electron.shell) |
| 119 … | + var view = menu.find(x => x.label === 'View') |
| 120 … | + view.submenu = [ |
| 121 … | + { role: 'reload' }, |
| 122 … | + { role: 'toggledevtools' }, |
| 123 … | + { type: 'separator' }, |
| 124 … | + { role: 'resetzoom' }, |
| 125 … | + { role: 'zoomin' }, |
| 126 … | + { role: 'zoomout' }, |
| 127 … | + { type: 'separator' }, |
| 128 … | + { role: 'togglefullscreen' } |
| 129 … | + ] |
| 130 … | + var win = menu.find(x => x.label === 'Window') |
| 131 … | + win.submenu = [ |
| 132 … | + { role: 'minimize' }, |
| 133 … | + { role: 'zoom' }, |
| 134 … | + { role: 'close', label: 'Close Window', accelerator: 'CmdOrCtrl+Shift+W' }, |
| 135 … | + { type: 'separator' }, |
| 136 … | + { |
| 137 … | + label: 'Close Tab', |
| 138 … | + accelerator: 'CmdOrCtrl+W', |
| 139 … | + click () { |
| 140 … | + windows.main.webContents.send('closeTab') |
| 141 … | + } |
| 142 … | + }, |
| 143 … | + { |
| 144 … | + label: 'Select Next Tab', |
| 145 … | + accelerator: 'CmdOrCtrl+Shift+]', |
| 146 … | + click () { |
| 147 … | + windows.main.webContents.send('nextTab') |
| 148 … | + } |
| 149 … | + }, |
| 150 … | + { |
| 151 … | + label: 'Select Previous Tab', |
| 152 … | + accelerator: 'CmdOrCtrl+Shift+[', |
| 153 … | + click () { |
| 154 … | + windows.main.webContents.send('previousTab') |
| 155 … | + } |
| 156 … | + }, |
| 157 … | + { type: 'separator' }, |
| 158 … | + { role: 'front' } |
| 159 … | + ] |
| 160 … | + |
| 161 … | + Menu.setApplicationMenu(Menu.buildFromTemplate(menu)) |
| 162 … | +} |