From 8928e1e598913794d428c53db2e257f47bd61c59 Mon Sep 17 00:00:00 2001 From: CaoMeiYouRen <996881204@qq.com> Date: Mon, 1 Apr 2024 16:58:43 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=20origin=20?= =?UTF-8?q?=E7=9A=84=20title=20=E5=92=8C=20desc=20=E5=8F=AF=E8=83=BD?= =?UTF-8?q?=E4=BC=9A=E9=87=8D=E5=A4=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/routes/bilibili/dynamic.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/routes/bilibili/dynamic.ts b/lib/routes/bilibili/dynamic.ts index ecf312eae..7161f6adf 100644 --- a/lib/routes/bilibili/dynamic.ts +++ b/lib/routes/bilibili/dynamic.ts @@ -55,8 +55,14 @@ export const route: Route = { 举例: bilibili 专栏全文输出 /bilibili/user/dynamic/2267573/?mode=fulltext :::`, }; - -const getTitle = (data: Modules) => { +/** + * + * + * @author CaoMeiYouRen + * @param data + * @param [desc=true] 当 title 为空的时候,是否用 desc 填充 + */ +const getTitle = (data: Modules, desc = true) => { const major = data.module_dynamic?.major; if (!major) { return ''; @@ -68,7 +74,7 @@ const getTitle = (data: Modules) => { return `${major.courses?.title} - ${major.courses?.sub_title}`; } const type = major.type.replace('MAJOR_TYPE_', '').toLowerCase(); - return major[type]?.title || getDes(data); + return major[type]?.title || (desc ? getDes(data) : ''); }; const getDes = (data: Modules) => { let desc = ''; @@ -97,7 +103,7 @@ const getDes = (data: Modules) => { return major[type]?.desc; }; -const getOriginTitle = (data?: Modules) => data && getTitle(data); +const getOriginTitle = (data?: Modules) => data && getTitle(data, false); const getOriginDes = (data?: Modules) => data && getDes(data); const getOriginName = (data?: Modules) => data?.module_author?.name; const getIframe = (data?: Modules, disableEmbed: boolean = false) => {