electron-builder中NSIS相关配置之自定义设置安装图标等

// 特别注意 图标必须是ico格式的才行,png图标转ico可参照(https://www.jb51.net/softjc/93414.html##2
// options placed here will be merged with default configuration and passed to electron-builder
const isDevelopment = process.env.NODE_ENV !== 'production'
const bundleId = 'xxxxx'
const teamID = '1111111'
/* eslint-disable no-template-curly-in-string */
let baseConfig = {
  // 公共部分
  // 必须要设置,是一个程序的唯一标识符,还与后面的程序自动更新有关
  'appId': bundleId,
  // 项目名 这也是生成的exe文件的前缀名,指定一下程序名称,这个对于后面创建桌面快捷方式和开始菜单都有关系
  'productName': process.env.VUE_APP_TITLE,
  // 版权信息
  'copyright': process.env.VUE_APP_COPYRIGHT,
  // 设置为 true 可以把自己的代码合并并加密
  'asar': true,
  'dmg': {
    'contents': [
      {
        'x': 410,
        'y': 150,
        'type': 'link',
        'path': '/Applications'
      },
      {
        'x': 130,
        'y': 150,
        'type': 'file'
      }
    ]
  },
  'mas': {
    'icon': 'build/icon.icns',
    entitlements: 'build/entitlements.mas.plist',
    'provisioningProfile': 'embedded.provisionprofile'
  },
  'mac': {
    'icon': 'build/icons.png',
    // https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html#//apple_ref/doc/uid/TP40009250-SW8
    'category': 'public.app-category.finance',
    // type: 'distribution',
    entitlements: 'build/entitlements.mac.plist',
    'extendInfo': {
      'ElectronTeamID': teamID,
      'com.apple.developer.team-identifier': teamID,
      'com.apple.application-identifier': `${teamID}.${bundleId}`
    },
    'target': [
      {
        'target': 'dmg'
      },
      {
        'target': 'zip'
      }
      // {
      //   'target': 'pkg'
      // },
      // {
      //   'target': 'mas'
      // }
    ]
  },
  // win 特定部分
  'win': {
    // 图标路径 windows系统中icon需要256*256的ico格式图片,更换应用图标亦在此处
    'icon': 'build/icons.png',
    // 'target': 'nsis'
    'target': [
      {
        // 打包成一个独立的 exe 安装程序
        'target': 'nsis',
        // 这个意思是打出来32 bit + 64 bit的包,但是要注意:这样打包出来的安装包体积比较大,所以建议直接打32的安装包。
        // 'arch': [
        //   'x64',
        //   'ia32'
        // ]
        'arch': [
          'ia32'
        ]
      }
    ]
  },
  'nsis': {
    // 是否一键安装,建议为 false,可以让用户点击下一步、下一步、下一步的形式安装程序,如果为true,当用户双击构建好的程序,自动安装程序并打开,即:一键安装(one-click installer)
    'oneClick': false,
    // 允许请求提升。 如果为false,则用户必须使用提升的权限重新启动安装程序。
    'allowElevation': true,
    // 允许修改安装目录,建议为 true,是否允许用户改变安装目录,默认是不允许
    'allowToChangeInstallationDirectory': true,
    // 安装图标
    'installerIcon': 'build/installerIcon_120.ico',
    // 卸载图标
    'uninstallerIcon': 'build/uninstallerIcon_120.ico',
    // 安装时头部图标
    'installerHeaderIcon': 'build/installerHeaderIcon_120.ico',
    // 创建桌面图标
    'createDesktopShortcut': true,
    // 创建开始菜单图标
    'createStartMenuShortcut': true,
    // electron中LICENSE.txt所需要的格式,并非是GBK,或者UTF-8,LICENSE.txt写好之后,需要进行转化,转化为ANSI
    'license': 'LICENSE.txt'
  },
  'extends': null
}

if (!isDevelopment) {
  baseConfig = {
    ...baseConfig,
    // 压缩级别,如果要打包成安装包的话建议设为 maximum 可以使安装包体积更小,当然打包时间会长一点点
    'compression': 'maximum'
  }
}

module.exports = baseConfig
  • 3
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值