From e6d4e1e18aaf58cf8c8b7e5ce37e5f723ead8e91 Mon Sep 17 00:00:00 2001 From: zsly387 Date: Thu, 25 Jul 2024 04:18:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(router):=20=E5=BE=AE=E5=8D=9A=E8=B7=AF?= =?UTF-8?q?=E7=94=B1=20=20=E8=AF=84=E8=AE=BA=E5=A2=9E=E5=8A=A0=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E8=BE=93=E5=87=BA=E5=8A=9F=E8=83=BD=20(#16227)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * updata * update * update * update * update * test * test2 --- lib/routes/weibo/utils.ts | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/routes/weibo/utils.ts b/lib/routes/weibo/utils.ts index afee8d978..579dd0dc9 100644 --- a/lib/routes/weibo/utils.ts +++ b/lib/routes/weibo/utils.ts @@ -426,9 +426,28 @@ const weiboUtils = { for (const comment of comments) { itemDesc += '

'; itemDesc += `${comment.user.screen_name}: ${comment.text}`; + // 带有图片的评论直接输出图片 + if ('pic' in comment) { + itemDesc += `
`; + } if (comment.comments) { itemDesc += '

'; for (const com of comment.comments) { + // 评论的带有图片的评论直接输出图片 + const pattern = /]*>]*><\/span>(查看图片|评论配图|查看动图)<\/span><\/a>/g; + const matches = com.text.match(pattern); + if (matches) { + for (const match of matches) { + const hrefMatch = match.match(/href="https:\/\/weibo\.cn\/sinaurl\?u=([^"]+)"/); + if (hrefMatch) { + // 获取并解码 href 中的图片 URL + const imgSrc = decodeURIComponent(hrefMatch[1]); + const imgTag = ``; + // 用替换后的 img 标签替换原来的 标签部分 + com.text = com.text.replaceAll(match, imgTag); + } + } + } itemDesc += '
'; itemDesc += `${com.user.screen_name}: ${com.text}`; itemDesc += '
'; @@ -437,6 +456,7 @@ const weiboUtils = { } itemDesc += '

'; } + itemDesc += ''; } }