关闭后前台隐藏私聊/群聊入口并由后端拦截;同步去掉公告页重复计数胶囊。 Co-authored-by: Cursor <cursoragent@cursor.com>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import { redirect } from "next/navigation";
|
|
import { cookies } from "next/headers";
|
|
import type { Metadata } from "next";
|
|
import { authCookieHeader } from "@/lib/cookies";
|
|
import { getMeCached, getPublicSettingsCached } from "@/lib/serverData";
|
|
import { fetchChatRooms } from "@/lib/api";
|
|
import ChatShell from "./ChatShell";
|
|
import MessagesUnsupported from "@/components/MessagesUnsupported";
|
|
|
|
export const metadata: Metadata = {
|
|
title: "消息",
|
|
description: "私聊与群聊,实时交流。",
|
|
};
|
|
|
|
export default async function ChatListPage() {
|
|
if ((await getPublicSettingsCached()).allow_messages === false) {
|
|
return <MessagesUnsupported />;
|
|
}
|
|
const cookie = authCookieHeader(await cookies());
|
|
const me = await getMeCached(cookie || undefined);
|
|
if (!me.user) {
|
|
redirect(`/login?redirect=${encodeURIComponent("/chat")}`);
|
|
}
|
|
|
|
let rooms: Awaited<ReturnType<typeof fetchChatRooms>>["rooms"] = [];
|
|
try {
|
|
const data = await fetchChatRooms(1, 50, "", cookie, "joined");
|
|
rooms = data.rooms || [];
|
|
} catch {
|
|
rooms = [];
|
|
}
|
|
|
|
return (
|
|
<ChatShell meId={me.user.id} initialRooms={rooms} activeRoomId={null} />
|
|
);
|
|
}
|