使用electron-forge构建app

官方文档有很详细的教程: electron-forge

使用官方 electron-quick-start 的demo。在其根目录下执行:

# 注意node的版本,我使用v9.6.0不行,使用了v12.0.0才可以
npx @electron-forge/cli import
npm run make

成功后在你的根目录下生成一个out文件。

使用appdmg做成dmg包

appdmg是一个npm包。

npm install -g appdmg

appdmg.json配置如下

{
    "title": "MyApp",
    "icon": "app.icns",
    "background": "bg.png",//
    "contents": [
      { "x": 380, "y": 170, "type": "link", "path": "/Applications" },
      { "x": 200, "y": 170, "type": "file", "path": "./../out/中文安装包-darwin-x64/中文安装包.app" } //这是上一步electron forge生成的东西,指定好目录就行了。
    ],
    "window": {
        "size": {
            "width": 580,
            "height": 360
        }
    },
    "format": "UDBZ"
}

需要注意的是electron forge主要管控的是安装时的行为。安装包安装后展示的在lunch中的信息是安装包自身配置的属性,比如展示的名称和图标。

配置完后执行:

appdmg ./build/appdmg.json ~/Desktop/test.dmg

相关文章:

  • 2021-07-10
  • 2021-08-06
  • 2021-09-16
  • 2022-12-23
  • 2022-12-23
  • 2021-04-27
猜你喜欢
  • 2021-05-18
  • 2019-08-24
  • 2022-02-16
  • 2018-04-04
  • 2021-08-04
  • 2021-12-24
相关资源
相似解决方案