* 修复/zhihu/question,需要设置非登录状态下cookie * Update lib/routes/zhihu/execlib/g_encrypt.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * 根据TonyRL review建议进行了修改 * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * 增加cookie中dc_0字段检验 * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * Update lib/routes/zhihu/question.js Co-authored-by: Rongrong <Rongronggg9@outlook.com> * refactor: migrate to v2 * fix: Incomplete URL substring sanitization Co-authored-by: Rongrong <Rongronggg9@outlook.com>
48 lines
1.9 KiB
JavaScript
48 lines
1.9 KiB
JavaScript
const got = require('@/utils/got');
|
|
const utils = require('./utils');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const {
|
|
data: { data },
|
|
} = await got({
|
|
method: 'get',
|
|
url: 'https://www.zhihu.com/api/v3/explore/guest/feeds?limit=40',
|
|
});
|
|
|
|
ctx.state.data = {
|
|
title: '知乎热榜',
|
|
link: 'https://www.zhihu.com/billboard',
|
|
description: '知乎热榜',
|
|
item: data.map((item) => {
|
|
switch (item.target.type) {
|
|
case 'answer':
|
|
return {
|
|
title: item.target.question.title,
|
|
description: `${item.target.author.name}的回答<br/><br/>${utils.ProcessImage(item.target.content)}`,
|
|
author: item.target.author.name,
|
|
pubDate: parseDate(item.target.updated_time * 1000),
|
|
guid: item.target.id.toString(),
|
|
link: `https://www.zhihu.com/question/${item.target.question.id}/answer/${item.target.id}`,
|
|
};
|
|
case 'article':
|
|
return {
|
|
title: item.target.title,
|
|
description: `${item.target.author.name}的文章<br/><br/>${utils.ProcessImage(item.target.content)}`,
|
|
author: item.target.author.name,
|
|
pubDate: parseDate(item.updated * 1000),
|
|
guid: item.target.id.toString(),
|
|
link: `https://zhuanlan.zhihu.com/p/${item.target.id}`,
|
|
};
|
|
default:
|
|
return {
|
|
title: '未知类型',
|
|
description: '请点击链接提交issue',
|
|
guid: item.target.type,
|
|
link: 'https://github.com/DIYgod/RSSHub/issues',
|
|
};
|
|
}
|
|
}),
|
|
};
|
|
};
|