import { AiOutlineArrowLeft, AiOutlineCloudDownload } from 'react-icons/ai'; import { getAudioInfo, getUserInfo } from '@/lib/podcastApi'; import AudioPlayerControls from './AudioPlayerControls'; import PodcastTabs from './PodcastTabs'; import ShareButton from './ShareButton'; // 导入 ShareButton 组件 import { getTranslation } from '../i18n'; // 从正确路径导入 useTranslation import { headers } from 'next/headers'; // 导入 usePathname import { getTruePathFromHeaders } from '../lib/utils'; // 导入新函数 // 脚本解析函数 (与 page.tsx 中保持一致) const parseTranscript = ( transcript: { speaker_id: number; dialog: string }[] | undefined, podUsers: { role: string; code: string; name: string; usedname: string }[] | undefined, t: (key: string, options?: any) => string // 传递 t 函数 ) => { if (!transcript) return []; return transcript.map((item, index) => { let speakerName: string | null = null; if (podUsers && podUsers[item.speaker_id]) { speakerName = podUsers[item.speaker_id].usedname; // 使用 podUsers 中的 usedname 字段作为 speakerName } else { speakerName = `${t('podcastContent.speaker')} ${item.speaker_id}`; // 回退到 Speaker ID } return { id: index, speaker: speakerName, dialogue: item.dialog }; }); }; interface PodcastContentProps { fileName: string; lang: string; // 新增 lang 属性 } export default async function PodcastContent({ fileName, lang }: PodcastContentProps) { const { t } = await getTranslation(lang, 'components'); // 初始化 getTranslation const result = await getAudioInfo(fileName, lang); const truePath = await getTruePathFromHeaders(await headers(), lang); if (!result.success || !result.data || result.data.status!='completed') { return (
{t('podcastContent.cannotLoadPodcastDetails')}{result.error || t('podcastContent.unknownError')}
{t('podcastContent.returnToHomepage')}