feat: 添加用户关注功能

- 新增 Follow 表和 User.bio 字段 (Prisma schema)
- 创建 follow 模块 (action-service-repository)
- 新增 FollowButton/FollowStats/UserList 组件
- 用户页面显示 bio、粉丝/关注数、关注按钮
- 新增 /users/[username]/followers 和 following 页面
- 添加 en-US/zh-CN i18n 翻译

⚠️ 需要运行: prisma migrate dev --name add_follow_and_bio
This commit is contained in:
2026-03-10 14:56:06 +08:00
parent abcae1b8d1
commit 683a4104ec
20 changed files with 940 additions and 145 deletions

View File

@@ -0,0 +1,44 @@
import { notFound } from "next/navigation";
import { getTranslations } from "next-intl/server";
import { PageLayout } from "@/components/ui/PageLayout";
import { UserList } from "@/components/follow/UserList";
import { actionGetUserProfileByUsername } from "@/modules/auth/auth-action";
import { actionGetFollowing } from "@/modules/follow/follow-action";
interface FollowingPageProps {
params: Promise<{ username: string }>;
}
export default async function FollowingPage({ params }: FollowingPageProps) {
const { username } = await params;
const t = await getTranslations("follow");
const userResult = await actionGetUserProfileByUsername({ username });
if (!userResult.success || !userResult.data) {
notFound();
}
const user = userResult.data;
const followingResult = await actionGetFollowing({
userId: user.id,
page: 1,
limit: 50,
});
const following = followingResult.success && followingResult.data
? followingResult.data.following.map((f) => f.user)
: [];
return (
<PageLayout>
<div className="bg-white rounded-lg shadow-md p-6">
<h1 className="text-2xl font-bold text-gray-800 mb-6">
{t("followingOf", { username: user.displayUsername || user.username || "User" })}
</h1>
<UserList users={following} emptyMessage={t("noFollowing")} />
</div>
</PageLayout>
);
}