| 
									
										
										
										
											2020-07-13 09:58:49 -07:00
										 |  |  | import { Menu } from 'electron/main'; | 
					
						
							|  |  |  | import { shell } from 'electron/common'; | 
					
						
							| 
									
										
										
										
											2019-01-10 20:54:34 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-06-22 20:32:45 -07:00
										 |  |  | const v8Util = process._linkedBinding('electron_common_v8_util'); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  | const isMac = process.platform === 'darwin'; | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-12 06:22:33 -08:00
										 |  |  | export const setDefaultApplicationMenu = () => { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   if (v8Util.getHiddenValue<boolean>(global, 'applicationMenuSet')) return; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-02-12 06:22:33 -08:00
										 |  |  |   const helpMenu: Electron.MenuItemConstructorOptions = { | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  |     role: 'help', | 
					
						
							|  |  |  |     submenu: [ | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         label: 'Learn More', | 
					
						
							| 
									
										
										
										
											2019-05-03 13:53:45 -07:00
										 |  |  |         click: async () => { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |           await shell.openExternal('https://electronjs.org'); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         label: 'Documentation', | 
					
						
							| 
									
										
										
										
											2019-05-03 13:53:45 -07:00
										 |  |  |         click: async () => { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |           const version = process.versions.electron; | 
					
						
							|  |  |  |           await shell.openExternal(`https://github.com/electron/electron/tree/v${version}/docs#readme`); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         label: 'Community Discussions', | 
					
						
							| 
									
										
										
										
											2019-05-03 13:53:45 -07:00
										 |  |  |         click: async () => { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |           await shell.openExternal('https://discuss.atom.io/c/electron'); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  |       }, | 
					
						
							|  |  |  |       { | 
					
						
							|  |  |  |         label: 'Search Issues', | 
					
						
							| 
									
										
										
										
											2019-05-03 13:53:45 -07:00
										 |  |  |         click: async () => { | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |           await shell.openExternal('https://github.com/electron/electron/issues'); | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     ] | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   }; | 
					
						
							| 
									
										
										
										
											2018-09-21 15:24:42 +10:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   const macAppMenu: Electron.MenuItemConstructorOptions = { role: 'appMenu' }; | 
					
						
							| 
									
										
										
										
											2019-02-12 06:22:33 -08:00
										 |  |  |   const template: Electron.MenuItemConstructorOptions[] = [ | 
					
						
							|  |  |  |     ...(isMac ? [macAppMenu] : []), | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  |     { role: 'fileMenu' }, | 
					
						
							|  |  |  |     { role: 'editMenu' }, | 
					
						
							|  |  |  |     { role: 'viewMenu' }, | 
					
						
							|  |  |  |     { role: 'windowMenu' }, | 
					
						
							|  |  |  |     helpMenu | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   ]; | 
					
						
							| 
									
										
										
										
											2019-01-10 14:32:03 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2020-03-20 13:28:31 -07:00
										 |  |  |   const menu = Menu.buildFromTemplate(template); | 
					
						
							|  |  |  |   Menu.setApplicationMenu(menu); | 
					
						
							|  |  |  | }; |