feat(route): add Now 熱門新聞 (#8093)
Co-authored-by: DIYgod <diy.d.god@gmail.com>
This commit is contained in:
parent
e9eebb1998
commit
970db993ee
|
|
@ -213,6 +213,12 @@ pageClass: routes
|
|||
|
||||
<Route author="Andiedie" example="/nhk/news_web_easy" path="/nhk/news_web_easy"/>
|
||||
|
||||
## Now 新聞
|
||||
|
||||
### 熱門
|
||||
|
||||
<Route author="nczitzk" example="/now/news/rank" path="/now/news/rank"/>
|
||||
|
||||
## Phoronix
|
||||
|
||||
### 新闻与评测
|
||||
|
|
|
|||
|
|
@ -4207,6 +4207,9 @@ router.get('/right/forum/:id?', lazyloadRouteHandler('./routes/right/forum'));
|
|||
// 香港經濟日報
|
||||
router.get('/hket/:category?', lazyloadRouteHandler('./routes/hket/index'));
|
||||
|
||||
// Now新聞
|
||||
router.get('/now/news/rank', lazyloadRouteHandler('./routes/now/rank'));
|
||||
|
||||
// s-hentai
|
||||
router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const sources = {
|
||||
nownews: '/home/local/player?newsId=',
|
||||
nowsports: '/home/news/details?id=',
|
||||
nowfinace: '/news/post.php?id=',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = (source) => `https://${source}.now.com`;
|
||||
const currentUrl = `${rootUrl('news')}/api/getRankNewsList?pageSize=221`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const items = response.data.map((item) => ({
|
||||
title: item.title,
|
||||
pubDate: parseDate(item.publishDate),
|
||||
description: `<img src="${item.imageUrl}">${item.summary || ''}`,
|
||||
link: `${rootUrl(item.newsSource.replace('now', ''))}${sources[item.newsSource]}${item.newsId}`,
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: '熱門 | Now 新聞',
|
||||
link: rootUrl('news'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue