From 15e08dc529cd563d43e3a38f83cd1d6a1c40057d Mon Sep 17 00:00:00 2001 From: xuncha <1658671838@qq.com> Date: Thu, 19 Feb 2026 17:12:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=8B=E5=8F=8B=E5=9C=88?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E4=B9=9F=E8=B5=B0=E5=8D=A1=E7=89=87=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/SnsPage.tsx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/pages/SnsPage.tsx b/src/pages/SnsPage.tsx index 218d8d0..d10031a 100644 --- a/src/pages/SnsPage.tsx +++ b/src/pages/SnsPage.tsx @@ -46,6 +46,12 @@ const LINK_XML_URL_TAGS = ['url', 'shorturl', 'weburl', 'webpageurl', 'jumpurl'] const LINK_XML_TITLE_TAGS = ['title', 'linktitle', 'webtitle'] const MEDIA_HOST_HINTS = ['mmsns.qpic.cn', 'vweixinthumb', 'snstimeline', 'snsvideodownload'] +const isSnsVideoUrl = (url?: string): boolean => { + if (!url) return false + const lower = url.toLowerCase() + return (lower.includes('snsvideodownload') || lower.includes('.mp4') || lower.includes('video')) && !lower.includes('vweixinthumb') +} + const decodeHtmlEntities = (text: string): string => { if (!text) return '' return text @@ -95,6 +101,9 @@ const isLikelyMediaAssetUrl = (url: string): boolean => { } const buildLinkCardData = (post: SnsPost): SnsLinkCardData | null => { + const hasVideoMedia = post.type === 15 || post.media.some((item) => isSnsVideoUrl(item.url)) + if (hasVideoMedia) return null + const mediaValues = post.media .flatMap((item) => [item.url, item.thumb]) .filter((value): value is string => Boolean(value)) @@ -201,7 +210,7 @@ const MediaItem = ({ media, onPreview }: { media: any; onPreview: (src: string, const targetUrl = thumb || url // 默认显示缩略图 // 判断是否为视频 - const isVideo = url && (url.includes('snsvideodownload') || url.includes('.mp4') || url.includes('video')) && !url.includes('vweixinthumb') + const isVideo = isSnsVideoUrl(url) useEffect(() => { let cancelled = false @@ -764,7 +773,8 @@ export default function SnsPage() { )} {posts.map((post) => { const linkCard = buildLinkCardData(post) - const showLinkCard = Boolean(linkCard) && post.media.length <= 1 + const hasVideoMedia = post.type === 15 || post.media.some((item) => isSnsVideoUrl(item.url)) + const showLinkCard = Boolean(linkCard) && post.media.length <= 1 && !hasVideoMedia const showMediaGrid = post.media.length > 0 && !showLinkCard return (