Skip to content

Commit fb08f56

Browse files
committed
Add forcereload menu item role
1 parent 555347e commit fb08f56

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

default_app/main.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ app.once('ready', () => {
8686
{
8787
role: 'reload'
8888
},
89+
{
90+
role: 'forcereload'
91+
},
8992
{
9093
role: 'toggledevtools'
9194
},

docs/api/menu.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,9 @@ const template = [
139139
{
140140
role: 'reload'
141141
},
142+
{
143+
role: 'forcereload'
144+
},
142145
{
143146
role: 'toggledevtools'
144147
},

lib/browser/api/menu-item-roles.js

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@ const roles = {
2525
label: 'Delete',
2626
webContentsMethod: 'delete'
2727
},
28+
forcereload: {
29+
label: 'Force Reload',
30+
accelerator: 'Shift+CmdOrCtrl+R',
31+
nonNativeMacOSRole: true,
32+
windowMethod: (window) => {
33+
window.webContents.reloadIgnoringCache()
34+
}
35+
},
2836
front: {
2937
label: 'Bring All to Front'
3038
},
@@ -75,11 +83,13 @@ const roles = {
7583
reload: {
7684
label: 'Reload',
7785
accelerator: 'CmdOrCtrl+R',
86+
nonNativeMacOSRole: true,
7887
windowMethod: 'reload'
7988
},
8089
resetzoom: {
8190
label: 'Actual Size',
8291
accelerator: 'CommandOrControl+0',
92+
nonNativeMacOSRole: true,
8393
webContentsMethod: (webContents) => {
8494
webContents.setZoomLevel(0)
8595
}
@@ -101,6 +111,7 @@ const roles = {
101111
toggledevtools: {
102112
label: 'Toggle Developer Tools',
103113
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
114+
nonNativeMacOSRole: true,
104115
windowMethod: 'toggleDevTools'
105116
},
106117
togglefullscreen: {
@@ -127,6 +138,7 @@ const roles = {
127138
zoomin: {
128139
label: 'Zoom In',
129140
accelerator: 'CommandOrControl+Plus',
141+
nonNativeMacOSRole: true,
130142
webContentsMethod: (webContents) => {
131143
webContents.getZoomLevel((zoomLevel) => {
132144
webContents.setZoomLevel(zoomLevel + 0.5)
@@ -136,6 +148,7 @@ const roles = {
136148
zoomout: {
137149
label: 'Zoom Out',
138150
accelerator: 'CommandOrControl+-',
151+
nonNativeMacOSRole: true,
139152
webContentsMethod: (webContents) => {
140153
webContents.getZoomLevel((zoomLevel) => {
141154
webContents.setZoomLevel(zoomLevel - 0.5)
@@ -147,8 +160,8 @@ const roles = {
147160
const canExecuteRole = (role) => {
148161
if (!roles.hasOwnProperty(role)) return false
149162
if (process.platform !== 'darwin') return true
150-
// macOS handles all roles natively except the ones listed below
151-
return ['reload', 'resetzoom', 'toggledevtools', 'zoomin', 'zoomout'].includes(role)
163+
// macOS handles all roles natively except for a few
164+
return roles[role].nonNativeMacOSRole
152165
}
153166

154167
exports.getDefaultLabel = (role) => {

0 commit comments

Comments
 (0)