增加:抽屉新热榜 (#929)

- 实现 #863
This commit is contained in:
凉凉
2018-10-23 23:35:23 +08:00
committed by DIYgod
parent f80098af2b
commit 401a0fc8b1
3 changed files with 45 additions and 0 deletions
+10
View File
@@ -1951,3 +1951,13 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
| plan | program | tech | audio | project | yunying | test |
</route>
### 抽屉
<route name="新热榜" author="xyqfer" example="/chouti/hot" path="/chouti/:subject?" :paramsDesc="['主题名称']">
| 热榜 | 42 区 | 段子 | 图片 | 挨踢 1024 | 你问我答 |
| ---- | ----- | ----- | ---- | --------- | -------- |
| hot | news | scoff | pic | tec | ask |
</route>
+2
View File
@@ -673,4 +673,6 @@ router.get('/dgtle/trade/:typeId?', require('./routes/dgtle/trade'));
// 腾讯游戏开发者社区
router.get('/gameinstitute/community/:tag?', require('./routes/gameinstitute/community'));
// 抽屉新热榜
router.get('/chouti/:subject?', require('./routes/chouti'));
module.exports = router;
+33
View File
@@ -0,0 +1,33 @@
const axios = require('../../utils/axios');
module.exports = async (ctx) => {
let { subject = '' } = ctx.params;
const host = 'https://m.chouti.com';
if (subject === 'hot') {
subject = '';
}
const response = await axios({
method: 'get',
url: `${host}/m/link/more.do?type=hot&subject=${subject}&limit=recent`,
headers: {
Referer: host,
},
});
const resultItem = response.data.result.data.items.map((item) => ({
title: item.title,
author: item.nick,
description: `${item.title}<br><img src="${item.originalImgUrl}" referrerpolicy="no-referrer" /><br><a href="${host}${item.commentsUrl}">评论</a>`,
link: item.url,
pubDate: new Date(item.createtime).toUTCString(),
}));
ctx.state.data = {
title: '抽屉新热榜',
description: '抽屉新热榜,汇聚每日搞笑段子、热门图片、有趣新闻。它将微博、门户、社区、bbs、社交网站等海量内容聚合在一起,通过用户推荐生成最热榜单。看抽屉新热榜,每日热门、有趣资讯尽收眼底。',
link: host,
item: resultItem,
};
};