隐藏菜单
const { app, Menu, session } = require('electron'); /*隐藏electron的菜单栏*/ Menu.setApplicationMenu(null);设置菜单
const { app, Menu, session } = require('electron');// 创建 menu function createMenu() { let menuStructure = [ { label: '配置', submenu: [ { label: '配置', click() { createConfigWindow() } }, { label: '刷新', // 刷新页面 click() { refreshWindows() } }, { label: '打开调试窗口', click(menuItem, targetWindow) { targetWindow.openDevTools() } }, { label: '关闭调试窗口', click(menuItem, targetWindow) { targetWindow.closeDevTools() } }, ] }, { label: '编辑', role: 'editMenu' }, { label: '文件夹', submenu: [ {label: '打开 Rime 配置文件夹', click() {shell.openPath(getRimeConfigDir())}}, {label: '打开 Rime 程序文件夹', click() {shell.openPath(getRimeExecDir())}}, { label: '打开工具配置文件夹', click() { let configDir = path.join(os.homedir(), CONFIG_FILE_PATH) shell.openPath(configDir) } }, ] }, { label: '码表处理工具', submenu: [ { label: '码表处理工具', click() { showToolWindow() } }, ] }, { label: '关于', submenu: [ {label: '最小化', role: 'minimize'}, {label: '关于', role: 'about'}, {type: 'separator'}, {label: '退出', role: 'quit'}, ] }, ] let menu = Menu.buildFromTemplate(menuStructure) Menu.setApplicationMenu(menu) }
标签:选项,菜单,Menu,label,electron,click,targetWindow From: https://www.cnblogs.com/zhulongxu/p/18180101