使用 Electron 在 Mac 中定义文件关联

Define file association in Mac with Electron

我正在尝试创建一个简单的电子应用程序,它从 Google Drive 打开 Google office 文件,读取 link 文件并创建一个新的 window 包含google 文档页面。

如果我在使用 electron-builder 构建后编辑 info.plist 以使应用程序接受文件扩展名“.gdoc、.gsheets 和 .gslides”,我可以让它工作。

有没有不涉及手动编辑的更聪明的方法info.plist?

Electron-builder is supposed to be able to do that through specifying the FileAssociation。我已经阅读了与此相关的各种问题,但我自己还不需要它——如果它对你有用,请反馈。

还有Windows唯一的electron-regedit节点模块:

"File associations, file icons & open with... for electron apps

This module allows you to register your app in the windows registry, manipulate context menus & handle native open, edit, print, preview actions ect."

但是对于 Google 驱动器,您可能正在考虑注册一个协议和 url 方案。有人支持electron-packager

protocol

Array of Strings

The URL protocol scheme(s) to associate the app with. For example, specifying myapp would cause URLs such as myapp://path to be opened with the app. Maps to the CFBundleURLSchemes metadata property. This option requires a corresponding protocol-name option to be specified.

protocol-name

Array of Strings

The descriptive name(s) of the URL protocol scheme(s) specified via the protocol option. Maps to the CFBundleURLName metadata property.