feat: 后台增加开放消息开关

关闭后前台隐藏私聊/群聊入口并由后端拦截;同步去掉公告页重复计数胶囊。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-17 04:16:10 +08:00
parent 9a55c2f6f2
commit 4b93739468
18 changed files with 275 additions and 91 deletions

View File

@@ -2,10 +2,11 @@ import type { Metadata } from "next";
import { notFound, redirect } from "next/navigation";
import { cookies } from "next/headers";
import { authCookieHeader } from "@/lib/cookies";
import { getMeCached } from "@/lib/serverData";
import { getMeCached, getPublicSettingsCached } from "@/lib/serverData";
import { fetchChatRoom, fetchChatMessages, fetchChatRooms } from "@/lib/api";
import ChatShell from "../ChatShell";
import ChatRoomClient from "./ChatRoomClient";
import MessagesUnsupported from "@/components/MessagesUnsupported";
interface PageProps {
params: Promise<{ id: string }>;
@@ -13,6 +14,9 @@ interface PageProps {
export async function generateMetadata({ params }: PageProps): Promise<Metadata> {
const { id } = await params;
if ((await getPublicSettingsCached()).allow_messages === false) {
return { title: "本站不支持消息" };
}
try {
const { room } = await fetchChatRoom(id, authCookieHeader(await cookies()));
const title =
@@ -27,6 +31,9 @@ export async function generateMetadata({ params }: PageProps): Promise<Metadata>
export default async function ChatRoomPage({ params }: PageProps) {
const { id } = await params;
if ((await getPublicSettingsCached()).allow_messages === false) {
return <MessagesUnsupported />;
}
const cookie = authCookieHeader(await cookies());
const me = await getMeCached(cookie || undefined);
if (!me.user) {

View File

@@ -2,9 +2,10 @@ import { redirect } from "next/navigation";
import { cookies } from "next/headers";
import type { Metadata } from "next";
import { authCookieHeader } from "@/lib/cookies";
import { getMeCached } from "@/lib/serverData";
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: "消息",
@@ -12,6 +13,9 @@ export const metadata: Metadata = {
};
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) {