nativefier的应用程序,在任务栏图标中的右键菜单新增“刷新当前页面”的功能

2023-11-30 建站知识 浏览 手机预览
文章来源:http://www.imtr.cn/html/n271.html

在/resources/app/lib/main.js中搜索const contextMenu = electron_1.Menu.buildFromTemplate,在这个代码的上一句中新增BrowserWindow刷新模块:

const { Menu, clipboard, shell, BrowserWindow } = require('electron');


然后在这个方法里新增代码:

			{
				label: '刷新页面',
				click: () => {// 刷新当前窗口的页面
				    const currentWindow = BrowserWindow.getFocusedWindow();
					if (currentWindow) {
						const webContents = currentWindow.webContents;
						webContents.reload();
					}
				},
			},

这样就可以在应用程序图标上单击右键,刷新当前页面

原文地址:http://www.imtr.cn/html/n271.html
  • 如果你的问题还没有解决,可以点击页面右侧的“ ”,站长收到问题后会尽快回复解决方案到你的邮箱。
  • 创造始于问题,有了问题才会思考,有了思考,才有解决问题的方法,才有找到独立思路的可能。 —— 陶行知