简体   繁体   English

电子:使用上下文菜单打开

[英]Electron: Open With Context Menu

In Electron, I would like to use a context menu to utilize the "Open With" submenu as is done on Mac OS. 在Electron中,我想使用上下文菜单来像在Mac OS上一样使用“打开方式”子菜单。 Is this functionality possible in electron? 电子中有这种功能吗?

在此处输入图片说明

I haven't worked with either of these options but they seem viable: 我没有使用以下任何一个选项,但它们似乎可行:

Native Electron: menu.popup(options) 本机电子: menu.popup(options)

electron-context-menu 电子上下文菜单

You might try adding this to your electron-builder-config.json : 您可以尝试将其添加到electron-builder-config.json

   "fileAssociations": [
        {
            "ext": ["txt", "md", "yml"],
            "name": "Plain Text",
            "role": "Editor"
        }
    ],

From https://github.com/rchrd2/example-electron-file-association 来自https://github.com/rchrd2/example-electron-file-association

See also: https://www.electron.build/configuration/configuration#PlatformSpecificBuildOptions-fileAssociations 另请参阅: https : //www.electron.build/configuration/configuration#PlatformSpecificBuildOptions-fileAssociations

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM