mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
fix(route): add 少女前线情报局 (#8519)
This commit is contained in:
+1
-1
@@ -555,7 +555,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
||||
|
||||
## 少女前线
|
||||
|
||||
### 新闻
|
||||
### 情报局
|
||||
|
||||
<Route author="nczitzk" example="/gf-cn/news" path="/gf-cn/news/:category?" :paramsDesc="['分类,见下表,默认为新闻']">
|
||||
|
||||
|
||||
+1
-1
@@ -4042,7 +4042,7 @@ router.get('/trakt/collection/:username/:type?', lazyloadRouteHandler('./routes/
|
||||
router.get('/ccg/:category?', lazyloadRouteHandler('./routes/ccg/index'));
|
||||
|
||||
// 少女前线
|
||||
router.get('/gf-cn/news/:category?', lazyloadRouteHandler('./routes/gf-cn/news'));
|
||||
// router.get('/gf-cn/news/:category?', lazyloadRouteHandler('./routes/gf-cn/news'));
|
||||
|
||||
// Eagle
|
||||
router.get('/eagle/changelog/:language?', lazyloadRouteHandler('./routes/eagle/changelog'));
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category || '1';
|
||||
|
||||
const rootUrl = 'https://gfcn-webserver.sunborngame.com';
|
||||
const currentUrl = `${rootUrl}/website/news_list/${category}?page=0&limit=11`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const list = response.data.data.list.map((item) => ({
|
||||
title: item.Title,
|
||||
link: `${rootUrl}/website/news/${item.Id}`,
|
||||
pubDate: new Date(item.Date).toUTCString(),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
item.description = detailResponse.data.data.Content;
|
||||
item.link = item.link.replace(`${rootUrl}/website/news/`, `${rootUrl}/NewsInfo?id=`);
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `少女前线 - ${category === '1' ? '新闻' : '公告'}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/news/:category?': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,50 @@
|
||||
const got = require('@/utils/got');
|
||||
const timezone = require('@/utils/timezone');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const titles = {
|
||||
1: '新闻',
|
||||
3: '公告',
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category ?? '1';
|
||||
|
||||
const rootUrl = 'https://gf-cn.sunborngame.com';
|
||||
const apiRootUrl = 'https://gfcn-webserver.sunborngame.com';
|
||||
const apiUrl = `${apiRootUrl}/website/news_list/${category}?page=0&limit=${ctx.query.limit ?? 50}`;
|
||||
const currentUrl = `${rootUrl}/News`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
let items = response.data.data.list.map((item) => ({
|
||||
guid: item.Id,
|
||||
title: item.Title,
|
||||
link: `${rootUrl}/NewsInfo?id=${item.Id}`,
|
||||
pubDate: timezone(parseDate(item.Date), +8),
|
||||
}));
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.guid, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: `${apiRootUrl}/website/news/${item.guid}`,
|
||||
});
|
||||
|
||||
item.description = detailResponse.data.data.Content.replace(/<img src="/g, '<img src="https://gf-cn.cdn.sunborngame.com/website/cms/');
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${titles[category]} - 少女前线 - 情报局`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,13 @@
|
||||
module.exports = {
|
||||
'sunborngame.com': {
|
||||
_name: '少女前线',
|
||||
'.': [
|
||||
{
|
||||
title: '情报局',
|
||||
docs: 'https://docs.rsshub.app/game.html#shao-nv-qian-xian-qing-bao-ju',
|
||||
source: ['/:category', '/'],
|
||||
target: '/gf-cn/news/:category?',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/news/:category?', require('./news'));
|
||||
};
|
||||
Reference in New Issue
Block a user