diff --git a/docs/programming.md b/docs/programming.md index 4ed17bdfe..ba19721ec 100644 --- a/docs/programming.md +++ b/docs/programming.md @@ -6,9 +6,9 @@ pageClass: routes ## AI 研习社 -### 最新 +### 首页 - + ## AlgoCasts diff --git a/lib/router.js b/lib/router.js index 88f6788e0..dbe3c3c6c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1419,6 +1419,6 @@ router.get('/outagereport/:name/:count?', require('./routes/outagereport/service router.get('/sixthtone/news', require('./routes/sixthtone/news')); // AI研习社 -router.get('/aiyanxishe/', require('./routes/aiyanxishe/home')); +router.get('/aiyanxishe/:id/:sort?', require('./routes/aiyanxishe/home')); module.exports = router; diff --git a/lib/routes/aiyanxishe/home.js b/lib/routes/aiyanxishe/home.js index 91a261c2f..ed1de8a38 100644 --- a/lib/routes/aiyanxishe/home.js +++ b/lib/routes/aiyanxishe/home.js @@ -1,9 +1,27 @@ const got = require('@/utils/got'); module.exports = async (ctx) => { + const id = ctx.params.id; + const sort = ctx.params.sort || 'new'; + + let url = 'https://www.leiphone.com/club/api?page=1&size=30&parent_tag='; + + if (id === 'all') { + url += '&tag='; + } else { + url += `&tag=${id}`; + } + if (sort === 'hot') { + url += '&is_hot=1&is_recommend=0'; + } else if (sort === 'recommend') { + url += '&is_hot=0&is_recommend=1'; + } else { + url += '&is_hot=0&is_recommend=0'; + } + const response = await got({ method: 'GET', - url: 'https://www.leiphone.com/club/api?page=1&size=30&is_hot=0&is_recommend=0&tag=&parent_tag=', + url: url, headers: { Referer: `https://www.leiphone.com/club/api?page=1&size=30&is_hot=0&is_recommend=0&tag=&parent_tag='`, },