feat(admin): 独立后台壳、站点分析与聊天监管,公开站拆出主题切换与访问埋点

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 04:00:14 +08:00
parent cda5fad2e5
commit 9a55c2f6f2
41 changed files with 5655 additions and 1810 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -25,7 +25,8 @@ function parseStatus(v?: string): AdminContentStatus {
}
function parseKind(v?: string): ContentKind {
return v === "comments" ? "comments" : "posts";
if (v === "comments") return "comments";
return "posts";
}
interface ContentPageProps {
@@ -48,35 +49,37 @@ export default async function AdminContentPage({ searchParams }: ContentPageProp
let initialComments: AdminContentComment[] = [];
let initialCommentsTotal = 0;
let initError = "";
const [listSettled, counts] = await Promise.all([
initialKind === "comments"
? fetchAdminContentComments(1, initialStatus, cookie || undefined)
.then((res) => ({ ok: true as const, kind: "comments" as const, res }))
.catch((e) => ({
ok: false as const,
error: e instanceof Error ? e.message : "获取内容列表失败",
}))
: fetchAdminContentPosts(1, initialStatus, cookie || undefined)
.then((res) => ({ ok: true as const, kind: "posts" as const, res }))
.catch((e) => ({
ok: false as const,
error: e instanceof Error ? e.message : "获取内容列表失败",
})),
fetchAdminContentCounts(cookie || undefined),
]);
if (listSettled.ok) {
if (listSettled.kind === "posts") {
initialPosts = listSettled.res.posts;
initialPostsTotal = listSettled.res.total;
} else {
initialComments = listSettled.res.comments;
initialCommentsTotal = listSettled.res.total;
}
} else {
initError = listSettled.error;
}
const settings = await getPublicSettingsCached();
// PC 双栏同时展示:SSR 并行预取帖子与评论
const [postsSettled, commentsSettled, counts, settings] = await Promise.all([
fetchAdminContentPosts(1, initialStatus, cookie || undefined)
.then((res) => ({ ok: true as const, res }))
.catch((e) => ({
ok: false as const,
error: e instanceof Error ? e.message : "获取帖子失败",
})),
fetchAdminContentComments(1, initialStatus, cookie || undefined)
.then((res) => ({ ok: true as const, res }))
.catch((e) => ({
ok: false as const,
error: e instanceof Error ? e.message : "获取评论失败",
})),
fetchAdminContentCounts(cookie || undefined),
getPublicSettingsCached(),
]);
if (postsSettled.ok) {
initialPosts = postsSettled.res.posts;
initialPostsTotal = postsSettled.res.total;
} else {
initError = postsSettled.error;
}
if (commentsSettled.ok) {
initialComments = commentsSettled.res.comments;
initialCommentsTotal = commentsSettled.res.total;
} else if (!initError) {
initError = commentsSettled.error;
}
return (
<ContentAdmin