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 += ''; } }