• background.js
import { Menu} from 'electron'

async function createWindow() {
....
    let menu_template=[
                {
                  label: '文件',
                  submenu: [
                    { role: 'quit',label:"退出" } 
                  ]
                },
    ]
  //主菜单
  let _template = menu_template(win);
  const _menu = Menu.buildFromTemplate(_template)
  Menu.setApplicationMenu(_menu)

菜单的事件role说明