电子 - 无法显示自定义图标 [英] Electron — Can't get custom icon to appear

查看:498
本文介绍了电子 - 无法显示自定义图标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在以两种不同的方式为我的Electron应用设置图标时出现问题:

I'm having an issue setting the icon for my Electron app in two different ways:

非打包(通过终端运行应用)

我的main.js确实指定了一个'icon'值,指向图标文件,但它不适用。

My main.js does specify an 'icon' value, pointing to the icon file, but it does not apply.

打包(使用电子打包器)

我的package.json文件指定'icon'键,指向图标文件,我在 build 目录中有.icns(Mac)文件。我使用了电子打包器来构建应用程序,但是没有应用图标,而是使用了默认的电子图标。

My package.json file specifies the 'icon' key, pointing to the icon file, and I have the .icns (Mac) file in the build directory. I used electron-packager to build the app, but the icon is not applied, the default electron icon is used instead.

不确定我在这里做错了什么,一切看似正确。

Not sure what I'm doing wrong here, everything appears correct.

推荐答案

这里有一个很好的教程:

There is a good tutorial here:

  • https://www.christianengvall.se/electron-app-icons/

按照步骤操作,但请确保不要跳过任何内容。

Follow the steps but make sure you don't skip anything.

这也是GitHub上的一个相关问题:

This is also a relevant issue on GitHub:

  • https://github.com/electron-userland/electron-builder/issues/289

此处有更多链接:

  • https://discuss.atom.io/t/changing-electron-app-icon-and-information/18631

这篇关于电子 - 无法显示自定义图标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆