如何从我的电子应用程序中创建类似于 vscode 安装设置的安装程序?

How to make an installer out of my electron app similar to vscode installation setup?

我正在尝试为我的电子应用程序进行安装设置。我已经尝试过 electron builder 和 electron packager,它有效但不是我所希望的。我想要一个类似于 vscode 的安装设置(我听说它是​​使用 electronjs 制作的),它是一个独立的安装程序,包含所有用户协议、路径等。如何做到这一点?是否根据用户将其安装到哪个 OS 而有所不同?我现在只关注 windows,因为我正在创建的应用程序仅适用于 windows。

electron-builder你设置了"oneClick": false吗?这将为您提供 PC 上的 "install wizard" 样式安装程序。 oneClick 的默认值为真,因此您必须明确设置它。


来自docs

  • oneClick = true Boolean - Whether to create one-click installer or assisted.

  • perMachine = false Boolean - Whether to show install mode installer page (choice per-machine or per-user) for assisted installer. Or whether installation always per all users (per-machine).

  • If oneClick is true (default): Whether to install per all users (per-machine).

  • If oneClick is false and perMachine is true: no install mode installer page, always install per-machine.

  • If oneClick is false and perMachine is false (default): install mode installer page.

  • allowElevation = true Boolean - assisted installer only. Allow requesting for elevation. If false, user will have to restart
    installer with elevated permissions.

  • allowToChangeInstallationDirectory = false Boolean - assisted installer only. Whether to allow user to change installation
    directory.

在 OSX 上,使用 DMG 格式,如果您指定许可证(也许还有 "licenseButtons" JSON 文件——这对我有用)在 DMG 安装之前,您会看到一个协议对话框。

来自docs

To add license to DMG, create file license_LANG_CODE.txt in the build resources. Multiple license files in different languages are supported — use lang postfix (e.g. _de, _ru)). For example, create files license_de.txt and license_en.txt in the build resources. If OS language is german, license_de.txt will be displayed. See map of language code to name.

You can also change the default button labels of the DMG by passing a json file named licenseButtons_LANG_CODE.json. The german file would be named: licenseButtons_de.json. The contain file should have the following format:

{
  "lang": "English",
  "agree": "Agree",
  "disagree": "Disagree",
  "print": "Print",
  "save": "Save",
  "description": "Here is my own description"
}