Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
4.3k views
in Technique[技术] by (71.8m points)

使用electron-forge如何自定义应用程序exe图标

如题,我在windows下用electron做程序,我的自定义图标放在{项目文件夹}/image/icon.ico,是64x64尺寸的ico文件,main.js放在{项目文件夹}/interface/main.jspackage.json就放在项目文件夹根目录。
我在main.js中写:

function createWindow () {
  const win = new BrowserWindow({
    width: 950,
    height: 690,
    icon:join(__dirname,'../image/icon.ico'),//Extra
    resizable: false,
    webPreferences: {
        nodeIntegration: true
    }
  })
  win.loadFile('interface/index.html')
}

结果npm run make之后只有任务栏和窗口左上角的图标改了,生成的exe文件本身的图标还是默认的。
后来又修改package.json,添加:

"config": {
    "forge": {
      "packagerConfig": {
        "icon": "image/icon.ico"//Extra
      },
      ··· ···
    }
  }

结果exe文件的图标依然没有改变。
请问我应该怎么做,才能使exe文件的图标改变?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...