I want to change the default Electron icon to custom icon on all the places but i am unable to change in two places.
- The icon on the Windows start menu when we search the application
- The icon on the Windows taskbar
I have also tried a few solutions
mainWindow = new BrowserWindow({
width: 1024,
height: 768,
resizable: false,
icon: path.join(__dirname, 'src/app_64x64.png'),
});
and
mainWindow.setOverlayIcon(path.join(__dirname, 'src/app_128x128.png'), 'Description for overlay');
but both the solutions are not working. Is there any way to change the icon?
Windows Task bar image
Window Application search image
I want to change the default Electron icon to custom icon on all the places but i am unable to change in two places.
- The icon on the Windows start menu when we search the application
- The icon on the Windows taskbar
I have also tried a few solutions
mainWindow = new BrowserWindow({
width: 1024,
height: 768,
resizable: false,
icon: path.join(__dirname, 'src/app_64x64.png'),
});
and
mainWindow.setOverlayIcon(path.join(__dirname, 'src/app_128x128.png'), 'Description for overlay');
but both the solutions are not working. Is there any way to change the icon?
Windows Task bar image
Window Application search image
Share Improve this question edited Jul 29, 2020 at 9:38 James Z 12.3k10 gold badges27 silver badges47 bronze badges asked Jul 29, 2020 at 9:18 Vivek Kumar ShuklaVivek Kumar Shukla 1962 silver badges14 bronze badges 2- Have you tried everything described there ? stackoverflow./questions/31529772/… – Jona Commented Jul 29, 2020 at 9:27
- Yes. It is not working for me. mainWindow.setOverlayIcon showing half in size – Vivek Kumar Shukla Commented Jul 29, 2020 at 10:51
4 Answers
Reset to default 1if you are building the app with electron-builder module then add this
"build": {
"productName": "Your App Name",
"win": {
"target": "NSIS",
"icon": "public/img/logo.ico"
}
}
in package.json
in addition to what Vishnu suggested: You can also just put icon.png file inside your buildResources folder. So, my electron.manifest.json looks like this:
"build": {
"appId": "ID",
"productName": "NAME",
"copyright": "Copyright",
"buildVersion": "1.0.0",
"pression": "maximum",
"directories": {
"output": "../../../bin/Desktop",
"buildResources": "./bin/_____"
},
"win": {
"target": "nsis"
}
But be aware Windows seems to cache icons, it might be the reason why you don't see any changes. You can try to delete C:\Users%USER_NAME%\AppData\Local\IconCache and reboot your PC to see if it's a case.
Set icon property to BrowserWindow in your app.js (or what you named your entry):
function createWindow() {
mainWindow = new BrowserWindow({
icon: 'images/logo.ico',
width: 800,
height: 600,
webPreferences: {
nodeIntegration: true,
}
})
Make sure to have this in your forge.config:
module.exports = {
packagerConfig: {
icon: 'images/logo.ico'
And this in forge.config too:
makers: [
{
name: '@electron-forge/maker-squirrel',
config: {
// An URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features).
icon: 'images/logo.ico',
// The ICO file to use as the icon for the generated Setup.exe
setupIcon: 'images/logo.ico',
},
},
All this will change the your app icon, taskbar icon, window icon. At this moment it has a issue with icon in add/remove programs and the icon in the task manager on Windows 7 and 10.
NB! As @Tetiana mentioned above - Windows make cache of icons here: C:\Users%USER_NAME%\AppData\Local\IconCache Delete it and reboot if you want to view your real icons. I spend a half day to figure out why they not changing.
For those using electron by itself with a package.json
file. Make sure to include the path to the png with the icon
key.
Example:
{
"name": "app",
"version": "1.0.0",
"description": "generic description",
"main": "main.js",
"type": "module",
"icon": "./path/to/icon.png",
}
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745560276a4633066.html
评论列表(0条)