电子:如何为Darwin / OS X

时间:2019-10-21 10:26:11

标签: electron

我刚刚完成了我的第一个电子封装,但是找不到有关如何在Mac OS X-达尔文上弹出“关于”的任何教程或示例。

到目前为止,我有

const menuTemplate = [
    ...(process.platform == 'darwin'? [{
        label: app.getName(),
        submenu: [
       {role: 'about'}
       ]
       }] : []),
    {
        label: "File",
        submenu: [
            {
                label: "Save",
                accelerator: "CmdOrCtrl+S",
                click(){ win.webContents.send('save-clicked')}
            },

            {
                label: "Save As",
                accelerator: "CmdOrCtrl+Shift+S",
                click(){ 
                    filePath = undefined
                    win.webContents.send('save-clicked')
                }
            }
        ]
    },

    {role: "editMenu"},
    {role: "viewMenu"}

我认为必须在角色“ about”之后设置一些内容,但不确定什么:)

1 个答案:

答案 0 :(得分:0)

实际上有一种方法,我们需要创建另一个浏览器窗口,而不是使用默认过程。希望这会起作用。

const menuTemplate = [
    ...(process.platform == 'darwin'? [{
        label: app.getName(),
        submenu: [{
         label: 'about',
         click: () => //Do something here to create a new browser window with necessary requirement,
        }]
       }] : []),
    {
        label: "File",
        submenu: [
            {
                label: "Save",
                accelerator: "CmdOrCtrl+S",
                click(){ win.webContents.send('save-clicked')}
            },

            {
                label: "Save As",
                accelerator: "CmdOrCtrl+Shift+S",
                click(){ 
                    filePath = undefined
                    win.webContents.send('save-clicked')
                }
            }
        ]
    },