10.《Electron 跨平台开发实战》- chapter10-menubar
时间:2020-06-18 20:11:56
收藏:0
阅读:56
项目代码
https://github.com/electron-in-action/clipmaster-9000/tree/completed-example
代码解析
electron9.x 代码更新
从源码下载的使用目前最新的版本 electron9.x、menubar 9.x ,
无法运行,原因是
- 无法识别Menubar类
- 得显式的让browserWindow集成node环境
需要做如下修改:
- main.js
- 旧版本的代码
const Menubar = require(‘menubar‘);
const { globalShortcut, Menu } = require(‘electron‘);
const menubar = Menubar({
preloadWindow: true,
index: `file://${__dirname}/index.html`,
});
- electron9.x版本 修改为
const { menubar } = require(‘menubar‘);
const { globalShortcut, Menu } = require(‘electron‘);
const mb = menubar({
preloadWindow: true,
browserWindow: {
webPreferences: {
nodeIntegration: true
}
},
index: `file://${__dirname}/index.html`,
});
原文:https://www.cnblogs.com/easy5weikai/p/13159423.html
评论(0)