feat: 完成社区首页功能迭代,新增首页聚合与工作台组件

本次提交实现了完整的社区首页功能:
1. 新增首页聚合接口与服务,包含社区统计、热门帖、活跃用户与板块数据
2. 实现帖子推荐排序、SSR缓存与点赞态同步逻辑
3. 重构导航与布局系统,新增工作台侧边栏与移动端适配
4. 优化主题色与UI样式,统一设计系统风格
5. 修复登录注册页自动跳转与组件状态同步问题
This commit is contained in:
2026-09-12 23:36:18 +08:00
parent 055688a6cf
commit bee06fa962
24 changed files with 1446 additions and 359 deletions

View File

@@ -18,18 +18,35 @@ function formatTime(dateStr: string) {
export default function PostRow({
post,
boardHref,
index = 0,
compact = false,
showViews = true,
showLike = true,
}: {
post: PostListItem;
index?: number;
boardHref?: boolean;
compact?: boolean;
showViews?: boolean;
showLike?: boolean;
}) {
return (
<div
className="group flex items-center gap-3 sm:gap-4 px-4 sm:px-5 py-4 border-t transition-colors hover:bg-[var(--panel-2)]"
style={{ borderColor: "var(--line)" }}
className="group relative flex items-center gap-3 sm:gap-4 px-4 sm:px-5 border-t transition-colors hover:bg-[var(--panel-2)] j13-fade-up"
style={{
borderColor: "var(--line)",
paddingTop: compact ? 13 : 16,
paddingBottom: compact ? 13 : 16,
animationDelay: `${Math.min(index, 9) * 35}ms`,
}}
>
<Link href={`/u/${post.user.id}`} className="shrink-0" aria-label={post.user.nickname}>
<Avatar name={post.user.nickname || post.user.username} size={42} />
<Link
href={`/u/${post.user.id}`}
className="shrink-0 above-link"
aria-label={post.user.nickname}
tabIndex={-1}
>
<Avatar name={post.user.nickname || post.user.username} size={compact ? 38 : 42} />
</Link>
<div className="flex-1 min-w-0">
@@ -39,7 +56,7 @@ export default function PostRow({
{post.recommended && <span className="badge-rec">推荐</span>}
</div>
)}
<Link href={`/post/${post.id}`}>
<Link href={`/post/${post.id}`} className="stretch-link" aria-label={post.title}>
<h3
className="font-semibold text-[15px] sm:text-[16px] leading-snug truncate transition-colors group-hover:text-[var(--accent)]"
style={{ color: "var(--ink)" }}
@@ -47,7 +64,7 @@ export default function PostRow({
{post.title}
</h3>
</Link>
<div className="meta flex items-center gap-2.5 mt-1.5 flex-wrap">
<div className="meta relative z-[2] flex items-center gap-2.5 mt-1.5 flex-wrap">
<Link
href={`/u/${post.user.id}`}
className="hover:text-[var(--accent)] transition-colors"
@@ -70,21 +87,28 @@ export default function PostRow({
</div>
</div>
<div className="flex items-center gap-2.5 sm:gap-3.5 shrink-0">
<span className="hidden sm:inline-flex items-center gap-1.5 meta" aria-label={`${post.comment_count} 条评论`}>
<div className="above-link flex items-center gap-2.5 sm:gap-3.5 shrink-0">
<span
className={`${showViews ? "hidden sm:inline-flex" : "inline-flex"} items-center gap-1.5 meta`}
aria-label={`${post.comment_count} 条评论`}
>
<IconComment size={15} />
{post.comment_count}
</span>
<span className="hidden md:inline-flex items-center gap-1.5 meta" aria-label={`${post.view_count} 次浏览`}>
<IconEye size={15} />
{post.view_count}
</span>
<LikeButton
postId={String(post.id)}
liked={post.liked}
likeCount={post.like_count}
variant="compact"
/>
{showViews && (
<span className="hidden md:inline-flex items-center gap-1.5 meta" aria-label={`${post.view_count} 次浏览`}>
<IconEye size={15} />
{post.view_count}
</span>
)}
{showLike && (
<LikeButton
postId={String(post.id)}
liked={post.liked}
likeCount={post.like_count}
variant="compact"
/>
)}
</div>
</div>
);