fix(route): 小黑盒 - 用户动态 (#7987)
Co-authored-by: SettingDust <settingdust@gmail.com>
This commit is contained in:
parent
0e93b51f6e
commit
91f48eb298
22
docs/game.md
22
docs/game.md
|
|
@ -206,9 +206,9 @@ pageClass: routes
|
|||
|
||||
支持的主机平台:
|
||||
|
||||
| PS 4 | Xbox One | Switch | PC | Wii U | 3DS | PS Vita | iOS |
|
||||
| ---- | -------- | ------ | -- | ----- | --- | ------- | --- |
|
||||
| ps4 | xboxone | switch | pc | wii-u | 3ds | vita | ios |
|
||||
| PS 4 | Xbox One | Switch | PC | Wii U | 3DS | PS Vita | iOS |
|
||||
| ---- | -------- | ------ | --- | ----- | --- | ------- | --- |
|
||||
| ps4 | xboxone | switch | pc | wii-u | 3ds | vita | ios |
|
||||
|
||||
发行类型,默认为 `new`:
|
||||
|
||||
|
|
@ -372,8 +372,8 @@ Example: `https://store.steampowered.com/search/?specials=1&term=atelier` 中的
|
|||
Steam 新闻中心支持官方的 RSS 订阅:
|
||||
|
||||
- 新闻中心首页订阅地址为:<https://store.steampowered.com/feeds/news/?l=schinese> 其中参数 `l=english` 指定语言,`l=schinese` 为简体中文。
|
||||
- Steam 游戏新闻可以在该游戏的 RSS 按钮订阅: <https://store.steampowered.com/news/app/648800/> ,获取的订阅链接类似为: <https://store.steampowered.com/feeds/news/app/648800/?cc=US&l=english>
|
||||
- STEAM 组可以在 Steam 社区链接尾部添加 `/rss` 订阅: <https://steamcommunity.com/groups/SteamLabs/rss> 或者在 Steam 新闻中心的 URL 里添加 `/feeds` 订阅 <https://store.steampowered.com/feeds/news/group/35143931/>
|
||||
- Steam 游戏新闻可以在该游戏的 RSS 按钮订阅: <https://store.steampowered.com/news/app/648800/> ,获取的订阅链接类似为: <https://store.steampowered.com/feeds/news/app/648800/?cc=US&l=english>
|
||||
- STEAM 组可以在 Steam 社区链接尾部添加 `/rss` 订阅: <https://steamcommunity.com/groups/SteamLabs/rss> 或者在 Steam 新闻中心的 URL 里添加 `/feeds` 订阅 <https://store.steampowered.com/feeds/news/group/35143931/>
|
||||
|
||||
:::
|
||||
|
||||
|
|
@ -417,9 +417,9 @@ Steam 新闻中心支持官方的 RSS 订阅:
|
|||
|
||||
<Route author="Arracc" example="/gamer/gnn/1" path="/gamer/gnn/:category?" :paramsDesc="['版块']">
|
||||
|
||||
| 首頁 | PC | TV 掌機 | 手機遊戲 | 動漫畫 | 主題報導 | 活動展覽 | 電競 |
|
||||
| ---- | -- | ------- | -------- | ------ | -------- | -------- | ---- |
|
||||
| 缺省 | 1 | 3 | 4 | 5 | 9 | 11 | 13 |
|
||||
| 首頁 | PC | TV 掌機 | 手機遊戲 | 動漫畫 | 主題報導 | 活動展覽 | 電競 |
|
||||
| ---- | --- | ------- | -------- | ------ | -------- | -------- | ---- |
|
||||
| 缺省 | 1 | 3 | 4 | 5 | 9 | 11 | 13 |
|
||||
|
||||
| Switch | PS5 | PS4 | XboxOne | XboxSX | PC 單機 | PC 線上 | iOS | Android | Web | 漫畫 | 動畫 |
|
||||
| ------ | --- | --- | ------- | ------ | ------- | ------- | --- | ------- | --- | ----- | ----- |
|
||||
|
|
@ -487,11 +487,11 @@ Steam 新闻中心支持官方的 RSS 订阅:
|
|||
|
||||
| 炉石传说 | 万智牌 | 游戏王 | 昆特牌 | 影之诗 | 符文之地传奇 | 阴阳师百闻牌 |
|
||||
| :------: | :----: | :----: | :----: | :----: | :----------: | :----------: |
|
||||
| 17 | 18 | 16 | 19 | 20 | 329 | 221 |
|
||||
| 17 | 18 | 16 | 19 | 20 | 329 | 221 |
|
||||
|
||||
| 英雄联盟 | 电子游戏 | 桌面游戏 | 卡牌游戏 | 玩家杂谈 | 二次元 |
|
||||
| :------: | :------: | :------: | :------: | :------: | :----: |
|
||||
| 112 | 389 | 24 | 102 | 23 | 117 |
|
||||
| 112 | 389 | 24 | 102 | 23 | 117 |
|
||||
|
||||
</Route>
|
||||
|
||||
|
|
@ -575,7 +575,7 @@ Example:`https://www.iyingdi.com/tz/people/55547` ,id 是 `55547`
|
|||
|
||||
### 用户动态
|
||||
|
||||
<Route author="LogicJake" example="/xiaoheihe/user/7775687" path="xiaoheihe/user/:id" :paramsDesc="['用户 id']"/>
|
||||
<Route author="auto-bot-ty" example="/xiaoheihe/user/7775687" path="xiaoheihe/user/:id" :paramsDesc="['用户 id']"/>
|
||||
|
||||
### 游戏新闻
|
||||
|
||||
|
|
|
|||
|
|
@ -1,40 +1,51 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
const { id } = ctx.params;
|
||||
const limit = parseInt(ctx.query.limit) || 10;
|
||||
const rootUrl = 'https://api.xiaoheihe.cn';
|
||||
const currentUrl = `${rootUrl}/bbs/web/profile/post/links?userid=${id}&limit=${limit}&offset=0&version=999.0.0`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `https://api.xiaoheihe.cn/bbs/web/profile/post/links?userid=${id}&limit=10&offset=0&version=999.0.0`,
|
||||
});
|
||||
const user_data = response.data.user;
|
||||
const post_data = response.data.post_links;
|
||||
const user_name = user_data.username;
|
||||
const data = await got(currentUrl).then((response) => response.data);
|
||||
const username = data.user.username;
|
||||
const articleList = data.post_links.map((post) => ({
|
||||
title: post.title || post.description,
|
||||
pubDate: parseDate(post.create_at * 1000),
|
||||
link: post.share_url,
|
||||
linkId: post.linkid,
|
||||
}));
|
||||
|
||||
const out = await Promise.all(
|
||||
post_data.map(async (post) => {
|
||||
const title = post.description;
|
||||
const date = post.create_at;
|
||||
const itemUrl = `https://xiaoheihe.cn/community/7216/list/${post.linkid}`;
|
||||
const items = await Promise.all(
|
||||
articleList.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const url = `${rootUrl}/bbs/app/api/share/data/?offset=0&limit=3&link_id=${item.linkId}&os_type=web`;
|
||||
const link = await got(url).then((response) => response.data.link);
|
||||
const content = link.content;
|
||||
const video = link.video;
|
||||
let description;
|
||||
|
||||
const response = await got.get(itemUrl);
|
||||
const $ = cheerio.load(response.data);
|
||||
const description = $('.post-content').html();
|
||||
|
||||
const single = {
|
||||
title,
|
||||
link: itemUrl,
|
||||
description,
|
||||
pubDate: new Date(date * 1000).toUTCString(),
|
||||
};
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
for (const item of content) {
|
||||
if (item.type === 'html') {
|
||||
const $ = cheerio.load(item.text, { decodeEntities: false });
|
||||
$('[data-gameid]').each((i, e) => $(e).remove());
|
||||
$('[data-original]').each((i, e) => $(e).replaceWith(`<img src = "${$(e).attr('data-original')}">`));
|
||||
description = $.html();
|
||||
}
|
||||
}
|
||||
if (video) {
|
||||
description = `<video src="${video.video_url}" poster="${video.thumb}" controls="controls"></video>`;
|
||||
}
|
||||
item.description = description;
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${user_name}的动态`,
|
||||
title: `${username} 的动态`,
|
||||
link: `https://xiaoheihe.cn/community/user/${id}/post_list`,
|
||||
item: out,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue