From b27279f269936d8020852efd44d862d2e6300895 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A6=B3=E6=9C=88=E5=94=AF?= Date: Mon, 21 Sep 2020 04:14:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=204Gamers=20=E9=A6=96=E9=A0=81?= =?UTF-8?q?=E4=B8=8A=E6=96=B9=E4=B8=BB=E9=A1=8C=E5=85=A7=E5=88=86=E5=8D=80?= =?UTF-8?q?=20(#5675)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/game.md | 38 ++++++++++++++++++++----------------- lib/router.js | 1 + lib/routes/4gamers/tag.js | 2 +- lib/routes/4gamers/topic.js | 20 +++++++++++++++++++ 4 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 lib/routes/4gamers/topic.js diff --git a/docs/game.md b/docs/game.md index c81153901..fcbc1d0f9 100644 --- a/docs/game.md +++ b/docs/game.md @@ -15,7 +15,7 @@ pageClass: routes | 新闻 | 攻略 | 下载资源 | 区块链快讯 | -| ---- | ---- | -------- | ---------- | +|------|------|----------|------------| | news | gl | resource | blockchain | @@ -30,6 +30,10 @@ pageClass: routes +### 主題 + + + ## a9vgNews 游戏新闻 ### a9vgNews 游戏新闻 @@ -81,19 +85,19 @@ pageClass: routes 支持的主机平台: | PS 4 | Xbox One | Switch | PC | Wii U | 3DS | PS Vita | iOS | -| ---- | -------- | ------ | -- | ----- | --- | ------- | --- | +|------|----------|--------|----|-------|-----|---------|-----| | ps4 | xboxone | switch | pc | wii-u | 3ds | vita | ios | 发行类型,默认为 `new`: | 新游发行 | 即将发行 | 全部 | -| -------- | -------- | ---- | +|----------|----------|------| | new | coming | all | 排序类型,默认为`date`: | 日期 | Metacritic 评分 | 用户评分 | -| ---- | --------------- | --------- | +|------|-----------------|-----------| | date | metascore | userscore | @@ -186,7 +190,7 @@ pageClass: routes | 游戏代码 | 游戏名称 | -| -------- | ------------ | +|----------|----------| | GTAV | 侠盗猎车手 5 | | RDR2 | 荒野大镖客 2 | @@ -233,7 +237,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 全部 | 精华 | 官方 | -| ---- | ----- | -------- | +|------|-------|----------| | all | elite | official | ### 游戏更新 @@ -245,7 +249,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 最新 | 最热 | 游戏时长 | -| ------ | ---- | -------- | +|--------|------|----------| | update | hot | spent | ## 二柄 APP @@ -275,7 +279,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 精选 | 海外 | 原创 | PS4 | Xboxone | PC | Switch | 掌机 | 手游 | 新闻 | 评测 | 文化 | 视频 | 音频 | 折扣 | -| ---------- | -------- | ------- | --- | ------- | -- | ------ | -------- | ---------- | ---- | ------ | ------- | ----- | ----- | -------- | +|------------|----------|---------|-----|---------|----|--------|----------|------------|------|--------|---------|-------|-------|----------| | choiceness | overseas | orignal | ps4 | xboxone | pc | switch | handheld | mobilegame | news | review | culture | video | audio | discount | @@ -301,11 +305,11 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 主页资讯 | 炉石传说 | 万智牌 | 昆特牌 | 游戏王 | 电子游戏 | 手机游戏 | 桌面游戏 | -| -------- | -------- | ------ | ------ | ------ | -------- | -------- | -------- | +|----------|----------|--------|--------|--------|----------|----------|----------| | 1 | 2 | 3 | 14 | 16 | 4 | 22 | 9 | | 影之诗 | Artifact | 玩家杂谈 | 营地电台 | 2047 | 魂武 | -| ------ | -------- | -------- | -------- | ---- | ---- | +|--------|----------|----------|----------|------|------| | 17 | 67 | 21 | 5 | 62 | 68 | @@ -317,7 +321,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 最新公告 | 版本信息 | 祈愿信息 | 活动介绍 | -| -------- | -------- | -------- | -------- | +|----------|----------|----------|----------| | new | version | gach | event | @@ -327,7 +331,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 最新 | 动态 | 公告 | 活动 | 补给 | -| ------ | ---- | ------ | -------- | -------- | +|--------|------|--------|----------|----------| | latest | news | notice | activity | strategy | @@ -371,7 +375,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | Steam | PlatStation4 | Switch | -| ----- | ------------ | ------ | +|-------|--------------|--------| | pc | ps4 | switch | @@ -393,7 +397,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 趣囧时间 | 游民影院 | 游观天下 | 壁纸图库 | 游民盘点 | 游民福利 | -| -------- | -------- | -------- | -------- | -------- | -------- | +|----------|----------|----------|----------|----------|----------| | qysj | ymyy | ygtx | bztk | ympd | ymfl | @@ -405,7 +409,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | Steam 最新折扣 | Steam 热门游戏折扣 | Steam 热门中文游戏折扣 | Steam 历史低价 | Steam 中文游戏历史低价 | -| -------------- | ------------------ | ---------------------- | -------------- | ---------------------- | +|----------------|--------------------|------------------------|----------------|------------------------| | new | hot | hot_chinese | low | low_chinese | @@ -431,7 +435,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 推游 | 游戏史 | 大事件 | 文化 | 趣闻 | 经典回顾 | -| --------- | ------- | ------ | ------- | ---- | -------- | +|-----------|---------|--------|---------|------|----------| | recommend | history | big | culture | news | retro | @@ -449,7 +453,7 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的 | 新闻 | 公告 | 活动 | 广告 | 所有 | -| ---- | -------- | ------ | --------- | ---- | +|------|----------|--------|-----------|------| | news | announce | events | advertise | all | ## きららファンタジア|奇拉拉幻想曲 diff --git a/lib/router.js b/lib/router.js index 63cd09049..7c22f369a 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2175,6 +2175,7 @@ router.get('/dengekionline/:type?', require('./routes/dengekionline/new')); // 4Gamers router.get('/4gamers/category/:category', require('./routes/4gamers/category')); router.get('/4gamers/tag/:tag', require('./routes/4gamers/tag')); +router.get('/4gamers/topic/:topic', require('./routes/4gamers/topic')); // 大麦网 router.get('/damai/activity/:city/:category/:subcategory/:keyword?', require('./routes/damai/activity')); diff --git a/lib/routes/4gamers/tag.js b/lib/routes/4gamers/tag.js index cda07e1e6..bc9878bc2 100644 --- a/lib/routes/4gamers/tag.js +++ b/lib/routes/4gamers/tag.js @@ -7,7 +7,7 @@ module.exports = async (ctx) => { const list = response.data.data.results; ctx.state.data = { - title: `4Gamers- #${tag}`, + title: `4Gamers - #${tag}`, link: `https://www.4gamers.com.tw/news/tag/${encodeURIComponent(tag)}`, item: list.map((item) => ({ title: item.title, diff --git a/lib/routes/4gamers/topic.js b/lib/routes/4gamers/topic.js new file mode 100644 index 000000000..abad24d4e --- /dev/null +++ b/lib/routes/4gamers/topic.js @@ -0,0 +1,20 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const topic = ctx.params.topic; + + const response = await got.get(`https://www.4gamers.com.tw/site/api/news/option-cfg/${topic}?pageSize=25`); + const list = response.data.data.results; + + ctx.state.data = { + title: `4Gamers - ${topic}`, + link: `https://www.4gamers.com.tw/news/option-cfg/${topic}`, + item: list.map((item) => ({ + title: item.title, + author: item.author.nickname, + description: `

${item.intro}

`, + pubDate: new Date(item.createPublishedAt * 1), + link: item.canonicalUrl, + })), + }; +};