feat(admin): 完善站点设置、内容回收站与后台菜单分组
新增站点设置与内容管理(含已删除恢复/清除),用户页改用独有运营指标,并按概览/内容/成员与经济/站点重组侧栏。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
56
frontend/app/admin/content/page.tsx
Normal file
56
frontend/app/admin/content/page.tsx
Normal file
@@ -0,0 +1,56 @@
|
||||
import type { Metadata } from "next";
|
||||
import { cookies } from "next/headers";
|
||||
import { authCookieHeader } from "@/lib/cookies";
|
||||
import {
|
||||
fetchAdminContentCounts,
|
||||
fetchAdminContentPosts,
|
||||
type AdminContentPost,
|
||||
} from "@/lib/api";
|
||||
import { getMeCached, getPublicSettingsCached } from "@/lib/serverData";
|
||||
import { canModerateAny, isSuperOrOwner } from "@/lib/roles";
|
||||
import Forbidden from "../Forbidden";
|
||||
import ContentAdmin from "./ContentAdmin";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "内容管理",
|
||||
};
|
||||
|
||||
export default async function AdminContentPage() {
|
||||
const cookie = authCookieHeader(await cookies());
|
||||
const me = await getMeCached(cookie || undefined);
|
||||
if (!me.user || !canModerateAny(me.user)) {
|
||||
return <Forbidden text="你所在的角色没有内容管理权限,或尚未被授权任何板块。" />;
|
||||
}
|
||||
|
||||
let initialPosts: AdminContentPost[] = [];
|
||||
let initialTotal = 0;
|
||||
let initError = "";
|
||||
const [postsSettled, counts] = await Promise.all([
|
||||
fetchAdminContentPosts(1, "live", cookie || undefined)
|
||||
.then((res) => ({ ok: true as const, res }))
|
||||
.catch((e) => ({
|
||||
ok: false as const,
|
||||
error: e instanceof Error ? e.message : "获取内容列表失败",
|
||||
})),
|
||||
fetchAdminContentCounts(cookie || undefined),
|
||||
]);
|
||||
if (postsSettled.ok) {
|
||||
initialPosts = postsSettled.res.posts;
|
||||
initialTotal = postsSettled.res.total;
|
||||
} else {
|
||||
initError = postsSettled.error;
|
||||
}
|
||||
|
||||
const settings = await getPublicSettingsCached();
|
||||
|
||||
return (
|
||||
<ContentAdmin
|
||||
initialPosts={initialPosts}
|
||||
initialPostsTotal={initialTotal}
|
||||
initialCounts={counts}
|
||||
initError={initError}
|
||||
canConfigureSettings={isSuperOrOwner(me.user.role)}
|
||||
initialSettings={settings}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user