From 37b70b48b6fbb3398bbf9400ff3cee49c96aa642 Mon Sep 17 00:00:00 2001 From: HamadaMasatoshi <77891959+HamadaMasatoshi@users.noreply.github.com> Date: Thu, 7 May 2026 14:39:54 +0800 Subject: [PATCH] fix(route/thepaper)(route/jiemian): remove useless image and audio (#21800) * Comment out media object in rss_item Comment out media object in rss_item construction * Disable voiceInfo handling in RSS item Comment out voiceInfo handling logic in RSS item creation. * Update description extraction to exclude report view * Refactor description logic in common.tsx Refactor description extraction to remove specific images and report view paragraphs. * Handle missing featured image in description logic * Improve description extraction in common.tsx Refactor description extraction logic to handle cases without a featured image more cleanly. --- lib/routes/jiemian/common.tsx | 18 +++++++++++++++++- lib/routes/thepaper/utils.tsx | 26 +++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/lib/routes/jiemian/common.tsx b/lib/routes/jiemian/common.tsx index c81333161..0c54b1468 100644 --- a/lib/routes/jiemian/common.tsx +++ b/lib/routes/jiemian/common.tsx @@ -70,7 +70,23 @@ export const handler = async (ctx): Promise => { } : undefined, intro: content('div.article-header p').text(), - description: content('div.article-content').html(), + description: (() => { + const featuredImageSrc = image.prop('src'); + if (!featuredImageSrc) { + // 如果没有 featured image,直接返回原始内容 + const descContent = content('div.article-content').clone(); + descContent.find('p.report-view').remove(); + return descContent.html(); + } + const baseImageName = featuredImageSrc.replace(/_[^.]+(\.\w+)$/, '$1'); + const descContent = content('div.article-content').clone(); + descContent.find('p.report-view').remove(); + if (baseImageName && baseImageName !== featuredImageSrc) { + descContent.find(`img[src="${baseImageName}"]`).remove(); + } + return descContent.html(); + })(), + }); item.author = content('span.author') .first() diff --git a/lib/routes/thepaper/utils.tsx b/lib/routes/thepaper/utils.tsx index 617cf2158..9e591f9de 100644 --- a/lib/routes/thepaper/utils.tsx +++ b/lib/routes/thepaper/utils.tsx @@ -61,20 +61,20 @@ export default { category: [...(contentDetail.tagList?.map((t) => t.tag) ?? []), contentDetail?.nodeInfo?.name ?? []], pubDate, author: contentDetail.author || '', - media: { - content: { - url: item.pic || contentDetail.videos?.coverUrl || contentDetail.bigPic, - }, - thumbnails: { - url: item.sharePic || contentDetail.sharePic, - }, - }, +// media: { +// content: { +// url: item.pic || contentDetail.videos?.coverUrl || contentDetail.bigPic, +// }, +// thumbnails: { +// url: item.sharePic || contentDetail.sharePic, +// }, +// }, }; - if (contentDetail.voiceInfo?.isHaveVoice) { - rss_item.enclosure_type = 'audio/mpeg'; - rss_item.enclosure_url = contentDetail.voiceInfo.voiceSrc; - rss_item.itunes_item_image = item.pic || contentDetail.videos?.coverUrl; - } +// if (contentDetail.voiceInfo?.isHaveVoice) { +// rss_item.enclosure_type = 'audio/mpeg'; +// rss_item.enclosure_url = contentDetail.voiceInfo.voiceSrc; +// rss_item.itunes_item_image = item.pic || contentDetail.videos?.coverUrl; +// } return rss_item; }); },