"use client"; import { useState, useEffect } from "react"; import Link from "next/link"; import { useParams } from "next/navigation"; import { ThemeToggle } from "@/app/components/ThemeToggle"; import { getTopicConfig } from "../config"; import { isPaid } from "@/app/cloudphone/lib/payment"; type TopicHeaderProps = { topicId: string; }; export function TopicHeader({ topicId }: TopicHeaderProps) { const [paid, setPaid] = useState(false); const config = getTopicConfig(topicId); useEffect(() => { setPaid(isPaid()); const onPayUpdate = () => setPaid(isPaid()); window.addEventListener("pay:updated", onPayUpdate); return () => window.removeEventListener("pay:updated", onPayUpdate); }, []); const ctaHref = config?.externalUrl ? config.externalUrl : paid ? "/cloudphone/course/0/0" : config?.payUrl ?? "/"; return (
🌍 异度星球
); }