feat: 优化首页帖子列表并新增右侧栏最新注册组件
首页列表精简 meta 与统计展示,板块色标前移并淡化;有回复时显示最后回复人。右侧栏新增最新注册(4 列头像网格),友链改为标签块并排换行。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { User, UserPublic, UserActivityStats, Board, PostItem, Comment, RecentComment, ForumStats, TagCount, AdminDashboard, AdminSettings, ForumLimits, ForumLimitsPublic, PostDetailResponse, PostRevision, CommentRevision, MailConfig, OIDCConfig, OAuthClient, OAuthClientInput, GiteaProject, GiteaSyncConfig, StorageConfig, MediaListResult, SiteBranding, RegisterConfig, PrivateMessage, MessageConversation, PostReport, ReportReason, ReportStatus, BadgeDef, PointLedger, CheckInStatus, LotteryStatus, SitePage, SitePageSummary, PollView, PostLotteryView, FriendLinkApply } from './types';
|
||||
import type { User, UserPublic, UserActivityStats, Board, PostItem, Comment, RecentComment, RecentUser, ForumStats, TagCount, AdminDashboard, AdminSettings, ForumLimits, ForumLimitsPublic, PostDetailResponse, PostRevision, CommentRevision, MailConfig, OIDCConfig, OAuthClient, OAuthClientInput, GiteaProject, GiteaSyncConfig, StorageConfig, MediaListResult, SiteBranding, RegisterConfig, PrivateMessage, MessageConversation, PostReport, ReportReason, ReportStatus, BadgeDef, PointLedger, CheckInStatus, LotteryStatus, SitePage, SitePageSummary, PollView, PostLotteryView, FriendLinkApply } from './types';
|
||||
|
||||
const BASE = '';
|
||||
|
||||
@@ -52,6 +52,7 @@ export const api = {
|
||||
return request<{ comments: Comment[]; total: number }>(`/api/posts/${id}/comments${q}`);
|
||||
},
|
||||
recentComments: () => request<{ comments: RecentComment[] }>('/api/comments/recent'),
|
||||
recentUsers: () => request<{ users: RecentUser[] }>('/api/users/recent'),
|
||||
favorites: () => request<{ favorites: unknown[]; total: number }>('/api/favorites'),
|
||||
createBoard: (body: { name: string; description: string; sort_order: number; icon?: string; color_index?: number }) =>
|
||||
request<{ board: Board }>('/api/admin/boards', { method: 'POST', body: JSON.stringify(body) }),
|
||||
|
||||
@@ -106,6 +106,10 @@ export interface PostItem {
|
||||
view_count: number;
|
||||
comment_count: number;
|
||||
last_reply_at?: string;
|
||||
/** 最后回复用户(登录用户);与 last_reply_guest_nick 二选一 */
|
||||
last_reply_user?: User;
|
||||
/** 最后回复游客昵称 */
|
||||
last_reply_guest_nick?: string;
|
||||
created_at: string;
|
||||
updated_at?: string;
|
||||
board?: Board;
|
||||
@@ -187,7 +191,7 @@ export interface AdminDashboard {
|
||||
recent_posts: PostItem[];
|
||||
}
|
||||
|
||||
export type AsideWidgetId = 'tag_cloud' | 'recent_comments' | 'friend_links';
|
||||
export type AsideWidgetId = 'tag_cloud' | 'recent_comments' | 'recent_users' | 'friend_links';
|
||||
|
||||
export interface AsideWidget {
|
||||
id: AsideWidgetId;
|
||||
@@ -197,6 +201,7 @@ export interface AsideWidget {
|
||||
export const DEFAULT_ASIDE_WIDGETS: AsideWidget[] = [
|
||||
{ id: 'tag_cloud', enabled: false },
|
||||
{ id: 'recent_comments', enabled: false },
|
||||
{ id: 'recent_users', enabled: false },
|
||||
{ id: 'friend_links', enabled: true },
|
||||
];
|
||||
|
||||
@@ -500,6 +505,14 @@ export interface RecentComment {
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
/** 右栏「最新注册」用户 */
|
||||
export interface RecentUser {
|
||||
id: number;
|
||||
nickname: string;
|
||||
avatar: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
/** 站内私信 */
|
||||
export interface PrivateMessage {
|
||||
id: number;
|
||||
|
||||
@@ -1,45 +1,48 @@
|
||||
import { memo } from 'react';
|
||||
import { useNavigate } from 'react-router-dom';
|
||||
import { Eye, Image as ImageIcon, MessageCircle, ThumbsUp } from 'lucide-react';
|
||||
import { MessageCircle } from 'lucide-react';
|
||||
import BoardBadge from '@/components/BoardBadge';
|
||||
import FeaturedIcon from '@/components/FeaturedIcon';
|
||||
import UserLink from '@/components/UserLink';
|
||||
import type { PostItem } from '../api/types';
|
||||
import type { FeedSort } from './FeedSortBar';
|
||||
import { useForumLimits } from '../hooks/useForumLimits';
|
||||
import { formatTime } from '../utils/content';
|
||||
import { postPath } from '../utils/permalink';
|
||||
import { boardPath, postPath } from '../utils/permalink';
|
||||
import { toPostImageThumbSrc } from '../utils/postContent';
|
||||
import { excerptFromHTML, firstImageFromHTML } from '../utils/seoText';
|
||||
import { parseTags } from './TagInput';
|
||||
|
||||
interface Props {
|
||||
post: PostItem;
|
||||
sort?: FeedSort;
|
||||
/** 当前板块 id,>0 时隐藏行内板块色标(避免板块页重复) */
|
||||
boardId?: number;
|
||||
onSelect: (id: number) => void;
|
||||
}
|
||||
|
||||
function PostListItem({ post, sort = 'latest', onSelect }: Props) {
|
||||
function PostListItem({ post, sort = 'latest', boardId = 0, onSelect }: Props) {
|
||||
const nav = useNavigate();
|
||||
const { limits } = useForumLimits();
|
||||
const feedStyle = limits.feed_list_style ?? 'title';
|
||||
const showExcerpt = feedStyle === 'excerpt' || feedStyle === 'thumbnail';
|
||||
const showThumb = feedStyle === 'thumbnail';
|
||||
const titleOnly = feedStyle === 'title';
|
||||
|
||||
const initial = post.user?.nickname?.[0] || '?';
|
||||
const timeLabel = sort === 'reply'
|
||||
? (post.last_reply_at
|
||||
? `${formatTime(post.last_reply_at)} 回复`
|
||||
: '暂无回复')
|
||||
const timeLabel = sort === 'reply' && !post.last_reply_at
|
||||
? '暂无回复'
|
||||
: formatTime(post.created_at);
|
||||
const lastReplyName = post.last_reply_user?.nickname?.trim()
|
||||
|| post.last_reply_user?.username?.trim()
|
||||
|| post.last_reply_guest_nick?.trim()
|
||||
|| '';
|
||||
const showLastReply = !!post.last_reply_at && (!!post.last_reply_user || !!lastReplyName);
|
||||
const commentCount = post.comment_count ?? 0;
|
||||
const likeCount = post.like_count ?? 0;
|
||||
const viewCount = post.view_count ?? 0;
|
||||
const href = postPath(post.id);
|
||||
const firstImage = firstImageFromHTML(post.content || '');
|
||||
const thumbSrc = showThumb && firstImage ? toPostImageThumbSrc(firstImage) : null;
|
||||
const excerpt = showExcerpt ? excerptFromHTML(post.content || '', 60) : '';
|
||||
const showImageIcon = !!firstImage && !thumbSrc;
|
||||
const tagList = parseTags(post.tags || '').slice(0, 3);
|
||||
const showBoardBadge = !!post.board && boardId !== post.board.id;
|
||||
|
||||
const openPost = () => onSelect(post.id);
|
||||
const onKeyDown = (e: React.KeyboardEvent) => {
|
||||
@@ -108,57 +111,53 @@ function PostListItem({ post, sort = 'latest', onSelect }: Props) {
|
||||
|
||||
const metaLeft = (
|
||||
<div className="post-meta-left">
|
||||
<UserLink user={post.user} stopPropagation className="post-meta-author" showBadges={false} />
|
||||
<span className="post-meta-sep" aria-hidden>·</span>
|
||||
<span className="post-meta-time">{timeLabel}</span>
|
||||
{post.board && (
|
||||
<>
|
||||
<span className="post-meta-sep" aria-hidden>·</span>
|
||||
<span className="post-meta-board">{post.board.name}</span>
|
||||
</>
|
||||
)}
|
||||
{tagList.map(t => (
|
||||
{showBoardBadge && post.board && (
|
||||
<button
|
||||
key={t}
|
||||
type="button"
|
||||
className="post-list-tag"
|
||||
title={`筛选标签:${t}`}
|
||||
className="post-list-board-btn"
|
||||
title={`进入板块:${post.board.name}`}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation();
|
||||
nav(`/?tag=${encodeURIComponent(t)}`);
|
||||
nav(boardPath(post.board!.id, limits));
|
||||
}}
|
||||
>
|
||||
#{t}
|
||||
<BoardBadge board={post.board} className="post-list-board-badge" />
|
||||
</button>
|
||||
))}
|
||||
)}
|
||||
<UserLink user={post.user} stopPropagation className="post-meta-author" showBadges={false} />
|
||||
<span className="post-meta-sep post-meta-sep--before-time" aria-hidden>·</span>
|
||||
<span className="post-meta-time post-meta-time--created">{timeLabel}</span>
|
||||
{showLastReply && (
|
||||
<span className="post-meta-last-reply">
|
||||
<span className="post-meta-last-reply-arrow" aria-hidden>←</span>
|
||||
{post.last_reply_user ? (
|
||||
<UserLink
|
||||
user={post.last_reply_user}
|
||||
stopPropagation
|
||||
className="post-meta-last-reply-user"
|
||||
showBadges={false}
|
||||
/>
|
||||
) : (
|
||||
<span className="post-meta-last-reply-user">{lastReplyName}</span>
|
||||
)}
|
||||
<span className="post-meta-last-reply-time">{formatTime(post.last_reply_at!)}</span>
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
const stats = (
|
||||
<div className="post-stats">
|
||||
{showImageIcon && (
|
||||
<span className="post-stat post-stat--media" title="含图片">
|
||||
<ImageIcon aria-hidden />
|
||||
</span>
|
||||
)}
|
||||
<span className={`post-stat${commentCount === 0 ? ' post-stat--zero' : ''}`} title="评论">
|
||||
<MessageCircle aria-hidden />
|
||||
{commentCount}
|
||||
</span>
|
||||
<span className={`post-stat${likeCount === 0 ? ' post-stat--zero' : ''}`} title="点赞">
|
||||
<ThumbsUp aria-hidden />
|
||||
{likeCount}
|
||||
</span>
|
||||
<span className={`post-stat${viewCount === 0 ? ' post-stat--zero' : ''}`} title="浏览">
|
||||
<Eye aria-hidden />
|
||||
{viewCount}
|
||||
</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<div
|
||||
className={`post-row post-row--v2${thumbSrc ? ' post-row--has-thumb' : ''}`}
|
||||
className={`post-row post-row--v2${titleOnly ? ' post-row--title-only' : ''}${thumbSrc ? ' post-row--has-thumb' : ''}`}
|
||||
role="link"
|
||||
tabIndex={0}
|
||||
onClick={openPost}
|
||||
|
||||
@@ -8,7 +8,7 @@ export function feedListRowEstimate(style: FeedListStyle): number {
|
||||
switch (style) {
|
||||
case 'excerpt': return 68;
|
||||
case 'thumbnail': return 72;
|
||||
default: return 52;
|
||||
default: return 64;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,13 +21,17 @@ interface Props {
|
||||
export default function PostListSkeleton({ count = 8, listStyle = 'title' }: Props) {
|
||||
const showExcerpt = listStyle === 'excerpt' || listStyle === 'thumbnail';
|
||||
const showThumb = listStyle === 'thumbnail';
|
||||
const titleOnly = listStyle === 'title';
|
||||
|
||||
return (
|
||||
<div className="post-list-skeleton" aria-busy="true" aria-label="加载中">
|
||||
{Array.from({ length: count }, (_, i) => {
|
||||
const hasThumb = showThumb && i % 3 === 0;
|
||||
return (
|
||||
<div key={i} className={`post-row post-row--v2 post-row--skeleton${hasThumb ? ' post-row--has-thumb' : ''}`}>
|
||||
<div
|
||||
key={i}
|
||||
className={`post-row post-row--v2 post-row--skeleton${titleOnly ? ' post-row--title-only' : ''}${hasThumb ? ' post-row--has-thumb' : ''}`}
|
||||
>
|
||||
<Skeleton className="skeleton--avatar skeleton--avatar-v2" />
|
||||
{hasThumb ? (
|
||||
<div className="post-main post-main--with-thumb">
|
||||
@@ -36,14 +40,15 @@ export default function PostListSkeleton({ count = 8, listStyle = 'title' }: Pro
|
||||
{showExcerpt && (
|
||||
<Skeleton className="skeleton--excerpt skeleton--excerpt-v2" style={{ width: `${72 + (i % 3) * 8}%` }} />
|
||||
)}
|
||||
<Skeleton className="skeleton--meta-line" style={{ width: `${45 + (i % 3) * 10}%` }} />
|
||||
<div className="post-meta-left post-meta-left--skeleton">
|
||||
<Skeleton className="skeleton--board-badge" />
|
||||
<Skeleton className="skeleton--meta-line" style={{ width: `${45 + (i % 3) * 10}%` }} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="post-aside">
|
||||
<Skeleton className="skeleton--thumb skeleton--thumb-tall" />
|
||||
<div className="post-stats">
|
||||
<Skeleton className="skeleton--stat" />
|
||||
<Skeleton className="skeleton--stat" />
|
||||
<Skeleton className="skeleton--stat" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,11 +61,12 @@ export default function PostListSkeleton({ count = 8, listStyle = 'title' }: Pro
|
||||
)}
|
||||
</div>
|
||||
<div className="post-meta">
|
||||
<Skeleton className="skeleton--meta-line" style={{ width: `${45 + (i % 3) * 10}%` }} />
|
||||
<div className="post-meta-left post-meta-left--skeleton">
|
||||
<Skeleton className="skeleton--board-badge" />
|
||||
<Skeleton className="skeleton--meta-line" style={{ width: `${45 + (i % 3) * 10}%` }} />
|
||||
</div>
|
||||
<div className="post-stats">
|
||||
<Skeleton className="skeleton--stat" />
|
||||
<Skeleton className="skeleton--stat" />
|
||||
<Skeleton className="skeleton--stat" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { useMemo } from 'react';
|
||||
import { ListTree, MessageCircle, Tags, Link2 } from 'lucide-react';
|
||||
import { ListTree, MessageCircle, Tags, Link2, UserPlus } from 'lucide-react';
|
||||
import { useLocation, useSearchParams, useNavigate } from 'react-router-dom';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import type { AsideWidget, RecentComment, TagCount, User, ForumStats, FriendLink } from '../api/types';
|
||||
import type { AsideWidget, RecentComment, RecentUser, TagCount, User, ForumStats, FriendLink } from '../api/types';
|
||||
import type { PostHeading } from '../utils/postHeadings';
|
||||
import { useSiteBranding } from '../hooks/useSiteBranding';
|
||||
import { formatShortDateTime, formatTime } from '../utils/content';
|
||||
@@ -25,6 +25,7 @@ export type PostDetailAside = {
|
||||
|
||||
interface Props {
|
||||
recentComments: RecentComment[];
|
||||
recentUsers: RecentUser[];
|
||||
tags?: TagCount[];
|
||||
tagsLoading?: boolean;
|
||||
stats?: ForumStats | null;
|
||||
@@ -53,8 +54,22 @@ function CommentSkeleton() {
|
||||
);
|
||||
}
|
||||
|
||||
function UserSkeleton() {
|
||||
return (
|
||||
<div className="widget-recent-users-grid" aria-busy="true" aria-label="用户加载中">
|
||||
{Array.from({ length: 8 }, (_, i) => (
|
||||
<div key={i} className="widget-recent-user-cell widget-recent-user-cell--skeleton">
|
||||
<Skeleton className="skeleton--recent-user-avatar" />
|
||||
<Skeleton className="skeleton--recent-user-name" style={{ width: `${48 + (i % 3) * 10}%` }} />
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default function RightPanel({
|
||||
recentComments,
|
||||
recentUsers,
|
||||
tags = [],
|
||||
tagsLoading = false,
|
||||
stats = null,
|
||||
@@ -69,6 +84,7 @@ export default function RightPanel({
|
||||
const [params] = useSearchParams();
|
||||
const activeTag = params.get('tag') || '';
|
||||
const commentList = recentComments?.slice(0, 6) ?? [];
|
||||
const userList = recentUsers?.slice(0, 8) ?? [];
|
||||
const friendLinks = (branding.friend_links ?? []).filter(
|
||||
(l: FriendLink) => l.name?.trim() && l.url?.trim(),
|
||||
);
|
||||
@@ -118,7 +134,7 @@ export default function RightPanel({
|
||||
申请
|
||||
</Button>
|
||||
</div>
|
||||
<div className="widget-card-body">
|
||||
<div className="widget-card-body widget-card-body--friend-links">
|
||||
{friendLinks.length === 0 ? (
|
||||
<div className="widget-empty">暂无友情链接</div>
|
||||
) : (
|
||||
@@ -126,7 +142,9 @@ export default function RightPanel({
|
||||
<ul className="widget-friend-links-list">
|
||||
{friendLinks.slice(0, 8).map((link: FriendLink) => (
|
||||
<li key={`${link.name}-${link.url}`}>
|
||||
<a href={link.url} target="_blank" rel="noopener noreferrer">{link.name}</a>
|
||||
<a href={link.url} target="_blank" rel="noopener noreferrer" title={link.name}>
|
||||
{link.name}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
@@ -212,6 +230,41 @@ export default function RightPanel({
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
case 'recent_users':
|
||||
return (
|
||||
<div key="recent_users" className="widget-card widget-card--users">
|
||||
<div className="widget-card-head">
|
||||
<UserPlus className="widget-card-icon widget-card-icon--users" aria-hidden />
|
||||
最新注册
|
||||
</div>
|
||||
<div className="widget-card-body widget-card-body--users">
|
||||
{loading && userList.length === 0 ? (
|
||||
<UserSkeleton />
|
||||
) : userList.length === 0 ? (
|
||||
<div className="widget-empty">暂无用户</div>
|
||||
) : (
|
||||
<div className="widget-recent-users-grid">
|
||||
{userList.map(item => (
|
||||
<UserLink
|
||||
key={item.id}
|
||||
user={{ id: item.id, nickname: item.nickname, avatar: item.avatar }}
|
||||
className="widget-recent-user-cell"
|
||||
showBadges={false}
|
||||
title={item.nickname}
|
||||
>
|
||||
<span className="widget-recent-user-avatar" aria-hidden>
|
||||
{item.avatar
|
||||
? <img src={item.avatar} alt="" loading="lazy" decoding="async" />
|
||||
: (item.nickname?.[0] || '?')}
|
||||
</span>
|
||||
<span className="widget-recent-user-name">{item.nickname}</span>
|
||||
</UserLink>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -263,7 +263,7 @@ export default function VirtualPostList({
|
||||
transform: `translateY(${offsetY}px)`,
|
||||
}}
|
||||
>
|
||||
<PostListItem post={post} sort={sort} onSelect={onSelect} />
|
||||
<PostListItem post={post} sort={sort} boardId={boardId} onSelect={onSelect} />
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
|
||||
@@ -10,6 +10,10 @@ const WIDGET_META: Record<AsideWidgetId, { label: string; hint: string }> = {
|
||||
label: '最新评论',
|
||||
hint: '在右侧栏展示最近回复',
|
||||
},
|
||||
recent_users: {
|
||||
label: '最新注册',
|
||||
hint: '在右侧栏展示最近注册的用户',
|
||||
},
|
||||
friend_links: {
|
||||
label: '友情链接',
|
||||
hint: '关闭后不在右侧栏展示,友链仍可在「友情链接」页面查看与申请',
|
||||
|
||||
@@ -14,9 +14,9 @@ import { useAuth } from '../hooks/useAuth';
|
||||
import { useTheme, useMediaQuery } from '../hooks/useTheme';
|
||||
import { useOverlayA11y, moveTabIndex } from '../hooks/useOverlayA11y';
|
||||
import { api } from '../api/client';
|
||||
import type { Board, RecentComment, ForumStats, TagCount, User } from '../api/types';
|
||||
import type { Board, RecentComment, RecentUser, ForumStats, TagCount, User } from '../api/types';
|
||||
import type { PostHeading } from '../utils/postHeadings';
|
||||
import { getCachedBoards, getCachedStats, getCachedRecentComments, getCachedTags, hasCachedAside, setCachedBoards, setCachedStats, setCachedRecentComments, setCachedTags } from '../utils/layoutCache';
|
||||
import { getCachedBoards, getCachedStats, getCachedRecentComments, getCachedRecentUsers, getCachedTags, hasCachedAside, setCachedBoards, setCachedStats, setCachedRecentComments, setCachedRecentUsers, setCachedTags } from '../utils/layoutCache';
|
||||
import Sidebar, { isNeutralSidebarRoute } from '../components/Sidebar';
|
||||
import RightPanel from '../components/RightPanel';
|
||||
import BackToTop from '../components/BackToTop';
|
||||
@@ -49,6 +49,7 @@ export default function MainLayout() {
|
||||
const [boards, setBoards] = useState<Board[]>(() => getCachedBoards());
|
||||
const [stats, setStats] = useState<ForumStats | null>(() => getCachedStats());
|
||||
const [recentComments, setRecentComments] = useState<RecentComment[]>(() => getCachedRecentComments());
|
||||
const [recentUsers, setRecentUsers] = useState<RecentUser[]>(() => getCachedRecentUsers());
|
||||
const [unreadMessages, setUnreadMessages] = useState(0);
|
||||
const [tags, setTags] = useState<TagCount[]>(() => getCachedTags());
|
||||
const [tagsLoading, setTagsLoading] = useState(() => getCachedTags().length === 0);
|
||||
@@ -82,6 +83,7 @@ export default function MainLayout() {
|
||||
const asideWidgets = useMemo(() => resolveAsideWidgets(forumLimits), [forumLimits]);
|
||||
const showTagCloud = asideWidgets.some(w => w.id === 'tag_cloud' && w.enabled);
|
||||
const showRecentComments = asideWidgets.some(w => w.id === 'recent_comments' && w.enabled);
|
||||
const showRecentUsers = asideWidgets.some(w => w.id === 'recent_users' && w.enabled);
|
||||
|
||||
const asideDrawerRef = useRef<HTMLElement>(null);
|
||||
const asideCloseRef = useRef<HTMLButtonElement>(null);
|
||||
@@ -241,6 +243,31 @@ export default function MainLayout() {
|
||||
};
|
||||
}, [needRecentComments]);
|
||||
|
||||
const needRecentUsers = needAsideData && showRecentUsers;
|
||||
useEffect(() => {
|
||||
if (!needRecentUsers) return;
|
||||
let cancelled = false;
|
||||
if (!asideEverLoaded.current && !hasCachedAside()) {
|
||||
setAsideLoading(true);
|
||||
}
|
||||
|
||||
api.recentUsers().then(d => {
|
||||
if (cancelled) return;
|
||||
const next = Array.isArray(d.users) ? d.users : [];
|
||||
setRecentUsers(next);
|
||||
setCachedRecentUsers(next);
|
||||
}).catch(() => {}).finally(() => {
|
||||
if (!cancelled) {
|
||||
asideEverLoaded.current = true;
|
||||
setAsideLoading(false);
|
||||
}
|
||||
});
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [needRecentUsers]);
|
||||
|
||||
const doSearch = () => {
|
||||
const kw = keyword.trim();
|
||||
const author = searchAuthor.trim();
|
||||
@@ -642,6 +669,7 @@ export default function MainLayout() {
|
||||
<aside className="aside-panel">
|
||||
<RightPanel
|
||||
recentComments={recentComments}
|
||||
recentUsers={recentUsers}
|
||||
tags={tags}
|
||||
tagsLoading={tagsLoading}
|
||||
stats={stats}
|
||||
@@ -757,6 +785,7 @@ export default function MainLayout() {
|
||||
<div className="aside-drawer-body">
|
||||
<RightPanel
|
||||
recentComments={recentComments}
|
||||
recentUsers={recentUsers}
|
||||
tags={tags}
|
||||
tagsLoading={tagsLoading}
|
||||
stats={stats}
|
||||
|
||||
@@ -2320,6 +2320,15 @@ body:has(.admin-topbar) .ptr-indicator {
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
/* 仅标题模式:略增行距,避免帖子贴得过紧 */
|
||||
.post-row--v2.post-row--title-only {
|
||||
padding: 12px 16px;
|
||||
}
|
||||
|
||||
.post-row--v2.post-row--title-only .post-main {
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
@@ -2434,6 +2443,7 @@ body:has(.admin-topbar) .ptr-indicator {
|
||||
|
||||
.post-row--v2 .post-title {
|
||||
font-size: 14px;
|
||||
font-weight: 400;
|
||||
line-height: 1.35;
|
||||
}
|
||||
|
||||
@@ -2447,6 +2457,7 @@ body:has(.admin-topbar) .ptr-indicator {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex-wrap: nowrap;
|
||||
gap: 8px;
|
||||
min-width: 0;
|
||||
font-size: 12px;
|
||||
@@ -2456,10 +2467,11 @@ body:has(.admin-topbar) .ptr-indicator {
|
||||
.post-row--v2 .post-meta-left {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex-wrap: wrap;
|
||||
flex-wrap: nowrap;
|
||||
gap: 0;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-author {
|
||||
@@ -2487,13 +2499,153 @@ body:has(.admin-topbar) .ptr-indicator {
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-board {
|
||||
.post-row--v2 .post-meta-last-reply {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 1;
|
||||
min-width: 0;
|
||||
margin-left: 6px;
|
||||
gap: 4px;
|
||||
color: var(--color-text-4);
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-last-reply-arrow {
|
||||
flex-shrink: 0;
|
||||
opacity: 0.75;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-last-reply-user {
|
||||
flex-shrink: 1;
|
||||
min-width: 0;
|
||||
max-width: 5rem;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--color-text-3);
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.post-row--v2 a.post-meta-last-reply-user:hover {
|
||||
color: var(--j13-green);
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-last-reply-time {
|
||||
flex-shrink: 0;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
/* 手机端 meta 精简:作者、回复人、一个时间(有回复则用回复时间) */
|
||||
@media (max-width: 768px) {
|
||||
.post-row--v2 .post-list-board-btn {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-left:has(.post-meta-last-reply) .post-meta-sep--before-time,
|
||||
.post-row--v2 .post-meta-left:has(.post-meta-last-reply) .post-meta-time--created {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-author {
|
||||
max-width: 4.5rem;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-meta-last-reply-user {
|
||||
max-width: 4.5rem;
|
||||
}
|
||||
}
|
||||
|
||||
/* 列表内板块色标(meta 行、用户名之前;颜色淡化) */
|
||||
.post-row--v2 .post-list-board-btn {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
flex-shrink: 0;
|
||||
max-width: 5rem;
|
||||
padding: 0;
|
||||
margin: 0 6px 0 0;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
cursor: pointer;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-list-board-badge {
|
||||
display: inline-block;
|
||||
max-width: 100%;
|
||||
padding: 0 5px;
|
||||
border-radius: 3px;
|
||||
font-size: 11px;
|
||||
font-weight: 400;
|
||||
line-height: 1.45;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-list-board-badge.board-badge--0 {
|
||||
color: color-mix(in srgb, var(--board-0-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-0-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--1 {
|
||||
color: color-mix(in srgb, var(--board-1-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-1-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--2 {
|
||||
color: color-mix(in srgb, var(--board-2-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-2-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--3 {
|
||||
color: color-mix(in srgb, var(--board-3-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-3-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--4 {
|
||||
color: color-mix(in srgb, var(--board-4-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-4-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--5 {
|
||||
color: color-mix(in srgb, var(--board-5-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-5-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--6 {
|
||||
color: color-mix(in srgb, var(--board-6-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-6-color) 9%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-badge.board-badge--7 {
|
||||
color: color-mix(in srgb, var(--board-7-color) 52%, var(--color-text-3, #64748b));
|
||||
background: color-mix(in srgb, var(--board-7-color) 9%, transparent);
|
||||
}
|
||||
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--0 {
|
||||
color: color-mix(in srgb, var(--board-0-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-0-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--1 {
|
||||
color: color-mix(in srgb, var(--board-1-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-1-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--2 {
|
||||
color: color-mix(in srgb, var(--board-2-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-2-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--3 {
|
||||
color: color-mix(in srgb, var(--board-3-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-3-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--4 {
|
||||
color: color-mix(in srgb, var(--board-4-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-4-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--5 {
|
||||
color: color-mix(in srgb, var(--board-5-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-5-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--6 {
|
||||
color: color-mix(in srgb, var(--board-6-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-6-color) 14%, transparent);
|
||||
}
|
||||
.post-row--v2 .post-list-board-btn:hover .post-list-board-badge.board-badge--7 {
|
||||
color: color-mix(in srgb, var(--board-7-color) 72%, var(--color-text-2, #475569));
|
||||
background: color-mix(in srgb, var(--board-7-color) 14%, transparent);
|
||||
}
|
||||
|
||||
.post-row--v2 .post-list-tag {
|
||||
@@ -2504,6 +2656,7 @@ body:has(.admin-topbar) .ptr-indicator {
|
||||
color: var(--color-text-4);
|
||||
font-size: 12px;
|
||||
max-width: 5rem;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.post-row--v2 .post-list-tag:hover {
|
||||
@@ -3108,6 +3261,26 @@ a.post-title:visited {
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.skeleton--board-badge {
|
||||
width: 2.5rem;
|
||||
height: 14px;
|
||||
border-radius: 3px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.post-meta-left--skeleton {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
min-width: 0;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.post-meta-left--skeleton .skeleton--meta-line {
|
||||
flex: 1;
|
||||
max-width: none;
|
||||
}
|
||||
|
||||
.skeleton--excerpt-v2 {
|
||||
height: 12px;
|
||||
}
|
||||
@@ -6354,6 +6527,7 @@ a.waline-comment-author:hover {
|
||||
.widget-card-icon--hot { color: #e74c3c; }
|
||||
.widget-card-icon--notice { color: #3498db; }
|
||||
.widget-card-icon--links { color: #2d6a4f; }
|
||||
.widget-card-icon--users { color: #8b5cf6; }
|
||||
|
||||
.widget-card-head--split {
|
||||
justify-content: space-between;
|
||||
@@ -6399,22 +6573,51 @@ a.waline-comment-author:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.widget-card-body--friend-links {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.widget-friend-links-list {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
display: grid;
|
||||
display: flex;
|
||||
flex-wrap: wrap;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.widget-friend-links-list li {
|
||||
max-width: 100%;
|
||||
}
|
||||
|
||||
.widget-friend-links-list a {
|
||||
color: var(--j13-link, var(--primary, #2d6a4f));
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
max-width: 100%;
|
||||
min-height: 26px;
|
||||
padding: 4px 8px;
|
||||
border: 1px solid var(--j13-border-light);
|
||||
border-radius: 4px;
|
||||
background: var(--j13-bg-block-muted);
|
||||
color: var(--color-text-2);
|
||||
text-decoration: none;
|
||||
font-size: 13px;
|
||||
font-size: 12px;
|
||||
line-height: 1.3;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
transition:
|
||||
border-color 0.15s ease,
|
||||
background 0.15s ease,
|
||||
color 0.15s ease;
|
||||
}
|
||||
|
||||
.widget-friend-links-list a:hover {
|
||||
text-decoration: underline;
|
||||
border-color: color-mix(in srgb, var(--j13-green) 35%, var(--j13-border-light));
|
||||
background: var(--j13-green-soft);
|
||||
color: var(--j13-green);
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.friend-link-site-info {
|
||||
@@ -7454,6 +7657,91 @@ a.user-link--avatar-only:focus-visible {
|
||||
outline: none;
|
||||
}
|
||||
|
||||
/* 最新注册:4 列网格,头像在上、昵称在下 */
|
||||
.widget-card-body--users {
|
||||
padding-top: 8px;
|
||||
}
|
||||
|
||||
.widget-recent-users-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
gap: 10px 6px;
|
||||
}
|
||||
|
||||
.widget-recent-user-cell {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
min-width: 0;
|
||||
padding: 4px 2px;
|
||||
border-radius: 6px;
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
|
||||
a.widget-recent-user-cell:hover,
|
||||
a.widget-recent-user-cell:focus-visible {
|
||||
background: var(--j13-bg-block-accent);
|
||||
text-decoration: none;
|
||||
color: inherit;
|
||||
}
|
||||
|
||||
.widget-recent-user-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
background: var(--j13-green);
|
||||
color: #fff;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
overflow: hidden;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.widget-recent-user-avatar img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.widget-recent-user-name {
|
||||
width: 100%;
|
||||
font-size: 11px;
|
||||
line-height: 1.3;
|
||||
text-align: center;
|
||||
color: var(--color-text-2);
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
a.widget-recent-user-cell:hover .widget-recent-user-name,
|
||||
a.widget-recent-user-cell:focus-visible .widget-recent-user-name {
|
||||
color: var(--j13-green);
|
||||
}
|
||||
|
||||
.widget-recent-user-cell--skeleton {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.skeleton--recent-user-avatar {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.skeleton--recent-user-name {
|
||||
height: 11px;
|
||||
width: 70%;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
a.widget-item-avatar.user-link {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { AsideWidget, AsideWidgetId, ForumLimits, ForumLimitsPublic } from '../api/types';
|
||||
import { DEFAULT_ASIDE_WIDGETS } from '../api/types';
|
||||
|
||||
const ASIDE_WIDGET_IDS: AsideWidgetId[] = ['tag_cloud', 'recent_comments', 'friend_links'];
|
||||
const ASIDE_WIDGET_IDS: AsideWidgetId[] = ['tag_cloud', 'recent_comments', 'recent_users', 'friend_links'];
|
||||
|
||||
/** 从 limits 解析右侧栏组件列表(兼容仅有布尔开关的旧数据) */
|
||||
export function resolveAsideWidgets(
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import type { Board, ForumStats, RecentComment, TagCount } from '../api/types';
|
||||
import type { Board, ForumStats, RecentComment, RecentUser, TagCount } from '../api/types';
|
||||
|
||||
const BOARDS_KEY = 'j13-cache-boards';
|
||||
const STATS_KEY = 'j13-cache-stats';
|
||||
const RECENT_COMMENTS_KEY = 'j13-cache-recent-comments';
|
||||
const RECENT_USERS_KEY = 'j13-cache-recent-users';
|
||||
const TAGS_KEY = 'j13-cache-tags';
|
||||
|
||||
function readJson<T>(key: string): T | null {
|
||||
@@ -38,6 +39,12 @@ export function getCachedRecentComments(): RecentComment[] {
|
||||
return Array.isArray(list) ? list : [];
|
||||
}
|
||||
|
||||
/** 读取缓存的最新注册用户 */
|
||||
export function getCachedRecentUsers(): RecentUser[] {
|
||||
const list = readJson<RecentUser[]>(RECENT_USERS_KEY);
|
||||
return Array.isArray(list) ? list : [];
|
||||
}
|
||||
|
||||
/** 读取缓存的标签云 */
|
||||
export function getCachedTags(): TagCount[] {
|
||||
const list = readJson<TagCount[]>(TAGS_KEY);
|
||||
@@ -47,7 +54,9 @@ export function getCachedTags(): TagCount[] {
|
||||
/** 右栏是否已有可展示的 session 缓存(含空列表) */
|
||||
export function hasCachedAside(): boolean {
|
||||
try {
|
||||
return sessionStorage.getItem(RECENT_COMMENTS_KEY) != null;
|
||||
return sessionStorage.getItem(RECENT_COMMENTS_KEY) != null
|
||||
|| sessionStorage.getItem(RECENT_USERS_KEY) != null
|
||||
|| sessionStorage.getItem(TAGS_KEY) != null;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
@@ -65,6 +74,10 @@ export function setCachedRecentComments(list: RecentComment[]) {
|
||||
writeJson(RECENT_COMMENTS_KEY, list);
|
||||
}
|
||||
|
||||
export function setCachedRecentUsers(list: RecentUser[]) {
|
||||
writeJson(RECENT_USERS_KEY, list);
|
||||
}
|
||||
|
||||
export function setCachedTags(tags: TagCount[]) {
|
||||
writeJson(TAGS_KEY, tags);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user