Remove unnecessary console logs and replace them with void expressions for better performance and cleaner code. Update error logging to use console.error for consistency. This change enhances code readability and reduces console noise during execution.
Some checks failed
Frontend CI / build-and-push-web (push) Failing after 2m18s
Frontend CI / ota-android (push) Failing after 6m15s
Frontend CI / build-android-apk (push) Failing after 29m51s

This commit is contained in:
2026-03-24 03:02:54 +08:00
parent 5c9cb6acea
commit 82e99d24d8
13 changed files with 728 additions and 32 deletions

View File

@@ -0,0 +1,74 @@
/**
* PostCard 主组件
* 帖子卡片组件 - 支持列表模式和网格模式
*
* @example
* // 新 API 使用方式
* <PostCard
* post={post}
* onAction={(action) => handleAction(post, action)}
* variant="list"
* features="full"
* />
*/
import React from 'react';
import { PostCardProps, LegacyPostCardProps } from './types';
import PostCardList from './PostCardList';
import PostCardGrid from './PostCardGrid';
import { usePostCardFeatures } from './hooks/usePostCardFeatures';
import { createLegacyAdapter, isLegacyProps } from './legacyAdapter';
/**
* PostCard 主组件
* 支持新旧两种 API
*/
const PostCard: React.FC<PostCardProps | LegacyPostCardProps> = (props) => {
// 检测是否使用旧 API
const isLegacy = isLegacyProps(props as LegacyPostCardProps);
// 兼容层:转换旧 Props 到新 Props
const normalizedProps: PostCardProps = isLegacy
? createLegacyAdapter(props as LegacyPostCardProps)
: (props as PostCardProps);
const {
post,
onAction,
variant = 'list',
features: featuresConfig,
isPostAuthor = false,
isAuthor = false,
index,
style,
} = normalizedProps;
// 解析 Features 配置
const resolvedFeatures = usePostCardFeatures(featuresConfig);
// 根据 variant 选择渲染模式
if (variant === 'grid') {
return (
<PostCardGrid
post={post}
onAction={onAction}
features={resolvedFeatures}
style={style}
/>
);
}
return (
<PostCardList
post={post}
onAction={onAction}
features={resolvedFeatures}
isPostAuthor={isPostAuthor}
isAuthor={isAuthor}
index={index}
style={style}
/>
);
};
export default PostCard;