简体   繁体   English

如何更改 Electron 应用程序的图标

[英]How do I change the icon for Electron app

I'm having trouble changing my electron app icon.我在更改电子应用程序图标时遇到问题。

mainWindow = new BrowserWindow({
    width: 1280,
    height: 960,
    frame: false,
    icon: __dirname + 'img/joe.icns',
    webPreferences: {
      nodeIntegration: true,
      enableRemoteModule: true,
      // worldSafeExecuteJavaScript: true,
      // contextIsolation: true,
    },

I've referenced stackoverflow and medium.com for my attempt.我已经参考了stackoverflowmedium.com进行了尝试。

I have also attemptted我也尝试过

icon: __dirname + 'src/img/joe.icns',
icon: __dirname + './img/joe.icns',

and other similar structure names.和其他类似的结构名称。

Picture: Directory Structure图片:目录结构

Try this:尝试这个:

icon: path.join(__static, 'joe.icns'),

And put the icon in ./dist_electron/bundled and ./public并将图标放在./dist_electron/bundled./public

Referencing stackoverflow , I assumed .icns (icon set) was the only extension allowed for electron apps.参考stackoverflow ,我认为 .icns (图标集)是电子应用程序允许的唯一扩展名。 Reading Stackoverflow2 provided by @deniz, I've realized ico file type was also available and gave it a try, and it worked.阅读Stackoverflow2提供由@deniz,我已经意识到ICO文件类型也可以,并给它一个尝试,和它的工作。 I assumed icns was a complex icon file type, and my icns file was probably not compatible with electron app.我认为 icns 是一个复杂的图标文件类型,我的 icns 文件可能与电子应用程序不兼容。 Thank you (and sorry) for the effort @Majed Badawi.感谢(并抱歉)@Majed Badawi 的努力。

icon: __dirname + '/img/joe.ico',

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM