如何在 Electron 应用程序中指定自定义文件扩展名?

sff*_*ffc 3 electron

我想为我的 Electron 应用程序创建自定义文件类型。我想要自定义文件图标,并在您双击文件时打开应用程序。我该怎么做呢?

sff*_*ffc 5

使用电子生成器中的fileAssociations选项。例如,在您的 package.json 中:

"build": {
  // ...
  "fileAssociations": [{
    "ext": "xyz",
    "name": "XYZ File",
    "role": "Editor"
  }]
}
Run Code Online (Sandbox Code Playgroud)