diff --git a/apps/desktop-client/src/renderer/lib/media-catalog.ts b/apps/desktop-client/src/renderer/lib/media-catalog.ts index 91255e8..98f1c43 100644 --- a/apps/desktop-client/src/renderer/lib/media-catalog.ts +++ b/apps/desktop-client/src/renderer/lib/media-catalog.ts @@ -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 ?? "未"; +} diff --git a/apps/desktop-client/src/renderer/views/HomeView.vue b/apps/desktop-client/src/renderer/views/HomeView.vue index d75616e..9c6fa68 100644 --- a/apps/desktop-client/src/renderer/views/HomeView.vue +++ b/apps/desktop-client/src/renderer/views/HomeView.vue @@ -4,21 +4,12 @@ import { DesktopOutlined, LinkOutlined, ClockCircleOutlined, AlertOutlined } fro import StatusBadge from "../components/StatusBadge.vue"; import { useDesktopRuntime } from "../composables/useDesktopRuntime"; -import { formatClock, formatRelativeTime, titleCaseToken } from "../lib/formatters"; +import { formatClock, formatRelativeTime } from "../lib/formatters"; +import { translateDesktopPlatform } from "../lib/media-catalog"; import { healthTone } from "../lib/runtime-ui"; function translatePlatform(platform: string) { - const map: Record = { - toutiaohao: "头条号", - bilibili: "哔哩哔哩", - xiaohongshu: "小红书", - douyin: "抖音", - kuaishou: "快手", - wechat_oa: "微信公众号", - baijiahao: "百家号", - zhihu: "知乎", - }; - return map[platform?.toLowerCase()] || titleCaseToken(platform); + return translateDesktopPlatform(platform); } function blockedAccountLabel(account: { authState: string; authReason: string | null }) { diff --git a/apps/desktop-client/src/renderer/views/PublishManagementView.vue b/apps/desktop-client/src/renderer/views/PublishManagementView.vue index bc2ca3b..e322216 100644 --- a/apps/desktop-client/src/renderer/views/PublishManagementView.vue +++ b/apps/desktop-client/src/renderer/views/PublishManagementView.vue @@ -14,8 +14,8 @@ import { computed, onMounted, onUnmounted, ref, watch } from "vue"; import StatusBadge from "../components/StatusBadge.vue"; import { useDesktopRuntime } from "../composables/useDesktopRuntime"; -import { formatDateTime, formatRelativeTime, titleCaseToken } from "../lib/formatters"; -import { desktopPublishMediaCatalog } from "../lib/media-catalog"; +import { formatDateTime, formatRelativeTime } from "../lib/formatters"; +import { desktopPlatformShortName, desktopPublishMediaCatalog, translateDesktopPlatform } from "../lib/media-catalog"; import { normalizePublisherErrorMessage } from "../../shared/publisher-errors"; const PAGE_SIZE = 10; @@ -52,7 +52,7 @@ function platformMeta(platform: string) { } function translatePlatform(platform: string) { - return platformMeta(platform)?.label || titleCaseToken(platform); + return platformMeta(platform)?.label || translateDesktopPlatform(platform); } function platformLogo(platform: string): string | null { @@ -64,7 +64,7 @@ function platformAccent(platform: string): string { } function platformShortName(platform: string): string { - return platformMeta(platform)?.shortName ?? titleCaseToken(platform).slice(0, 1); + return platformMeta(platform)?.shortName ?? desktopPlatformShortName(platform); } function statusLabel(status: DesktopTaskInfo["status"]): string { diff --git a/apps/desktop-client/src/renderer/views/TasksView.vue b/apps/desktop-client/src/renderer/views/TasksView.vue index 892f5c1..e8ae4e8 100644 --- a/apps/desktop-client/src/renderer/views/TasksView.vue +++ b/apps/desktop-client/src/renderer/views/TasksView.vue @@ -4,21 +4,12 @@ import { computed } from "vue"; import StatusBadge from "../components/StatusBadge.vue"; import SurfaceCard from "../components/SurfaceCard.vue"; import { useDesktopRuntime } from "../composables/useDesktopRuntime"; -import { formatRelativeTime, titleCaseToken } from "../lib/formatters"; +import { formatRelativeTime } from "../lib/formatters"; +import { translateDesktopPlatform } from "../lib/media-catalog"; import { taskTone } from "../lib/runtime-ui"; function translatePlatform(platform: string) { - const map: Record = { - toutiaohao: "头条号", - bilibili: "哔哩哔哩", - xiaohongshu: "小红书", - douyin: "抖音", - kuaishou: "快手", - wechat_oa: "微信公众号", - baijiahao: "百家号", - zhihu: "知乎", - }; - return map[platform?.toLowerCase()] || titleCaseToken(platform); + return translateDesktopPlatform(platform); } function translateTaskStatus(status: string) {