35 lines
951 B
TypeScript
35 lines
951 B
TypeScript
|
|
import type { Metadata } from 'next';
|
||
|
|
import { notFound } from 'next/navigation';
|
||
|
|
import { publicApi } from '@/lib/services';
|
||
|
|
import { ManualLayout } from '@/components/front/ManualLayout';
|
||
|
|
|
||
|
|
export const revalidate = 60;
|
||
|
|
|
||
|
|
interface PageProps {
|
||
|
|
params: { id: string };
|
||
|
|
}
|
||
|
|
|
||
|
|
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
|
||
|
|
try {
|
||
|
|
const doc = await publicApi.getManualDetail(Number(params.id));
|
||
|
|
return { title: doc.title, description: doc.title };
|
||
|
|
} catch {
|
||
|
|
return { title: '使用手册' };
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
export default async function ManualDetailPage({ params }: PageProps) {
|
||
|
|
const id = Number(params.id);
|
||
|
|
if (!Number.isFinite(id)) notFound();
|
||
|
|
|
||
|
|
// 并行拉取树形菜单 + 当前文档详情
|
||
|
|
const [tree, doc] = await Promise.all([
|
||
|
|
publicApi.getManualTree(),
|
||
|
|
publicApi.getManualDetail(id).catch(() => null),
|
||
|
|
]);
|
||
|
|
|
||
|
|
if (!doc) notFound();
|
||
|
|
|
||
|
|
return <ManualLayout tree={tree} doc={doc} />;
|
||
|
|
}
|