完善站点运营设置:分路由管理、登录可见评论、邮件模板内联与关闭注册 SSR。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -83,7 +83,9 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
|
||||
const me = await getMeCached(cookie || undefined);
|
||||
const settings = await getPublicSettingsCached();
|
||||
const allowComments = settings.allow_comments !== false;
|
||||
const commentsRequireLogin = settings.comments_require_login === true;
|
||||
const allowMessages = settings.allow_messages !== false;
|
||||
const canReadComments = allowComments && (!commentsRequireLogin || !!me.user);
|
||||
|
||||
let data: UserProfile;
|
||||
try {
|
||||
@@ -108,12 +110,12 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
|
||||
const currentUser = me.user;
|
||||
let effectiveTab: UserTab =
|
||||
(tab === "settings" || tab === "security") && !isOwner ? "posts" : tab;
|
||||
if (!allowComments && effectiveTab === "comments") effectiveTab = "posts";
|
||||
if (!canReadComments && effectiveTab === "comments") effectiveTab = "posts";
|
||||
|
||||
// 评论 tab:SSR 直出对应分页
|
||||
let commentData: UserCommentsResponse | null = null;
|
||||
let commentError = false;
|
||||
if (allowComments && effectiveTab === "comments") {
|
||||
if (canReadComments && effectiveTab === "comments") {
|
||||
try {
|
||||
commentData = await fetchUserComments(id, page);
|
||||
} catch {
|
||||
@@ -147,7 +149,7 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
|
||||
// 导航项(桌面左栏 / 移动 chips 共用定义)
|
||||
const navItems: { key: UserTab; label: string; count?: number; icon: React.ReactNode; ownerOnly?: boolean }[] = [
|
||||
{ key: "posts", label: "发帖", count: data.stats.post_count, icon: <FileText size={15} /> },
|
||||
...(allowComments
|
||||
...(canReadComments
|
||||
? [{ key: "comments" as const, label: "评论", count: data.stats.comment_count, icon: <MessageCircle size={15} /> }]
|
||||
: []),
|
||||
{ key: "settings", label: "资料设置", icon: <Settings size={15} />, ownerOnly: true },
|
||||
@@ -157,7 +159,7 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
|
||||
const tabHref = (t: UserTab) => (t === "posts" ? `/u/${id}` : `/u/${id}?tab=${t}`);
|
||||
|
||||
const profileQuery: Record<string, string | number> = {};
|
||||
if (allowComments && effectiveTab === "comments") profileQuery.tab = "comments";
|
||||
if (canReadComments && effectiveTab === "comments") profileQuery.tab = "comments";
|
||||
if (page > 1) profileQuery.page = page;
|
||||
const profileLd =
|
||||
effectiveTab === "settings" || effectiveTab === "security"
|
||||
@@ -274,7 +276,7 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
|
||||
<span className="tabular-nums font-semibold" style={{ color: "var(--ink)" }}>{data.stats.post_count}</span>
|
||||
{" "}帖子
|
||||
</span>
|
||||
{allowComments && (
|
||||
{canReadComments && (
|
||||
<>
|
||||
<span aria-hidden className="mx-1.5">·</span>
|
||||
<span>
|
||||
|
||||
Reference in New Issue
Block a user