diff --git a/docs/game.md b/docs/game.md index ba6bad0af8..50dbf3cd68 100644 --- a/docs/game.md +++ b/docs/game.md @@ -250,6 +250,10 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 +### 国服公告 + + + ## 篝火营地 ### 游戏资讯 diff --git a/lib/router.js b/lib/router.js index 1c53c2dc6f..d25bb13b00 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2236,6 +2236,7 @@ router.get('/ddrk/index', require('./routes/ddrk/list')); // 公主链接公告 router.get('/pcr/news', require('./routes/pcr/news')); router.get('/pcr/news-tw', require('./routes/pcr/news-tw')); +router.get('/pcr/news-cn', require('./routes/pcr/news-cn')); // project-zero issues router.get('/project-zero-issues', require('./routes/project-zero-issues/index')); diff --git a/lib/routes/pcr/news-cn.js b/lib/routes/pcr/news-cn.js new file mode 100644 index 0000000000..2d8a51a147 --- /dev/null +++ b/lib/routes/pcr/news-cn.js @@ -0,0 +1,28 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://api.biligame.com/news/list?gameExtensionId=267&positionId=2&typeId=1&pageNum=1&pageSize=5', + }); + const data = response.data; + ctx.state.data = { + title: '公主链接国服-最新公告', + link: 'https://game.bilibili.com/pcr/news.html', + item: data + ? await Promise.all( + data.data.map(async (item) => ({ + title: item.title, + description: `${await ctx.cache.tryGet(`pcrcn_${item.id}`, async () => { + const resp = await got({ method: 'get', url: `https://api.biligame.com/news/${item.id}` }); + return resp.data.data.content; + })}`, + link: `https://game.bilibili.com/pcr/news.html#detail=${item.id}`, + pubDate: item.ctime ? item.ctime : item.createTime, + })) + ) + : { + title: '获取失败!', + }, + }; +};