electron 配置mac安装的图标, 生成.icns文件
electron 配置mac安装的图标
使用的 icon.icns
准备一张 1024 * 1024 的png图片
1. 在项目根目录中创建文件()
mkdir tmp.iconset
sips -z 16 16 logo.png --out tmp.iconset/icon_16x16.png sips -z 32 32 logo.png --out tmp.iconset/icon_16x16@2x.png sips -z 32 32 logo.png --out tmp.iconset/icon_32x32.png sips -z 64 64 logo.png --out tmp.iconset/icon_32x32@2x.png sips -z 128 128 logo.png --out tmp.iconset/icon_128x128.png sips -z 256 256 logo.png --out tmp.iconset/icon_128x128@2x.png sips -z 256 256 logo.png --out tmp.iconset/icon_256x256.png sips -z 512 512 logo.png --out tmp.iconset/icon_256x256@2x.png sips -z 512 512 logo.png --out tmp.iconset/icon_512x512.png sips -z 1024 1024 logo.png --out tmp.iconset/icon_512x512@2x.png
3. 生成 icns
iconutil -c icns tmp.iconset -o icon.icns
4. 修改配置文件
package.json
{ .... "build": { "asar": true, "files": [ "./dist/**/*", "dist/**/*", "electron/**/*" ], "appId": "com.XXXX.XXX", "productName": "XXXXX", "copyright": "Copyright © 2022 XXXXX", "icon": "./Icon.icns", "win": { "icon": "./Icon.icns", "artifactName": "digital_shield.${ext}", "verifyUpdateCodeSignature": false, "requestedExecutionLevel": "highestAvailable", "target": [ "nsis", "zip" ] }, "mac": { "icon": "./Icon.icns", "category": "public.app-category.utilities" }, "nsis": { "oneClick": false, "allowToChangeInstallationDirectory": false, "installerIcon": "./Icon.icns", "uninstallerIcon": "./Icon.icns", "installerHeader": "./Icon.icns", "installerHeaderIcon": "./Icon.icns", "createDesktopShortcut": true, "createStartMenuShortcut": true, "shortcutName": "XXXXXXXXX" } }, .... }