refactor(desktop/renderer): centralize platform label and short-name lookup

Move the per-platform translation map out of HomeView/TasksView and the
titleCaseToken fallback out of PublishManagementView into shared helpers
on media-catalog. Single source of truth keeps renderer views consistent
with the binding catalog when new platforms ship.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-29 17:12:05 +08:00
parent 426e94dd6b
commit b59435dec5
4 changed files with 23 additions and 28 deletions
@@ -169,3 +169,16 @@ export const desktopMonitoringMediaCatalog: DesktopMediaDefinition[] = aiPlatfor
}));
export const desktopMediaCatalog = [...desktopPublishMediaCatalog, ...desktopMonitoringMediaCatalog];
export function getDesktopMediaDefinition(platform: string): DesktopMediaDefinition | null {
const key = (platform ?? "").toLowerCase();
return desktopMediaCatalog.find((item) => item.id === key) ?? null;
}
export function translateDesktopPlatform(platform: string): string {
return getDesktopMediaDefinition(platform)?.label ?? "未知平台";
}
export function desktopPlatformShortName(platform: string): string {
return getDesktopMediaDefinition(platform)?.shortName ?? "未";
}