Files
jiang13-bbs/frontend/app/notifications/page.tsx
freefire 996a870015 feat: 新增站点公告系统与多项体验优化
此提交完成了以下核心功能与优化:
1. 新增站点公告全流程支持:包含公告模型、CRUD接口、管理后台页面、公告详情页与首页展示
2. 实现评论楼层化与回复嵌套:重构评论系统为树状结构,支持回复评论与层级限制
3. 添加用户在线状态追踪:异步更新用户最后活跃时间并做SQL限频
4. 优化用户体验:移动端浮动操作条、统一板块标签样式、用户页签到积分展示、注册即登录优化
5. 其他细节优化:SEO站点地图新增公告页、评论分页与统计、登录/注册表单增强等
2026-09-13 21:38:01 +08:00

65 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { redirect } from "next/navigation";
import Link from "next/link";
import { cookies } from "next/headers";
import { ChevronRight } from "lucide-react";
import { authCookieHeader } from "@/lib/cookies";
import { getMeCached } from "@/lib/serverData";
import { fetchNotifications } from "@/lib/api";
import Pagination from "@/components/Pagination";
import NotificationsClient from "./NotificationsClient";
interface NotificationsPageProps {
searchParams: Promise<{ page?: string }>;
}
// SSR 直出通知列表:F5 直接看到内容,不再先渲染"正在加载…"
export default async function NotificationsPage({ searchParams }: NotificationsPageProps) {
const sp = await searchParams;
const page = Math.max(1, parseInt(sp.page || "1", 10) || 1);
const cookie = authCookieHeader(await cookies());
const me = await getMeCached(cookie || undefined);
if (!me.user) {
redirect(`/login?redirect=${encodeURIComponent(`/notifications`)}`);
}
let data = null;
let loadError = false;
try {
data = await fetchNotifications(page, cookie);
} catch {
loadError = true;
}
return (
<div className="max-w-2xl mx-auto">
<nav className="meta mb-5 flex items-center gap-1.5 text-[13px]">
<Link href="/" className="hover:text-[var(--accent)] transition-colors">首页</Link>
<ChevronRight size={13} />
<span style={{ color: "var(--accent)" }}>通知中心</span>
</nav>
<h1 className="text-[26px] sm:text-[30px] font-extrabold tracking-tight mb-6" style={{ color: "var(--ink)" }}>
通知中心
</h1>
{loadError || !data ? (
<div className="panel text-center py-16 px-6" role="alert">
<p className="text-sm font-semibold" style={{ color: "var(--ink-2)" }}>通知加载失败</p>
<p className="meta mt-1.5 mb-4">网络异常,请稍后重试</p>
<Link href="/notifications" className="btn btn-line btn-sm">重新加载</Link>
</div>
) : (
<>
<NotificationsClient initialData={data} />
<Pagination
total={data.total}
page={data.page}
size={data.size}
basePath="/notifications"
/>
</>
)}
</div>
);
}