Add forcereload menu item role
This commit is contained in:
		
					parent
					
						
							
								555347e726
							
						
					
				
			
			
				commit
				
					
						fb08f56fc8
					
				
			
		
					 3 changed files with 21 additions and 2 deletions
				
			
		|  | @ -86,6 +86,9 @@ app.once('ready', () => { | |||
|         { | ||||
|           role: 'reload' | ||||
|         }, | ||||
|         { | ||||
|           role: 'forcereload' | ||||
|         }, | ||||
|         { | ||||
|           role: 'toggledevtools' | ||||
|         }, | ||||
|  |  | |||
|  | @ -139,6 +139,9 @@ const template = [ | |||
|       { | ||||
|         role: 'reload' | ||||
|       }, | ||||
|       { | ||||
|         role: 'forcereload' | ||||
|       }, | ||||
|       { | ||||
|         role: 'toggledevtools' | ||||
|       }, | ||||
|  |  | |||
|  | @ -25,6 +25,14 @@ const roles = { | |||
|     label: 'Delete', | ||||
|     webContentsMethod: 'delete' | ||||
|   }, | ||||
|   forcereload: { | ||||
|     label: 'Force Reload', | ||||
|     accelerator: 'Shift+CmdOrCtrl+R', | ||||
|     nonNativeMacOSRole: true, | ||||
|     windowMethod: (window) => { | ||||
|       window.webContents.reloadIgnoringCache() | ||||
|     } | ||||
|   }, | ||||
|   front: { | ||||
|     label: 'Bring All to Front' | ||||
|   }, | ||||
|  | @ -75,11 +83,13 @@ const roles = { | |||
|   reload: { | ||||
|     label: 'Reload', | ||||
|     accelerator: 'CmdOrCtrl+R', | ||||
|     nonNativeMacOSRole: true, | ||||
|     windowMethod: 'reload' | ||||
|   }, | ||||
|   resetzoom: { | ||||
|     label: 'Actual Size', | ||||
|     accelerator: 'CommandOrControl+0', | ||||
|     nonNativeMacOSRole: true, | ||||
|     webContentsMethod: (webContents) => { | ||||
|       webContents.setZoomLevel(0) | ||||
|     } | ||||
|  | @ -101,6 +111,7 @@ const roles = { | |||
|   toggledevtools: { | ||||
|     label: 'Toggle Developer Tools', | ||||
|     accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I', | ||||
|     nonNativeMacOSRole: true, | ||||
|     windowMethod: 'toggleDevTools' | ||||
|   }, | ||||
|   togglefullscreen: { | ||||
|  | @ -127,6 +138,7 @@ const roles = { | |||
|   zoomin: { | ||||
|     label: 'Zoom In', | ||||
|     accelerator: 'CommandOrControl+Plus', | ||||
|     nonNativeMacOSRole: true, | ||||
|     webContentsMethod: (webContents) => { | ||||
|       webContents.getZoomLevel((zoomLevel) => { | ||||
|         webContents.setZoomLevel(zoomLevel + 0.5) | ||||
|  | @ -136,6 +148,7 @@ const roles = { | |||
|   zoomout: { | ||||
|     label: 'Zoom Out', | ||||
|     accelerator: 'CommandOrControl+-', | ||||
|     nonNativeMacOSRole: true, | ||||
|     webContentsMethod: (webContents) => { | ||||
|       webContents.getZoomLevel((zoomLevel) => { | ||||
|         webContents.setZoomLevel(zoomLevel - 0.5) | ||||
|  | @ -147,8 +160,8 @@ const roles = { | |||
| const canExecuteRole = (role) => { | ||||
|   if (!roles.hasOwnProperty(role)) return false | ||||
|   if (process.platform !== 'darwin') return true | ||||
|   // macOS handles all roles natively except the ones listed below
 | ||||
|   return ['reload', 'resetzoom', 'toggledevtools', 'zoomin', 'zoomout'].includes(role) | ||||
|   // macOS handles all roles natively except for a few
 | ||||
|   return roles[role].nonNativeMacOSRole | ||||
| } | ||||
| 
 | ||||
| exports.getDefaultLabel = (role) => { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Kevin Sawicki
				Kevin Sawicki