The electron-builder packaged desktop only displays half of the icons, and the desktop icons and the icons in the upper left corner of the program are not fully displayed.

Problem Description

As shown in the picture:
d3adf6f4035656e4f85755ddf6b0a7f.png

problem analysis

image.pngThe desktop is normal again, but the icons at runtime are not normal. It stands to reason that these two icons are the same. However, there is a problem that the icons running on the taskbar are not fully displayed. After a lot of searching and trying, the problem is finally determined:
1. The minimum logo image size is 256*256 pixels
2. The generated ico icon cannot be higher than 50kb

Solution:

1. Prepare a 256×256 pixel picture, and the size is about 30kb.
2. Go to the website to make a 256*256 ico icon. (Other methods can also be used to generate ico icons, but the generated ico icons cannot be larger than 50kb) The
website is: https://convertio.co/zh/
Note that the generated ico files cannot be larger than 50kb, and taskbar icons will appear if they are larger than 50kb The problem of incomplete display
3. Place the ico icon in the publich folder
insert image description here

4.package.json configuration:

"win": {
    
    
      "icon": "public/logoTemplate.ico",
      "target": [
        {
    
    
          "target": "nsis",
          "arch": [
            "x64",
            "ia32"
          ]
        }
      ],
      "artifactName": "${productName}_${version}.${ext}"
    }

Summary: The summary is that your ico icon needs to be 256*256, and it cannot be larger than 50kb. As long as it is larger, this problem will occur . In addition, it is best to use the ico icon directly instead of png, because if png is used, it will be processed by nsis. When the complex icon is converted into ico, it will be larger than 50kb. For example, sometimes your 20kb png will become 100kb ico after nsis processing, which will lead to this problem again.

Guess you like

Origin blog.csdn.net/weixin_43239880/article/details/130066060