diff --git a/docs/game.md b/docs/game.md index d113ee6f4dc09b..fc4eb0fd344036 100644 --- a/docs/game.md +++ b/docs/game.md @@ -504,6 +504,18 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 +## 少女前线 + +### 新闻 + + + +| 新闻 | 公告 | +| ---- | ---- | +| 1 | 3 | + + + ## 网易大神 ### 用户发帖 diff --git a/lib/router.js b/lib/router.js index c5cd11a7008089..6d54289241dadf 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3968,12 +3968,16 @@ router.get('/furaffinity/journal_comments/:id', require('./routes/furaffinity/jo // Logseq router.get('/logseq/changelog', require('./routes/logseq/changelog')); + // 亿欧网 router.get('/iyiou', require('./routes/iyiou')); // 香港商报 router.get('/hkcd/pdf', require('./routes/hkcd/pdf')); +// 少女前线 +router.get('/gf-cn/news/:category?', require('./routes/gf-cn/news')); + // Eagle router.get('/eagle/changelog/:language?', require('./routes/eagle/changelog')); diff --git a/lib/routes/gf-cn/news.js b/lib/routes/gf-cn/news.js new file mode 100644 index 00000000000000..452b377fd70911 --- /dev/null +++ b/lib/routes/gf-cn/news.js @@ -0,0 +1,40 @@ +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( + async (item) => + await 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, + }; +};