"use client" import { gql, useQuery } from '@apollo/client' import { use, useState } from 'react' import BlogViewer from '@/components/blog-viewer' import TableOfContents from '@/components/table-of-contents' import { cn } from '@/lib/utils' const BLOG = gql` query Blog($slug: String!) { blogBySlug(slug: $slug) { id title content } } ` export default function Page({ params }: { params: Promise<{ slug: string }> }) { // 使用 React.use() 来解包 params Promise const resolvedParams = use(params); const { slug } = resolvedParams; const [contentReady, setContentReady] = useState(false); const { data, loading, error } = useQuery(BLOG, { variables: { slug }, }) // 条件渲染处理 if (loading) return