首页 > 解决方案 > electron-forge @maker-dmg 如何在 dmg 安装程序中更改图标位置

问题描述

我一直在尝试修改 中的一些参数maker-dmg,到目前为止,除了图标位置之外,我得到了所有我想要的。

这就是我目前所拥有的:

      name: "@electron-forge/maker-dmg",
      config: {
        title: "Gallery",
        background: "src/assets/installer-assets/installBackground.png",
        format: "ULFO",
        icon: "src/assets/installer-assets/brand-icon.icns",
        contents: [
          { x: 192, y: 344, type: "file", path: "Gallery.app" },
          { x: 428, y: 344, type: "link", path: "/Applications" }
        ]
      }

但我收到一条错误消息,说它找不到 Gallery.app。

制作目标时出错:dmg "Gallery.app" not found at: /var/folders/07/rvgsd3wx7_949217htsn84pw0000gn/T/Gallery.app

我知道制造商只将信息转发到appdmg库。我一直在浏览他们的文档,我发现所有这些都被视为相对路径。

基本上我不知道临时挂载位置是什么,我只想从内容对象中指定 x 和 y 变量,但它迫使我指定类型和路径。

有没有人改变过dmg风格?请高度赞赏任何帮助。

PD。当我在没有指定内容的情况下安装 dmg 然后添加如下内容时,此方法有效:

{ x: 192, y: 344, type: "file", path: "/Volumes/Gallery/Gallery.app" },

但是一旦我弹出它并更新伪造配置以包含上面的行,它就会中断。

标签: macoselectrondmgelectron-forge

解决方案


如果有人经历相同的 bs,只需使用process.cwd().

参见示例:

contents: [
      {
        x: 192,
        y: 240,
        type: "file",
        path: `${process.cwd()}/out/Gallery-darwin-x64/Gallery.app`
      },
      { x: 466, y: 240, type: "link", path: "/Applications" }
    ]

我终于可以玩转图标位置了!快乐编码。


推荐阅读