import type { Metadata } from "next"; import { Suspense } from "react"; import { cookies } from "next/headers"; import AdsAdmin from "./AdsAdmin"; import { authCookieHeader } from "@/lib/cookies"; import { fetchAdminAds, fetchAdminAdsConfig, fetchAdminSponsorsConfig, type AdConfig, type AdRecord, type SponsorsConfig, } from "@/lib/api"; import { getMeCached } from "@/lib/serverData"; import { hasPerm, PERMS } from "@/lib/roles"; import Forbidden from "../Forbidden"; export const metadata: Metadata = { title: "推广与赞助", }; export default async function AdminAdsPage() { const cookie = authCookieHeader(await cookies()); const me = await getMeCached(cookie || undefined); if (!me.user || !hasPerm(me.user, PERMS.ADS)) { return ; } let ads: AdRecord[] = []; let cfg: AdConfig | null = null; let sponsors: SponsorsConfig | null = null; let initError = ""; try { const [list, config, sp] = await Promise.all([ fetchAdminAds(cookie || undefined), fetchAdminAdsConfig(cookie || undefined), fetchAdminSponsorsConfig(cookie || undefined), ]); ads = list.ads ?? []; cfg = config; sponsors = sp; } catch (e) { initError = e instanceof Error ? e.message : "加载失败"; } return ( 加载中…

}>
); }