From 2b5f4d092a0b3b79b3f022f34ef238152e5ff636 Mon Sep 17 00:00:00 2001
From: CaoMeiYouRen <40430746+CaoMeiYouRen@users.noreply.github.com>
Date: Tue, 28 May 2024 00:40:55 +0800
Subject: [PATCH] =?UTF-8?q?feat(route):=20=E5=BE=AE=E5=8D=9A=E8=B7=AF?=
=?UTF-8?q?=E7=94=B1=20=E6=96=B0=E5=A2=9E=20category=20=E5=AD=97=E6=AE=B5?=
=?UTF-8?q?=20(#15734)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
lib/routes/weibo/utils.ts | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/routes/weibo/utils.ts b/lib/routes/weibo/utils.ts
index 4efa0a31e..7d86af49d 100644
--- a/lib/routes/weibo/utils.ts
+++ b/lib/routes/weibo/utils.ts
@@ -74,6 +74,10 @@ const weiboUtils = {
if (!showLinkIconInDescription) {
htmlNewLineUnreplaced = htmlNewLineUnreplaced.replaceAll(/(]*>)
]*><\/span>[^<>]*?([^<>]*?)<\/span><\/a>/g, '$1$2');
}
+
+ // 提取 话题作为 category
+ const category: string[] = htmlNewLineUnreplaced.match(/#([^<>]*?)#<\/span>/g)?.map((e) => e?.match(/#([^#]+)#/)?.[1]);
+
// 去掉乱七八糟的图标 // 不需要,上述的替换应该已经把所有的图标都替换掉了,且这条 regex 会破坏上述替换不发生时的输出
// htmlNewLineUnreplaced = htmlNewLineUnreplaced.replace(/(
]*?>)<\/span>/g, '');
// 将行内图标的高度设置为一行,改善阅读体验。但有些阅读器删除了 style 属性,无法生效 // 不需要,微博已经作此设置
@@ -241,7 +245,7 @@ const weiboUtils = {
const author = status.user?.screen_name;
const pubDate = status.created_at;
- return { description: html, title, link, guid, author, pubDate };
+ return { description: html, title, link, guid, author, pubDate, category };
},
getShowData: async (uid, bid) => {
const link = `https://m.weibo.cn/statuses/show?id=${bid}`;