- 新增徽章系统:badge 服务与 handler、管理端配置页、BadgeChip/LevelBadge 展示组件 - 新增等级模型:model/level 及前端 levels 元数据 - 管理端经济模块拆分为 points/badges/levels 独立页面,EconomySettings 迁入设置 - 积分、签到、评论等服务适配等级与徽章逻辑
45 lines
1.4 KiB
TypeScript
45 lines
1.4 KiB
TypeScript
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 <Forbidden text="积分管理仅管理员及以上可查看。" />;
|
|
}
|
|
|
|
const canManage = isSuperOrOwner(me.user.role);
|
|
|
|
// 经济总览预取(管理员及以上可读);失败降级为空态,不阻塞规则/用户积分标签
|
|
let stats: Awaited<ReturnType<typeof fetchAdminEconomyStats>> | null = null;
|
|
try {
|
|
stats = await fetchAdminEconomyStats(cookie);
|
|
} catch {
|
|
stats = null;
|
|
}
|
|
|
|
// 积分规则初始值(公开设置缓存,超管/站长的规则标签用)
|
|
let settings: PublicSettings | null = null;
|
|
if (canManage) {
|
|
settings = await getPublicSettingsCached();
|
|
}
|
|
|
|
return (
|
|
<PointsTabs
|
|
stats={stats}
|
|
settings={settings}
|
|
canManage={canManage}
|
|
/>
|
|
);
|
|
}
|