初始化提交
This commit is contained in:
commit
887c1f449e
963 files changed
+166869
No files matched your search
@@ -0,0 +1,71 @@
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
import { CharacterIdentityCard } from "@/components/characters/CharacterIdentityCard";
|
||||
import { CharacterLifecycleBar } from "@/components/characters/CharacterLifecycleBar";
|
||||
import { ModelPolicyEditForm } from "@/components/characters/ModelPolicyEditForm";
|
||||
import { ProfileEditForm } from "@/components/characters/ProfileEditForm";
|
||||
import { PageContainer } from "@/components/layout/PageContainer";
|
||||
import { ErrorState } from "@/components/shared/StateViews";
|
||||
import { CharacterStatusBadge } from "@/components/ui/StatusBadge";
|
||||
|
||||
import { serverApi } from "@/lib/api/server-client";
|
||||
import { describeError } from "@/lib/utils/error";
|
||||
import { formatDateTime } from "@/lib/utils/format";
|
||||
import type { Character } from "@/types/api";
|
||||
|
||||
export const dynamic = "force-dynamic";
|
||||
|
||||
/**
|
||||
* 人物详情页:生命周期操作 + 档案编辑 + 模型策略编辑。
|
||||
* Server Component 预取 getCharacter;写操作后 router.refresh() 重新拉取,以服务端数据为准。
|
||||
*/
|
||||
export default async function CharacterDetailPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ characterId: string }>;
|
||||
}) {
|
||||
const { characterId } = await params;
|
||||
|
||||
let character = null;
|
||||
let error: string | null = null;
|
||||
try {
|
||||
character = await serverApi.get<Character>(`/characters/${characterId}`);
|
||||
} catch (e) {
|
||||
error = describeError(e);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<PageContainer title="人物详情">
|
||||
<ErrorState message={error} />
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
if (!character) return notFound();
|
||||
|
||||
return (
|
||||
<PageContainer
|
||||
title={character.display_name || character.name}
|
||||
description={`内部名称:${character.name} · 创建于 ${formatDateTime(character.created_at)}`}
|
||||
>
|
||||
<div className="mb-4 flex flex-wrap items-center gap-3">
|
||||
<CharacterStatusBadge status={character.status} />
|
||||
<CharacterLifecycleBar character={character} />
|
||||
<Link
|
||||
href={`/characters/${character.id}/materials`}
|
||||
className="ml-auto rounded-lg border border-border-glass bg-glass px-3 py-1 text-xs text-patina hover:underline"
|
||||
>
|
||||
资料与沉淀 →
|
||||
</Link>
|
||||
</div>
|
||||
|
||||
<CharacterIdentityCard character={character} />
|
||||
|
||||
<div className="mt-6 grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<ProfileEditForm character={character} />
|
||||
<ModelPolicyEditForm character={character} />
|
||||
</div>
|
||||
</PageContainer>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user