打包

作者: EnjoyWT | 来源:发表于2024-10-09 11:56 被阅读0次

两种方式:

  1. electron-forge
  2. electron-builder

electron-forge

1. MacOS DMG

1. 基础配置

配置参考文档

help.png
  {
      name: "@electron-forge/maker-dmg",
      config: {
        name: "dmg的名字",
        // title: "标题名称",
        format: "ULFO",
        background: "./dmg-background.png",
        additionalDMGOptions: {
          window: {
            size: {
              width: 200, // 设置窗口宽度
              height: 400, // 设置窗口高度
            },
            position: {
              x: 200, // 设置窗口相对于屏幕左侧的位置
              y: 200, // 设置窗口相对于屏幕底部的位置
            },
          },
        },
      },
    },
2. 签名
2.1 mac 应用分发一般不需要进行签名

2.2 签名配置 (未验证)

module.exports = {
  packagerConfig: {
    osxSign: {
      identity: 'Developer ID Application: Your Name (Team ID)',  // 使用你的开发者证书
      'hardened-runtime': true,  // 使用强化运行时以满足苹果的安全要求
      entitlements: 'path/to/your/entitlements.plist',  // 指定权限文件
      'entitlements-inherit': 'path/to/your/entitlements.plist',  // 继承权限
      'signature-flags': 'library'
    },
    osxNotarize: {
      appleId: 'your-apple-id@example.com',  // 苹果账号
      appleIdPassword: 'your-apple-id-password'  // 苹果账号密码或 app-specific password
    }
  },
  makers: [
    {
      name: '@electron-forge/maker-dmg',
      config: {
        background: './assets/dmg-background.png',
        format: 'ULFO',
        additionalDMGOptions: {
          window: {
            size: {
              width: 600,
              height: 400
            },
            position: {
              x: 200,
              y: 200
            }
          }
        }
      }
    }
  ]
};

从 macOS 10.15 Catalina 开始,所有分发给用户的应用都需要经过 Apple 的公证服务,以确保应用没有包含恶意软件。

在配置中可以直接添加 osxNotarize 选项来完成自动公证:

  osxNotarize: {
      appleId: 'your-apple-id@example.com',  // 苹果账号
      appleIdPassword: 'your-apple-id-password'  // 苹果账号密码或 app-specific password
    }

• entitlements: 定义应用程序运行时的权限,确保应用可以访问所需的系统资源。
• entitlements-inherit: 为应用程序的子进程或二进制文件继承相同的权限。
• signature-flags: 'library': 指定为动态库或插件签名,以便系统在运行时加载这些库时不会破坏签名。

electron-builder

通用配置

相关文章

网友评论

      本文标题:打包

      本文链接:https://www.haomeiwen.com/subject/iudirjtx.html