mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-08-05 19:21:35 -07:00
3a97239ade
- Add a changelog modal opened from tray "View Changelog" or the update notification's "What's New" button; renders in-player or in its own window like the help modal - Fetch changelog from the newest published release so newer-than-installed notes are visible, falling back to the bundled CHANGELOG.md on failure - Group versions by minor line (current expanded, older folded), badge the installed version, tag newer ones "New" - Support J/K/arrow navigation, Enter to fold/unfold, R to refetch, Esc to close - Add changelog parsing/semver-compare utils and changelog IPC channel/runtime; bundle CHANGELOG.md into packaged builds - Replace release/release-notes.md with changes/changelog-modal.md changeset entry
156 lines
3.9 KiB
TypeScript
156 lines
3.9 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 = {
|
|
platform?: string;
|
|
openSessionHelp: () => void;
|
|
openChangelog: () => void;
|
|
openTexthookerInBrowser: () => void;
|
|
showTexthookerPage: boolean;
|
|
openFirstRunSetup: () => void;
|
|
showFirstRunSetup: boolean;
|
|
openWindowsMpvLauncherSetup: () => void;
|
|
showWindowsMpvLauncherSetup: boolean;
|
|
openYomitanSettings: () => void;
|
|
openConfigSettings: () => void;
|
|
openSyncUi: () => void;
|
|
exportLogs: () => void;
|
|
openJellyfinSetup: () => void;
|
|
showJellyfinDiscovery: boolean;
|
|
jellyfinDiscoveryActive: boolean;
|
|
toggleJellyfinDiscovery: (checked: boolean) => void;
|
|
openAnilistSetup: () => void;
|
|
checkForUpdates: () => void;
|
|
quitApp: () => void;
|
|
};
|
|
|
|
type TrayMenuClickItem = {
|
|
checked?: boolean;
|
|
};
|
|
|
|
export function buildTrayMenuTemplateRuntime(handlers: TrayMenuActionHandlers): Array<{
|
|
label?: string;
|
|
type?: 'separator' | 'checkbox';
|
|
checked?: boolean;
|
|
enabled?: boolean;
|
|
click?: (menuItem?: TrayMenuClickItem) => void;
|
|
}> {
|
|
const jellyfinDiscoveryLabel =
|
|
handlers.platform === 'linux' && handlers.jellyfinDiscoveryActive
|
|
? '✓ Jellyfin Discovery'
|
|
: 'Jellyfin Discovery';
|
|
|
|
return [
|
|
{
|
|
label: 'Open Help',
|
|
click: handlers.openSessionHelp,
|
|
},
|
|
{
|
|
label: 'View Changelog',
|
|
click: handlers.openChangelog,
|
|
},
|
|
...(handlers.showTexthookerPage
|
|
? [
|
|
{
|
|
label: 'Open Texthooker',
|
|
click: handlers.openTexthookerInBrowser,
|
|
},
|
|
]
|
|
: []),
|
|
...(handlers.showFirstRunSetup
|
|
? [
|
|
{
|
|
label: 'Complete Setup',
|
|
click: handlers.openFirstRunSetup,
|
|
},
|
|
]
|
|
: []),
|
|
...(handlers.showWindowsMpvLauncherSetup
|
|
? [
|
|
{
|
|
label: 'Open SubMiner Setup',
|
|
click: handlers.openWindowsMpvLauncherSetup,
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
label: 'Open Yomitan Settings',
|
|
click: handlers.openYomitanSettings,
|
|
},
|
|
{
|
|
label: 'Open SubMiner Settings',
|
|
click: handlers.openConfigSettings,
|
|
},
|
|
{
|
|
label: 'Sync Stats && History',
|
|
click: handlers.openSyncUi,
|
|
},
|
|
{
|
|
label: 'Export Logs',
|
|
click: handlers.exportLogs,
|
|
},
|
|
{
|
|
label: 'Configure Jellyfin',
|
|
click: handlers.openJellyfinSetup,
|
|
},
|
|
...(handlers.showJellyfinDiscovery
|
|
? [
|
|
{
|
|
label: jellyfinDiscoveryLabel,
|
|
type: 'checkbox' as const,
|
|
checked: handlers.jellyfinDiscoveryActive,
|
|
enabled: true,
|
|
click: (menuItem?: TrayMenuClickItem) => {
|
|
const checked =
|
|
typeof menuItem?.checked === 'boolean'
|
|
? menuItem.checked
|
|
: !handlers.jellyfinDiscoveryActive;
|
|
handlers.toggleJellyfinDiscovery(checked);
|
|
},
|
|
},
|
|
]
|
|
: []),
|
|
{
|
|
label: 'Configure AniList',
|
|
click: handlers.openAnilistSetup,
|
|
},
|
|
{
|
|
label: 'Check for Updates',
|
|
click: handlers.checkForUpdates,
|
|
},
|
|
{ type: 'separator' },
|
|
{
|
|
label: 'Quit',
|
|
click: handlers.quitApp,
|
|
},
|
|
];
|
|
}
|