返回 DeepSeek-Reasonix
icons.ts
根目录 / desktop / electron / src / main / icons.ts
1 import { existsSync } from "node:fs";
2 import { join, resolve } from "node:path";
3
4 export interface IconLookup {
5 platform: NodeJS.Platform;
6 appPath: string;
7 resourcesPath: string;
8 packaged: boolean;
9 }
10
11 export interface IconCandidates {
12 tray: string[];
13 window: string[];
14 dock: string[];
15 }
16
17 export function iconCandidates(input: IconLookup): IconCandidates {
18 const build = input.packaged ? join(input.resourcesPath, "icons") : resolve(input.appPath, "..", "build");
19 const hicolor = (size: string) => join(build, "linux", "icons", "hicolor", size, "apps", "reasonix-desktop.png");
20 const appicon = join(build, "appicon.png");
21 const trayTemplate = join(build, "trayTemplate.png");
22 return {
23 // macOS must not fall through to the full-canvas color appicon for the
24 // tray: template-izing it renders the alpha mask as a solid block (#10715).
25 tray: input.platform === "darwin" ? [trayTemplate, hicolor("32x32"), appicon] : [hicolor("32x32"), appicon],
26 window: [hicolor("256x256"), appicon],
27 // Packaged macOS apps keep their bundle's ICNS. Development uses the same
28 // inset artwork instead of the full-canvas Windows/Linux window icon.
29 dock: input.platform === "darwin" && !input.packaged ? [join(build, "darwin", "appicon.png")] : [],
30 };
31 }
32
33 export function firstExisting(paths: string[]): string | null {
34 return paths.find((path) => existsSync(path)) ?? null;
35 }
36
36 lines TYPESCRIPT