- 新增管理端板块管理页面与后端接口(admin_board) - 新增旧版数据导入:legacyimport 服务、导入面板、importusers 命令行工具 - 聊天用户卡片、板块图标等 UI 组件与界面优化 - 补充 about/公告/1Panel 部署等文档 - gitignore 排除 dist/ 构建产物与 .agents/ 本地工具目录
55 lines
1.7 KiB
TypeScript
55 lines
1.7 KiB
TypeScript
import { cookies } from "next/headers";
|
|
import { notFound, redirect } from "next/navigation";
|
|
import { authCookieHeader } from "@/lib/cookies";
|
|
import { getMeCached } from "@/lib/serverData";
|
|
import { fetchPostDetail } from "@/lib/api";
|
|
import { canModerateBoard } from "@/lib/roles";
|
|
import EditPostClient from "./EditPostClient";
|
|
|
|
interface PageProps {
|
|
params: Promise<{ id: string }>;
|
|
}
|
|
|
|
export default async function EditPostPage({ params }: PageProps) {
|
|
const { id } = await params;
|
|
const cookie = authCookieHeader(await cookies());
|
|
const me = await getMeCached(cookie || undefined);
|
|
if (!me.user) {
|
|
redirect(`/login?redirect=${encodeURIComponent(`/post/${id}/edit`)}`);
|
|
}
|
|
|
|
let post: Awaited<ReturnType<typeof fetchPostDetail>>["post"];
|
|
try {
|
|
({ post } = await fetchPostDetail(id, cookie));
|
|
} catch {
|
|
notFound();
|
|
}
|
|
|
|
const allowed =
|
|
me.user.id === post.user.id ||
|
|
canModerateBoard(me.user, post.board_id);
|
|
if (!allowed) {
|
|
redirect(`/post/${id}`);
|
|
}
|
|
|
|
return (
|
|
<div className="j13-compose-page w-full">
|
|
<EditPostClient
|
|
postId={post.id}
|
|
initialTitle={post.title}
|
|
initialContent={post.content}
|
|
initialTags={post.tags || ""}
|
|
initialPostType={post.post_type}
|
|
initialTypeMeta={post.type_meta}
|
|
initialAttachments={post.attachments || []}
|
|
canEditPollOptions={post.poll?.can_edit_options !== false}
|
|
canEditLotteryPrizes={post.lottery?.can_edit_prizes !== false}
|
|
boardName={post.board?.name || "未知板块"}
|
|
boardId={post.board_id}
|
|
boardColorIndex={post.board?.color_index ?? 0}
|
|
boardIcon={post.board?.icon}
|
|
/>
|
|
</div>
|
|
);
|
|
}
|