1const {getCurrentWindow, globalShortcut} = require('electron').remote;
2
3var reload = ()=>{
4 getCurrentWindow().reload()
5}
6
7globalShortcut.register('F5', reload);
8globalShortcut.register('CommandOrControl+R', reload);
9// here is the fix bug #3778, if you know alternative ways, please write them
10window.addEventListener('beforeunload', ()=>{
11 globalShortcut.unregister('F5', reload);
12 globalShortcut.unregister('CommandOrControl+R', reload);
13})
1/*
2To use this code, you need to install the npm package 'electron-reload'
3executing this command:
4npm install electron-reload
5*/
6
7const path = require('path')
8
9require('electron-reload')(__dirname, {
10 electron: path.join(__dirname, 'node_modules', '.bin', 'electron'),
11 hardResetMethod: 'exit'
12});