mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-28 06:22:45 -08:00
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
export function resolveTrayIconPathRuntime(deps: {
|
|
platform: string;
|
|
resourcesPath: string;
|
|
appPath: string;
|
|
dirname: string;
|
|
joinPath: (...parts: string[]) => string;
|
|
fileExists: (path: string) => boolean;
|
|
}): string | null {
|
|
const iconNames =
|
|
deps.platform === 'darwin'
|
|
? ['SubMinerTemplate.png', 'SubMinerTemplate@2x.png', 'SubMiner.png']
|
|
: ['SubMiner.png'];
|
|
|
|
const baseDirs = [
|
|
deps.joinPath(deps.resourcesPath, 'assets'),
|
|
deps.joinPath(deps.appPath, 'assets'),
|
|
deps.joinPath(deps.dirname, '..', 'assets'),
|
|
deps.joinPath(deps.dirname, '..', '..', 'assets'),
|
|
];
|
|
|
|
for (const baseDir of baseDirs) {
|
|
for (const iconName of iconNames) {
|
|
const candidate = deps.joinPath(baseDir, iconName);
|
|
if (deps.fileExists(candidate)) {
|
|
return candidate;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
|
|
export type TrayMenuActionHandlers = {
|
|
openOverlay: () => void;
|
|
openYomitanSettings: () => void;
|
|
openRuntimeOptions: () => void;
|
|
openJellyfinSetup: () => void;
|
|
openAnilistSetup: () => void;
|
|
quitApp: () => void;
|
|
};
|
|
|
|
export function buildTrayMenuTemplateRuntime(handlers: TrayMenuActionHandlers): Array<{
|
|
label?: string;
|
|
type?: 'separator';
|
|
click?: () => void;
|
|
}> {
|
|
return [
|
|
{
|
|
label: 'Open Overlay',
|
|
click: handlers.openOverlay,
|
|
},
|
|
{
|
|
label: 'Open Yomitan Settings',
|
|
click: handlers.openYomitanSettings,
|
|
},
|
|
{
|
|
label: 'Open Runtime Options',
|
|
click: handlers.openRuntimeOptions,
|
|
},
|
|
{
|
|
label: 'Configure Jellyfin',
|
|
click: handlers.openJellyfinSetup,
|
|
},
|
|
{
|
|
label: 'Configure AniList',
|
|
click: handlers.openAnilistSetup,
|
|
},
|
|
{ type: 'separator' },
|
|
{
|
|
label: 'Quit',
|
|
click: handlers.quitApp,
|
|
},
|
|
];
|
|
}
|