feat: 实时消息与管理端运营能力

新增群聊/私信与公共 WebSocket 总线,站长用户内容档案,并将通知与待审角标改为推送驱动;同步精简管理仪表盘并修复主题换肤 DOM 冲突。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-15 22:58:16 +08:00
parent 29db9ae9b5
commit 42c395a864
55 changed files with 7607 additions and 346 deletions

View File

@@ -0,0 +1,36 @@
"use client";
import { useState } from "react";
import { useRouter } from "next/navigation";
import { MessageSquare } from "lucide-react";
import { apiOpenDirectChat } from "@/lib/api";
import { toast } from "@/lib/toast";
/** 用户主页:发起私聊 */
export default function StartDMButton({ userId }: { userId: number }) {
const router = useRouter();
const [loading, setLoading] = useState(false);
const start = async () => {
setLoading(true);
try {
const { room } = await apiOpenDirectChat(userId);
router.push(`/chat/${room.id}`);
} catch (e) {
toast(e instanceof Error ? e.message : "无法发起私聊");
} finally {
setLoading(false);
}
};
return (
<button
onClick={start}
disabled={loading}
className="btn btn-accent btn-sm gap-1.5"
>
<MessageSquare size={14} />
{loading ? "打开中…" : "私聊"}
</button>
);
}

View File

@@ -14,6 +14,7 @@ import PasswordForm from "./PasswordForm";
import Avatar from "@/components/Avatar";
import RoleBadge from "@/components/RoleBadge";
import { roleMeta } from "@/lib/roles";
import StartDMButton from "./StartDMButton";
interface UserPageProps {
params: Promise<{ id: string }>;
@@ -132,8 +133,8 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
/>
</div>
{/* 本人操作按钮 */}
{isOwner && (
{/* 本人操作按钮 / 访客私聊 */}
{isOwner ? (
<div className="absolute top-3 right-3 sm:top-4 sm:right-4 z-20 flex items-center gap-2">
<Link href={`/u/${id}?tab=settings`} className="btn btn-line btn-sm">
<PenLine size={13.5} />
@@ -148,7 +149,11 @@ export default async function UserPage({ params, searchParams }: UserPageProps)
<Shield size={14} />
</Link>
</div>
)}
) : currentUser ? (
<div className="absolute top-3 right-3 sm:top-4 sm:right-4 z-20">
<StartDMButton userId={data.user.id} />
</div>
) : null}
{/* 身份信息:纯文档流,头像 + 右侧文字 baseline 对齐 */}
<div className="relative z-10 px-5 sm:px-7 pt-5 sm:pt-6">