Merge remote-tracking branch 'origin/master' into feature/adap-pc
This commit is contained in:
@@ -20,6 +20,7 @@ import Avatar from '../common/Avatar';
|
||||
import { ImageGrid, ImageGridItem, SmartImage } from '../common';
|
||||
import VotePreview from './VotePreview';
|
||||
import { useResponsive, useResponsiveValue } from '../../hooks/useResponsive';
|
||||
import { getPreviewImageUrl, ImageDisplayMode } from '../../utils/imageHelper';
|
||||
|
||||
interface PostCardProps {
|
||||
post: Post;
|
||||
@@ -206,6 +207,8 @@ const PostCard: React.FC<PostCardProps> = ({
|
||||
id: img.id,
|
||||
url: img.url,
|
||||
thumbnail_url: img.thumbnail_url,
|
||||
preview_url: img.preview_url,
|
||||
preview_url_large: img.preview_url_large,
|
||||
width: img.width,
|
||||
height: img.height,
|
||||
}));
|
||||
@@ -224,6 +227,8 @@ const PostCard: React.FC<PostCardProps> = ({
|
||||
borderRadius={imageBorderRadius}
|
||||
showMoreOverlay={true}
|
||||
onImagePress={onImagePress}
|
||||
displayMode={variant === 'grid' ? 'grid' : 'list'}
|
||||
usePreview={true}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
@@ -335,6 +340,11 @@ const PostCard: React.FC<PostCardProps> = ({
|
||||
const aspectRatios = [0.7, 0.75, 0.8, 0.85, 0.9, 1, 1.1, 1.2];
|
||||
const aspectRatio = aspectRatios[hash % aspectRatios.length];
|
||||
|
||||
// 获取封面图预览 URL
|
||||
const coverUrl = hasImage
|
||||
? getPreviewImageUrl(coverImage, 'grid')
|
||||
: '';
|
||||
|
||||
// 获取正文预览(无图时显示)
|
||||
const getContentPreview = (content: string | undefined | null): string => {
|
||||
if (!content) return '';
|
||||
@@ -369,9 +379,10 @@ const PostCard: React.FC<PostCardProps> = ({
|
||||
onPress={() => onImagePress?.(post.images || [], 0)}
|
||||
>
|
||||
<SmartImage
|
||||
source={{ uri: coverImage.thumbnail_url || coverImage.url || '' }}
|
||||
source={{ uri: coverUrl }}
|
||||
style={[styles.gridCoverImage, { aspectRatio }]}
|
||||
resizeMode="cover"
|
||||
usePreview={true}
|
||||
/>
|
||||
</TouchableOpacity>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user