feat: 添加4Gamers新闻 (#3224)
This commit is contained in:
parent
54d5cd9fc4
commit
d941d9d8aa
10
docs/game.md
10
docs/game.md
|
|
@ -20,6 +20,16 @@ pageClass: routes
|
|||
|
||||
</Route>
|
||||
|
||||
## 4Gamers 新闻
|
||||
|
||||
### 分类
|
||||
|
||||
<Route author="hoilc" example="/4gamers/category/352" path="/4gamers/category/:category" :paramsDesc="['分类 ID, 可从分类 URL 中找到']"/>
|
||||
|
||||
### 标签
|
||||
|
||||
<Route author="hoilc" example="/4gamers/tag/英雄聯盟" path="/4gamers/tag/:tag" :paramsDesc="['标签名, 可在标签 URL 中找到']"/>
|
||||
|
||||
## a9vgNews 游戏新闻
|
||||
|
||||
### a9vgNews 游戏新闻
|
||||
|
|
|
|||
|
|
@ -1807,6 +1807,10 @@ router.get('/kzfeed/topic/:id', require('./routes/kzfeed/topic'));
|
|||
// 腾讯新闻较真查证平台
|
||||
router.get('/factcheck', require('./routes/tencent/factcheck'));
|
||||
|
||||
// 4Gamers
|
||||
router.get('/4gamers/category/:category', require('./routes/4gamers/category'));
|
||||
router.get('/4gamers/tag/:tag', require('./routes/4gamers/tag'));
|
||||
|
||||
// 大麦网
|
||||
router.get('/damai/activity/:city/:category/:subcategory/:keyword?', require('./routes/damai/activity'));
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const category = ctx.params.category;
|
||||
|
||||
const response = await got.get(`https://www.4gamers.com.tw/site/api/news/by-category/${category}?pageSize=25`);
|
||||
const list = response.data.data.results;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `4Gamers - ${list[0].category.name}`,
|
||||
link: `https://www.4gamers.com.tw/news/category/${category}/`,
|
||||
item: list.map((item) => ({
|
||||
title: item.title,
|
||||
author: item.author.nickname,
|
||||
description: `<img src="${item.smallBannerUrl}" /><p>${item.intro}</p>`,
|
||||
pubDate: new Date(item.createPublishedAt * 1),
|
||||
link: item.canonicalUrl,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const tag = ctx.params.tag;
|
||||
|
||||
const response = await got.get(`https://www.4gamers.com.tw/site/api/news/by-tag?tag=${encodeURIComponent(tag)}&pageSize=25`);
|
||||
const list = response.data.data.results;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `4Gamers- #${tag}`,
|
||||
link: `https://www.4gamers.com.tw/news/tag/${encodeURIComponent(tag)}`,
|
||||
item: list.map((item) => ({
|
||||
title: item.title,
|
||||
author: item.author.nickname,
|
||||
description: `<img src="${item.smallBannerUrl}" /><p>${item.intro}</p>`,
|
||||
pubDate: new Date(item.createPublishedAt * 1),
|
||||
link: item.canonicalUrl,
|
||||
})),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue