修复头像和用户名bug,增加视频预览功能
Change-Id: I26087f826d29106a3db9428329946ff374c867bf
diff --git a/Merge/front/src/components/PostDetailJWLLL.jsx b/Merge/front/src/components/PostDetailJWLLL.jsx
index d598a72..01f64b5 100644
--- a/Merge/front/src/components/PostDetailJWLLL.jsx
+++ b/Merge/front/src/components/PostDetailJWLLL.jsx
@@ -5,6 +5,7 @@
import { getUserInfo } from '../utils/auth'
import FollowButton from './FollowButton'
import postsAPI from '../api/posts_api'
+import MediaPreview from './MediaPreview'
import '../style/PostDetail.css'
import dayjs from 'dayjs'
@@ -314,11 +315,24 @@
</div>
)}
- {/* 帖子图片(支持多图) */}
+ {/* 帖子媒体(支持多图/多视频) */}
{Array.isArray(post.media_urls) && post.media_urls.length > 0 && (
- <div className="post-images" style={{display:'flex',gap:8,marginBottom:16}}>
+ <div className="post-media" style={{display:'flex',gap:8,marginBottom:16,flexWrap:'wrap'}}>
{post.media_urls.map((url, idx) => (
- <img key={idx} src={url} alt={`图片${idx+1}`} style={{maxWidth:220,maxHeight:220,borderRadius:8,objectFit:'cover',cursor:'pointer'}} onClick={() => setPreviewImg(url)} />
+ <MediaPreview
+ key={idx}
+ url={url}
+ alt={`媒体${idx+1}`}
+ onClick={(mediaUrl) => {
+ // 对于图片,显示预览
+ if (!mediaUrl.toLowerCase().includes('video') && !mediaUrl.includes('.mp4') && !mediaUrl.includes('.webm')) {
+ setPreviewImg(mediaUrl)
+ }
+ }}
+ style={{ cursor: 'pointer' }}
+ maxWidth={320}
+ maxHeight={320}
+ />
))}
</div>
)}