📌  相关文章
📜  Electron WebContents 上下文菜单 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:17.485000             🧑  作者: Mango

代码示例1
var menu = new Menu();

//Basic Menu For Testing
menu.append(new MenuItem({ label: 'MenuItem1', click: function() { console.log("YES"); 
} }));
menu.append(new MenuItem({ type: 'separator' }));
menu.append(new MenuItem({ label: 'MenuItem2', type: 'checkbox', checked: true }));
app.on("web-contents-created", (...[/* event */, webContents]) => {

//Webview is being shown here as a window type
console.log(webContents.getType())
webContents.on("context-menu", (event, click) => {
  event.preventDefault();
  console.log(webContents.getType())
  menu.popup(webContents);
}, false);
});