如何更改 NW.js 中的任务栏图标?

How to change taskbar icon in NW.js?

我想设置自定义任务栏图标,但配置不工作。我尝试使用 PNGICO 文件,但没有任何意义。

我搜索了很多并找到了 that and that,但这对我的问题没有帮助。

这是我的 package.json:

  "name": "nwjsapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@fortawesome/fontawesome-svg-core": "^1.2.18",
    "@fortawesome/free-brands-svg-icons": "^5.8.2",
    "@fortawesome/free-solid-svg-icons": "^5.8.2",
    "@fortawesome/react-fontawesome": "^0.1.4",
    "adm-zip": "^0.4.13",
    "async-file-dl": "^0.4.1",
    "axios": "^0.19.0",
    "child-process": "^1.0.2",
    "child_process": "^1.0.2",
    "download-file-with-progressbar": "^1.2.3",
    "filenamify": "^4.1.0",
    "is-admin": "^3.0.0",
    "node-machine-id": "^1.1.12",
    "nw-autoupdater": "^1.1.10",
    "nw-react-scripts": "2.0.0",
    "prop-types": "^15.7.2",
    "react": "^16.8.6",
    "react-animations": "^1.0.0",
    "react-dom": "^16.8.6",
    "react-redux": "^7.0.3",
    "redux": "^4.0.1",
    "runas": "^3.1.1",
    "shelljs": "^0.8.3",
    "spawn-as-admin": "^0.1.3",
    "styled-components": "^4.2.0",
    "trim-character": "^2.0.1",
    "walk-promise": "^0.2.0"
  },
  "scripts": {
    "start": "nw-react-scripts start",
    "build": "nw-react-scripts build",
    "test": "nw-react-scripts test",
    "eject": "nw-react-scripts eject"
  },
  "eslintConfig": {
    "extends": "nw-react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ],
  "main": "index.html",
  "nwBuilder": {
    "//": "https://github.com/nwjs-community/nw-builder",
    "platforms": [
      "win64"
    ],
    "version": "latest",
    "flavor": "normal",
    "buildDir": "./build",
    "cacheDir": "./cache",
    "macIcns": "./src/logo.icns"
  },
  "window": {
    "resizable": false,
    "toolbar": false,
    "frame": false,
    "width": 391,
    "height": 444,
    "position": "center",
    "icon": "icon.png"
  }
}

我想将此图标更改为自定义图标:

非常感谢您的帮助!

位置正确 package.json:window:icon

问题是你的icon.png所在的路径。更改为类似 "build/icon.png" 的内容,其中 build 是构建目标的文件夹。