From 797470c0dbd79c52ebf0a28ad47b678fc52c6708 Mon Sep 17 00:00:00 2001
From: CaoMeiYouRen <40430746+CaoMeiYouRen@users.noreply.github.com>
Date: Sat, 2 Nov 2024 21:08:14 +0800
Subject: [PATCH] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20bilibili=20?=
=?UTF-8?q?=E5=8A=A8=E6=80=81=E8=B7=AF=E7=94=B1=E5=9C=A8=E9=83=A8=E5=88=86?=
=?UTF-8?q?=E6=83=85=E5=86=B5=E4=B8=8B=E5=87=BA=E7=8E=B0=E7=A9=BA=E5=9B=BE?=
=?UTF-8?q?=E7=89=87=E7=9A=84=E9=97=AE=E9=A2=98=20(#17420)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
fix #17414
---
lib/routes/bilibili/dynamic.ts | 11 +++++++----
lib/routes/bilibili/templates/description.art | 2 ++
2 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts
index b5b21cf88..cd1ffb353 100644
--- a/lib/routes/bilibili/dynamic.ts
+++ b/lib/routes/bilibili/dynamic.ts
@@ -117,6 +117,7 @@ const getIframe = (data?: Modules, embed: boolean = true) => {
if (aid === undefined && bvid === undefined) {
return '';
}
+ // 不通过 utils.renderUGCDescription 渲染 img/description 以兼容其他格式的动态
return utils.renderUGCDescription(embed, '', '', aid, undefined, bvid);
};
@@ -146,7 +147,10 @@ const getImgs = (data?: Modules) => {
if (major[type]?.cover) {
imgUrls.push(major[type].cover);
}
- return imgUrls.map((url) => `
`).join('');
+ return imgUrls
+ .filter(Boolean)
+ .map((url) => `
`)
+ .join('');
};
const getUrl = (item?: Item2, useAvid = false) => {
@@ -354,10 +358,9 @@ async function handler(ctx) {
// 换行处理
description = description.replaceAll('\r\n', '
').replaceAll('\n', '
');
originDescription = originDescription.replaceAll('\r\n', '
').replaceAll('\n', '
');
-
- const descriptions = [description, originDescription, urlText, originUrlText, getIframe(data, embed), getIframe(origin, embed), getImgs(data), getImgs(origin)]
- .filter(Boolean)
+ const descriptions = [description, getIframe(data, embed), getImgs(data), urlText, originDescription, getIframe(origin, embed), getImgs(origin), originUrlText]
.map((e) => e?.trim())
+ .filter(Boolean)
.join('
');
return {
diff --git a/lib/routes/bilibili/templates/description.art b/lib/routes/bilibili/templates/description.art
index 65e2261cf..5f6e5847d 100644
--- a/lib/routes/bilibili/templates/description.art
+++ b/lib/routes/bilibili/templates/description.art
@@ -7,6 +7,8 @@
{{ /if }}
{{ /if }}
+{{ if img}}
+{{ /if }}
{{@ description }}