import type { Metadata } from "next"; import { cookies } from "next/headers"; import { fetchAdminEconomyStats, type EconomyStats, type PublicSettings } from "@/lib/api"; import { authCookieHeader } from "@/lib/cookies"; import { getMeCached, getPublicSettingsCached } from "@/lib/serverData"; import { isAdminOrAbove, isSuperOrOwner } from "@/lib/roles"; import Forbidden from "../Forbidden"; import PointsTabs from "./PointsTabs"; export const metadata: Metadata = { title: "积分管理", }; export default async function AdminPointsPage() { const cookie = authCookieHeader(await cookies()); const me = await getMeCached(cookie || undefined); if (!me.user || !isAdminOrAbove(me.user.role)) { return ; } const canManage = isSuperOrOwner(me.user.role); // 经济总览预取(管理员及以上可读);失败降级为空态,不阻塞规则/用户积分标签 let stats: Awaited> | null = null; try { stats = await fetchAdminEconomyStats(cookie); } catch { stats = null; } // 积分规则初始值(公开设置缓存,超管/站长的规则标签用) let settings: PublicSettings | null = null; if (canManage) { settings = await getPublicSettingsCached(); } return ( ); }