feat(route): add 差评快讯 and refactor to V2 (#9319)
* feat(route): add 差评快讯 and refactor to V2 * fix: parseDate
This commit is contained in:
parent
9dc20280e8
commit
ea0022cbcf
|
|
@ -1496,6 +1496,10 @@ Supported sub-sites:
|
|||
|
||||
</Route>
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="Fatpandac" example="/chaping/newsflash" path="/chaping/newsflash"/>
|
||||
|
||||
## 城农 Growin' City
|
||||
|
||||
### 城农资讯观点
|
||||
|
|
|
|||
|
|
@ -3211,10 +3211,6 @@ router.get('/blogs/jianning', lazyloadRouteHandler('./routes/blogs/jianning'));
|
|||
// 互动吧
|
||||
router.get('/hudongba/:city/:id', lazyloadRouteHandler('./routes/hudongba/index'));
|
||||
|
||||
// 差评
|
||||
router.get('/chaping/banner', lazyloadRouteHandler('./routes/chaping/banner'));
|
||||
router.get('/chaping/news/:caty?', lazyloadRouteHandler('./routes/chaping/news'));
|
||||
|
||||
// 飞雪娱乐网
|
||||
router.get('/feixuew/:id?', lazyloadRouteHandler('./routes/feixuew/index'));
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = `https://chaping.cn/`;
|
||||
|
|
@ -24,7 +25,7 @@ module.exports = async (ctx) => {
|
|||
|
||||
item.description = content.content;
|
||||
item.author = content.article_author.name;
|
||||
item.pubDate = new Date(content.time_publish_timestamp * 1000).toUTCString();
|
||||
item.pubDate = parseDate(content.time_publish_timestamp * 1000);
|
||||
|
||||
return item;
|
||||
})
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
'/banner': ['nczitzk'],
|
||||
'/news/:caty?': ['nczitzk'],
|
||||
'/newsflash': ['Fatpandac'],
|
||||
};
|
||||
|
|
@ -1,4 +1,5 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const titles = {
|
||||
0: '全部',
|
||||
|
|
@ -13,7 +14,7 @@ const titles = {
|
|||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.caty = ctx.params.caty || '';
|
||||
ctx.params.caty = ctx.params.caty ?? '';
|
||||
|
||||
const targetUrl = `https://chaping.cn/news?cate=${ctx.params.caty}`;
|
||||
const currentUrl = `https://chaping.cn/api/official/information/news?page=1&limit=16&cate=${ctx.params.caty}`;
|
||||
|
|
@ -25,7 +26,7 @@ module.exports = async (ctx) => {
|
|||
const list = apiResponse.data.data.map((item) => ({
|
||||
title: item.title,
|
||||
link: `https://chaping.cn/news/${item.id}`,
|
||||
pubDate: new Date(item.time_publish_timestamp * 1000).toUTCString(),
|
||||
pubDate: parseDate(item.time_publish_timestamp * 1000),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const host = 'https://chaping.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const newflashAPI = `${host}/api/official/information/newsflash?page=1&limit=21`;
|
||||
const response = await got(newflashAPI).json();
|
||||
const data = response.data;
|
||||
|
||||
ctx.state.data = {
|
||||
title: '差评 快讯',
|
||||
link: `${host}/newsflash`,
|
||||
item:
|
||||
data &&
|
||||
data.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.summary,
|
||||
pubDate: parseDate(item.time_publish_timestamp * 1000),
|
||||
link: item.origin_url,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
module.exports = {
|
||||
'chaping.cn': {
|
||||
_name: '差评',
|
||||
'.': [
|
||||
{
|
||||
title: '图片墙',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#cha-ping',
|
||||
source: ['/'],
|
||||
target: '/chaping/banner',
|
||||
},
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#cha-ping',
|
||||
source: ['/news'],
|
||||
target: (params, url) => {
|
||||
const cateList = ['15', '3', '7', '5', '6', '1', '8', '9'];
|
||||
const cate = new URL(url).searchParams.get('cate');
|
||||
if (cateList.includes(cate)) {
|
||||
return `/chaping/news/${cate}`;
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/new-media.html#cha-ping',
|
||||
source: ['/newsflash'],
|
||||
target: '/chaping/newsflash',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/banner', require('./banner'));
|
||||
router.get('/news/:caty?', require('./news'));
|
||||
router.get('/newsflash', require('./newsflash'));
|
||||
};
|
||||
Loading…
Reference in New Issue