diff --git a/default_app/main.js b/default_app/main.js index 332ff4bf25ab..4fd01f28e025 100644 --- a/default_app/main.js +++ b/default_app/main.js @@ -86,6 +86,9 @@ app.once('ready', () => { { role: 'reload' }, + { + role: 'forcereload' + }, { role: 'toggledevtools' }, diff --git a/docs/api/menu.md b/docs/api/menu.md index 64ab3afafbf1..b9bdc3606481 100644 --- a/docs/api/menu.md +++ b/docs/api/menu.md @@ -139,6 +139,9 @@ const template = [ { role: 'reload' }, + { + role: 'forcereload' + }, { role: 'toggledevtools' }, diff --git a/lib/browser/api/menu-item-roles.js b/lib/browser/api/menu-item-roles.js index 7777926cd46c..8a78670267ae 100644 --- a/lib/browser/api/menu-item-roles.js +++ b/lib/browser/api/menu-item-roles.js @@ -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) => {