fix: B站话题(频道/标签)失效 (#2367)
This commit is contained in:
parent
d9e2bcd4d9
commit
f1514212db
|
|
@ -1,5 +1,4 @@
|
|||
const got = require('@/utils/got');
|
||||
const JSONbig = require('json-bigint');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const topic = ctx.params.topic;
|
||||
|
|
@ -13,38 +12,36 @@ module.exports = async (ctx) => {
|
|||
},
|
||||
transformResponse: [(data) => data],
|
||||
});
|
||||
const data = JSONbig.parse(response.data).data.cards;
|
||||
const data = response.data.data.cards;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${topic} 的全部话题`,
|
||||
link: `https://www.bilibili.com/tag/${topic}/feed`,
|
||||
description: `https://www.bilibili.com/tag/${topic}/feed`,
|
||||
item: data.map((item) => {
|
||||
const parsed = JSONbig.parse(item.card);
|
||||
const data = parsed.item || parsed;
|
||||
const parsed = JSON.parse(item.card);
|
||||
const cardData = parsed.item || parsed;
|
||||
|
||||
// img
|
||||
let imgHTML = '';
|
||||
if (data.pictures) {
|
||||
for (let i = 0; i < data.pictures.length; i++) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${data.pictures[i].img_src}">`;
|
||||
if (cardData.pictures) {
|
||||
for (let i = 0; i < cardData.pictures.length; i++) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${cardData.pictures[i].img_src}">`;
|
||||
}
|
||||
}
|
||||
if (data.pic) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${data.pic}">`;
|
||||
if (cardData.pic) {
|
||||
imgHTML += `<img referrerpolicy="no-referrer" src="${cardData.pic}">`;
|
||||
}
|
||||
|
||||
// link
|
||||
let link = '';
|
||||
if (data.dynamic_id) {
|
||||
link = `https://t.bilibili.com/${data.dynamic_id}`;
|
||||
} else if (item.desc && item.desc.dynamic_id) {
|
||||
link = `https://t.bilibili.com/${item.desc.dynamic_id}`;
|
||||
if (item.desc && item.desc.dynamic_id_str) {
|
||||
link = `https://t.bilibili.com/${item.desc.dynamic_id_str}`;
|
||||
}
|
||||
|
||||
return {
|
||||
title: data.title || data.description || data.content || (data.vest && data.vest.content),
|
||||
description: `${data.desc || data.description || data.content || data.summary || (data.vest && data.vest.content) + (data.sketch && data.sketch.title)}${imgHTML} `,
|
||||
title: cardData.title || cardData.description || cardData.content || (cardData.vest && cardData.vest.content),
|
||||
description: `${cardData.desc || cardData.description || cardData.content || cardData.summary || (cardData.vest && cardData.vest.content) + (cardData.sketch && cardData.sketch.title)}${imgHTML} `,
|
||||
pubDate: new Date(item.desc.timestamp * 1000).toUTCString(),
|
||||
link: link,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue