diff --git a/lib/v2/wmpvp/index.js b/lib/v2/wmpvp/index.js new file mode 100644 index 000000000..a62a5c74f --- /dev/null +++ b/lib/v2/wmpvp/index.js @@ -0,0 +1,34 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const { type } = ctx.params; + + const response = await got({ + method: 'get', + url: `https://appengine.wmpvp.com/steamcn/community/homepage/getHomeInformation?gameTypeStr=${type}&pageNum=1&pageSize=20`, + }); + const data = response.data.result.filter((item) => item.news !== undefined); + + const items = data.map((item) => { + const entity = item.news; + const newsId = entity.newsId; + const newsLink = `https://news.wmpvp.com/news.html?id=${newsId}&gameTypeStr=${type}`; + + // 最终需要返回的对象 + return { + title: entity.title, + pubDate: parseDate(entity.publishTime), + link: newsLink, + guid: newsLink, + description: entity.summary, + author: entity.author, + }; + }); + + ctx.state.data = { + title: `完美世界电竞`, + link: `https://news.wmpvp.com/`, + item: items, + }; +}; diff --git a/lib/v2/wmpvp/maintainer.js b/lib/v2/wmpvp/maintainer.js new file mode 100644 index 000000000..1559b79e1 --- /dev/null +++ b/lib/v2/wmpvp/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:type': ['tssujt'], +}; diff --git a/lib/v2/wmpvp/radar.js b/lib/v2/wmpvp/radar.js new file mode 100644 index 000000000..496db0b08 --- /dev/null +++ b/lib/v2/wmpvp/radar.js @@ -0,0 +1,11 @@ +module.exports = { + 'wmpvp.com': { + _name: '完美世界电竞', + '.': [ + { + title: '资讯', + docs: 'https://docs.rsshub.app/routes/game#wan-mei-shi-jie-dian-jing-zi-xun', + }, + ], + }, +}; diff --git a/lib/v2/wmpvp/router.js b/lib/v2/wmpvp/router.js new file mode 100644 index 000000000..eb2f665ae --- /dev/null +++ b/lib/v2/wmpvp/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news/:type', require('.')); +}; diff --git a/website/docs/routes/game.mdx b/website/docs/routes/game.mdx index 5a93f2f29..80a6bb35a 100644 --- a/website/docs/routes/game.mdx +++ b/website/docs/routes/game.mdx @@ -903,6 +903,16 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547` +## 完美世界电竞 {#wan-mei-shi-jie-dian-jing} + +### 资讯列表 {#wan-mei-shi-jie-dian-jing-zi-xun} + + + | DOTA2 | CS2 | + | ---- | ---- | + | 1 | 2 | + + ## 小黑盒 {#xiao-hei-he} ### 用户动态 {#xiao-hei-he-yong-hu-dong-tai}