Skip to content

Commit 9a8206d

Browse files
committed
fix(windows): align taskbar setAppDetails with embedded exe icon
Prefer process.execPath for setAppDetails when nativeImage decodes RT_ICON (shell/taskbar); else resources/icon.ico. Add build.icon alongside win.icon for electron-builder default icon resolution. Made-with: Cursor
1 parent dc557fb commit 9a8206d

2 files changed

Lines changed: 21 additions & 1 deletion

File tree

app/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
"build": {
5151
"appId": "com.sraibaby.app",
5252
"productName": "Hyperlinks Space Program",
53+
"icon": "assets/icon.ico",
5354
"asar": {
5455
"smartUnpack": true
5556
},

app/windows/build.cjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1993,6 +1993,25 @@ function logWindowsIconProbeAlways(windowIcon) {
19931993
}
19941994
}
19951995

1996+
/**
1997+
* Path for setAppDetails (taskbar / Jump List): prefer the .exe when Chromium can decode an embedded
1998+
* icon — Windows shell uses the exe for the taskbar more reliably than a loose .ico in that case.
1999+
* Otherwise use resources\\icon.ico (see embed-windows-exe-icon.cjs + afterSign).
2000+
*/
2001+
function resolveWindowsTaskbarDetailsIconPath() {
2002+
if (process.platform !== "win32" || !app.isPackaged) return null;
2003+
const exe = process.execPath;
2004+
const ico = ensureWindowsIcoFileOnDiskSync();
2005+
try {
2006+
if (fs.existsSync(exe)) {
2007+
const niFromExe = nativeImage.createFromPath(exe);
2008+
if (!niFromExe.isEmpty()) return exe;
2009+
}
2010+
} catch (_) {}
2011+
if (ico && fs.existsSync(ico)) return ico;
2012+
return fs.existsSync(exe) ? exe : ico;
2013+
}
2014+
19962015
/** Logs once per main window: summary + probe(always); full dump when HSP_DEBUG_ICON=1. */
19972016
function logWindowsIconEnvironment(windowIcon) {
19982017
if (process.platform !== "win32" || !app.isPackaged) return;
@@ -2117,7 +2136,7 @@ async function createWindow() {
21172136
// Win32: ties this HWND to AppUserModelID + icon for the taskbar button (see Electron BrowserWindow.setAppDetails).
21182137
if (process.platform === "win32" && fs.existsSync(process.execPath)) {
21192138
try {
2120-
const detailsIcon = ensureWindowsIcoFileOnDiskSync() || process.execPath;
2139+
const detailsIcon = resolveWindowsTaskbarDetailsIconPath();
21212140
if (detailsIcon && fs.existsSync(detailsIcon)) {
21222141
mainWindow.setAppDetails({
21232142
appId: WIN_APP_USER_MODEL_ID,

0 commit comments

Comments
 (0)