From 5e03b4d76bff18f2a029e58ccdbdebf9e90fd164 Mon Sep 17 00:00:00 2001 From: Jiayuan Zhang Date: Sat, 14 Feb 2026 23:16:56 +0800 Subject: [PATCH] fix(desktop): use asterisk tray icon and show-only menu - Replace resized app icon with dedicated tray icon matching MulticaIcon - Remove click-to-toggle behavior, add "Show Main Window" menu item - Include tray icon PNGs in electron-builder files config Co-Authored-By: Claude Opus 4.6 --- apps/desktop/build/trayTemplate.png | Bin 0 -> 191 bytes apps/desktop/build/trayTemplate@2x.png | Bin 0 -> 326 bytes apps/desktop/electron-builder.json5 | 1 + apps/desktop/src/main/tray.ts | 32 ++++++++----------------- 4 files changed, 11 insertions(+), 22 deletions(-) create mode 100644 apps/desktop/build/trayTemplate.png create mode 100644 apps/desktop/build/trayTemplate@2x.png diff --git a/apps/desktop/build/trayTemplate.png b/apps/desktop/build/trayTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..3b86d3d59e4c08e33b97a856323068651f05c588 GIT binary patch literal 191 zcmeAS@N?(olHy`uVBq!ia0vp^Vj#@H1|*Mc$*~4fZJsWUAr*7ZPI2U8P~>1<`~QEj z?c3C;K^{JD&T>q4+aNLThqZF{jK`CfJv=99Y_Qmg`4q>QGp!AI&m$!}6kYrqo3eLm zo>C32Z(4YbH}*yO#mMy^udr82_dJ<*x9;f-&X8*^ibsx!y8IRNVGQ^X#8H~kD!?PK pN|EJu@`YllICZ=2^Rner7`cy0saaaCQ3tw+!PC{xWt~$(69CWcMvDLd literal 0 HcmV?d00001 diff --git a/apps/desktop/build/trayTemplate@2x.png b/apps/desktop/build/trayTemplate@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..dfb64239d0b7ed7bff932b2a8e4ece87edfa354a GIT binary patch literal 326 zcmV-M0lEH(P)E%i*cwD#5zo|4pXcL0@J{e&K1cG9MH_< z`UdAf!rVT#^~eVPuN3Pr z#X3x}4ilR3bmxuTz~S~%4(xhyNPwMhx;F4#i?}n#31Bv0v(R)|Rh1JDmsPb3AcwA4 zRn^3uSeaGj6jfH0^Tk1hRporsp=(u5SXh{{swVw5sI4l8IS7|kr4%05z{fgF@oRvp YUV=R~R9pRqU;qFB07*qoM6N<$f_XHHlK=n! literal 0 HcmV?d00001 diff --git a/apps/desktop/electron-builder.json5 b/apps/desktop/electron-builder.json5 index 2acbbfbe..753424e2 100644 --- a/apps/desktop/electron-builder.json5 +++ b/apps/desktop/electron-builder.json5 @@ -10,6 +10,7 @@ }, "files": [ "out", + "build/trayTemplate*.png", "!**/.vscode/*", "!src/*", "!electron.vite.config.{js,ts,mjs,cjs}", diff --git a/apps/desktop/src/main/tray.ts b/apps/desktop/src/main/tray.ts index a0e2d47b..90436ce2 100644 --- a/apps/desktop/src/main/tray.ts +++ b/apps/desktop/src/main/tray.ts @@ -18,20 +18,15 @@ let statusInterval: ReturnType | null = null export function createTray(window: BrowserWindow): void { mainWindowRef = window - const iconPath = path.join(process.env.APP_ROOT!, 'build', 'icon.png') + // Use dedicated tray icon (asterisk shape matching MulticaIcon). + // On macOS, Electron auto-picks trayTemplate.png / trayTemplate@2x.png + // and treats "Template" suffix as a template image (adapts to dark/light menu bar). + const iconPath = path.join(process.env.APP_ROOT!, 'build', 'trayTemplate.png') const icon = nativeImage.createFromPath(iconPath) - const trayIcon = icon.resize({ width: 16, height: 16 }) - if (process.platform === 'darwin') { - trayIcon.setTemplateImage(true) - } - - tray = new Tray(trayIcon) + tray = new Tray(icon) tray.setToolTip('Multica') - // Click to toggle window visibility - tray.on('click', toggleWindowVisibility) - // Initial menu updateTrayMenu() @@ -54,15 +49,10 @@ export function destroyTray(): void { mainWindowRef = null } -function toggleWindowVisibility(): void { +function showMainWindow(): void { if (!mainWindowRef || mainWindowRef.isDestroyed()) return - - if (mainWindowRef.isVisible()) { - mainWindowRef.hide() - } else { - mainWindowRef.show() - mainWindowRef.focus() - } + mainWindowRef.show() + mainWindowRef.focus() } function updateTrayMenu(): void { @@ -90,15 +80,13 @@ function updateTrayMenu(): void { tray.setToolTip(`Multica - Agent: ${agentStatus}`) - const windowVisible = mainWindowRef && !mainWindowRef.isDestroyed() && mainWindowRef.isVisible() - const menu = Menu.buildFromTemplate([ { label: `Agent: ${agentStatus}`, enabled: false }, { label: `Hub: ${hubStatus}`, enabled: false }, { type: 'separator' }, { - label: windowVisible ? 'Hide Window' : 'Show Window', - click: toggleWindowVisibility, + label: 'Show Main Window', + click: showMainWindow, }, { type: 'separator' }, {