如何添加Electron DMG背景图像?

时间:2016-09-30 14:27:00

标签: macos electron

我有一个Electron应用程序,它不会在DMG版本中显示背景图像。我的package.json(顶级)包含:

"pack": "build --dir",
"dist": "build"

我的“build”目录也有一个有效的“background.png”。还需要配置什么?

2 个答案:

答案 0 :(得分:0)

上面的配置是正确的。如果配置了非默认的OS X安装文件夹,电子构建器中的某个点就会出现错误,导致后台不显示。

答案 1 :(得分:0)

PKG 内置电子生成器

的更新

package.json

  "build": {
    "appId": "com.audio.application",
    "productName": "Audio-App",
    "artifactName": "${productName}-Setup-${version}.${ext}",
    "copyright": "Copyright © 2020 Audio Corp",
    "mac": {
      "category": "com.audio.application",
      "target": [
        "pkg"
      ],
      "icon": "dist",
      "identity": "identity",
      "darkModeSupport": true,
      "hardenedRuntime": true,
      "gatekeeperAssess": false,
      "artifactName": "${productName}.${ext}"
    },
    "pkg": {
      "scripts": "../build/pkg-scripts",
      "installLocation": "/Applications",
      "background": {
        "file": "build/icon/background.png",
        "alignment": "bottomleft"
      },
      "allowAnywhere": true,
      "allowCurrentUserHome": true,
      "allowRootDirectory": true,
      "license": "build/license.html",
      "welcome": "build/resources/welcome.txt",
      "conclusion": "build/resources/conclusion.txt",
      "isVersionChecked": true,
      "isRelocatable": false,
      "overwriteAction": "upgrade"
    },
    "directories": {
      "buildResources": "release",
      "output": "release"
    }
    },

构建目录的文件夹结构-
(位于项目的根目录)

enter image description here


背景(数据类型: PkgBackgroundOptions

PkgBackgroundOptions

  • 文件(数据类型:字符串)
  • alignment(数据类型: BackgroundAlignment | null)
  • 缩放(数据类型: BackgroundScaling | null)

BackgroundAlignment

  • “中心” | “左” | “正确” | “顶部” | “底部” | “左上” | “右上” | “ bottomleft” | “右下”

BackgroundScaling

  • “适应” | “无” | “比例”

参考:pkgOptions