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:
@@ -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 ?? "未";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user