- 新增 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
45 lines
1.3 KiB
TypeScript
45 lines
1.3 KiB
TypeScript
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 { actionGetFollowers } from "@/modules/follow/follow-action";
|
|
|
|
interface FollowersPageProps {
|
|
params: Promise<{ username: string }>;
|
|
}
|
|
|
|
export default async function FollowersPage({ params }: FollowersPageProps) {
|
|
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 followersResult = await actionGetFollowers({
|
|
userId: user.id,
|
|
page: 1,
|
|
limit: 50,
|
|
});
|
|
|
|
const followers = followersResult.success && followersResult.data
|
|
? followersResult.data.followers.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("followersOf", { username: user.displayUsername || user.username || "User" })}
|
|
</h1>
|
|
<UserList users={followers} emptyMessage={t("noFollowers")} />
|
|
</div>
|
|
</PageLayout>
|
|
);
|
|
}
|