Skip to content

Commit 20ffd60

Browse files
committed
fix: app icon in macos dock and system tray
1 parent 0f098d6 commit 20ffd60

5 files changed

Lines changed: 21 additions & 7 deletions

File tree

apps/desktop/build/icon.png

-23.9 KB
Loading

apps/desktop/src/main.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { app, BrowserWindow, Menu, Tray, shell, dialog } from "electron";
1+
import { app, BrowserWindow, Menu, Tray, shell, dialog, nativeImage } from "electron";
22
import { createLogger, enableFileLogging } from "@easyclaw/logger";
33
import {
44
GatewayLauncher,
@@ -52,6 +52,14 @@ import { createGatewayConfigBuilder } from "./gateway-config-builder.js";
5252

5353
const log = createLogger("desktop");
5454

55+
function setDockIcon(): void {
56+
const iconPath = resolve(dirname(fileURLToPath(import.meta.url)), "../build/icon.png");
57+
const icon = nativeImage.createFromPath(iconPath);
58+
if (!icon.isEmpty()) {
59+
app.dock?.setIcon(icon);
60+
}
61+
}
62+
5563
const PANEL_URL = process.env.PANEL_DEV_URL || `http://127.0.0.1:${resolvePanelPort()}`;
5664
// Resolve Volcengine STT CLI script path.
5765
// In packaged app: bundled into Resources/.
@@ -218,6 +226,7 @@ app.whenReady().then(async () => {
218226
// (which also prevents child processes like the gateway from showing dock icons).
219227
// We explicitly show it for the main process here.
220228
app.dock?.show();
229+
setDockIcon();
221230

222231
// --- Device ID ---
223232
let deviceId: string;

apps/desktop/src/tray-icon.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
import { nativeImage } from "electron";
1+
import { app, nativeImage } from "electron";
22
import type { NativeImage } from "electron";
33
import type { GatewayState } from "@easyclaw/gateway";
44
import { resolve, dirname } from "node:path";
55
import { fileURLToPath } from "node:url";
66

77
const __dirname = dirname(fileURLToPath(import.meta.url));
8+
const DEV_TRAY_ICON_PATH = resolve(__dirname, "../../panel/public/logo.png");
9+
const PACKAGED_TRAY_ICON_PATH = resolve(__dirname, "../build/[email protected]");
10+
const TRAY_ICON_SIZE = 44;
811

912
/**
1013
* Color palette for state indicator dot.
@@ -20,12 +23,14 @@ const STATE_COLORS: Record<GatewayState, [number, number, number]> = {
2023
/**
2124
* Create a tray icon from the app logo PNG with a colored status dot overlay.
2225
*
23-
* Uses build/[email protected] (64x64) as base, displayed at 32x32 on retina.
26+
* In dev, load the panel logo directly so icon tweaks are reflected immediately.
27+
* In packaged builds, use the bundled tray PNG.
2428
* Overlays a small colored circle in the bottom-right corner to indicate gateway state.
2529
*/
2630
export function createTrayIcon(state: GatewayState): NativeImage {
27-
const iconPath = resolve(__dirname, "../build/[email protected]");
28-
const base = nativeImage.createFromPath(iconPath);
31+
const iconPath = app.isPackaged ? PACKAGED_TRAY_ICON_PATH : DEV_TRAY_ICON_PATH;
32+
const source = nativeImage.createFromPath(iconPath);
33+
const base = source.resize({ width: TRAY_ICON_SIZE, height: TRAY_ICON_SIZE });
2934

3035
// Get the raw RGBA bitmap
3136
const size = base.getSize();
@@ -36,7 +41,7 @@ export function createTrayIcon(state: GatewayState): NativeImage {
3641

3742
// Draw a state indicator dot in the bottom-right corner
3843
const [r, g, b] = STATE_COLORS[state];
39-
const dotRadius = Math.round(w * 0.18); // ~18% of icon size
44+
const dotRadius = Math.round(TRAY_ICON_SIZE * 0.18); // ~18% of the visible icon size
4045
const cx = w - dotRadius - 1;
4146
const cy = h - dotRadius - 1;
4247

apps/panel/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<head>
44
<meta charset="UTF-8" />
55
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6-
<link rel="icon" href="/favicon.ico" />
6+
<link rel="icon" href="/logo.png" />
77
<title>EasyClaw</title>
88
</head>
99
<body>

apps/panel/public/favicon.ico

-16.6 KB
Binary file not shown.

0 commit comments

Comments
 (0)