Skip to content

Commit b45b67b

Browse files
committed
fix: weibo rss title
1 parent eb8b266 commit b45b67b

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

lib/routes/weibo/user.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ module.exports = async (ctx) => {
5050
if (isDataOK) {
5151
item.mblog.text = data.text;
5252
item.mblog.created_at = data.created_at;
53-
item.mblog.retweeted_status.created_at = data.retweeted_status.created_at;
53+
if (item.mblog.retweeted_status && data.retweeted_status) {
54+
item.mblog.retweeted_status.created_at = data.retweeted_status.created_at;
55+
}
5456
}
5557
// 转发的长微博处理
5658
const retweet = item.mblog.retweeted_status;

lib/routes/weibo/utils.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const weiboUtils = {
55
formatWithRetweet: (status, showAuthorAvatar = true) => {
66
let retweetedOrOriginal = '';
77
// 长文章的处理
8-
let temp = (status.longText && status.longText.longTextContent.replace(/\n/g, '<br>')) || status.text || '';
8+
let temp = (status.longText && status.longText.longTextContent) || status.text || '';
99
// 表情图标转换为文字
1010
temp = temp.replace(/<span class="url-icon"><img.*?alt="?(.*?)"? [\s\S]*?\/><\/span>/g, '$1');
1111
// 去掉外部链接的图标
@@ -21,6 +21,9 @@ const weiboUtils = {
2121
return decodeURIComponent(p1);
2222
});
2323

24+
let originalText = temp;
25+
temp = temp.replace(/\n/g, '<br>');
26+
2427
// 添加用户名和头像
2528
let usernameAndAvatar = `<a href="https://weibo.com/${status.user.id}">`;
2629
if (showAuthorAvatar) {
@@ -50,10 +53,11 @@ const weiboUtils = {
5053
temp += '<br clear="both" /><div style="clear: both"></div>';
5154
status.pics.forEach(function (item) {
5255
temp += '<a href="' + item.large.url + '"><img vspace="8" hspace="4" src="' + item.large.url + '"></a>';
56+
originalText += '<img src="">'
5357
});
5458
}
5559

56-
return { description: temp, retweetedOrOriginal: status.retweeted_status ? '🔁 ' + retweetedOrOriginal : temp };
60+
return { description: temp, retweetedOrOriginal: status.retweeted_status ? '🔁 ' + retweetedOrOriginal : originalText.replace('\n', '') };
5761
},
5862
getShowData: async (uid, bid) => {
5963
const link = `https://m.weibo.cn/statuses/show?id=${bid}`;

0 commit comments

Comments
 (0)