fix(route): Fix the issue of missing post cover in the official routing of Miyoushe; Optimize the data processing of posts | 修复 米游社官方路由中帖子封面缺失的问题;优化帖子的数据处理 (#14436)
* feat(route): 增加 米游社 - 用户关注动态 路由 * fix(route): 修复 路由、文档的风格问题 * docs: fix envs * fix(route): 修复 米游社官方路由中帖子封面缺失的问题;优化帖子的数据处理 ---------
This commit is contained in:
@@ -1,10 +1,6 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { DATA_MAP, RANKING_TYPE_MAP } = require('./static-data');
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
const { post2item } = require('./utils');
|
||||
|
||||
const getGameInfo = (game) => ({
|
||||
gids: DATA_MAP[game]?.gids,
|
||||
@@ -75,32 +71,7 @@ module.exports = async (ctx) => {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const title = `米游社-${game_title}-${forum_title}${cate_title ? `-${cate_title}` : ''}-${type_title}`;
|
||||
const items = list.map((e) => {
|
||||
const author = e.user.nickname;
|
||||
const title = e.post.subject;
|
||||
const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
let describe = e.post.content || '';
|
||||
try {
|
||||
describe = JSON.parse(e.post.content).describe;
|
||||
} catch (error) {
|
||||
if (!(error instanceof SyntaxError)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
const upvotes = e.stat.like_num;
|
||||
const comments = e.stat.reply_num;
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
upvotes,
|
||||
comments,
|
||||
};
|
||||
});
|
||||
const items = list.map((e) => post2item(e));
|
||||
const data = {
|
||||
title,
|
||||
link: url,
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { post2item } = require('./utils');
|
||||
// 游戏id
|
||||
const GITS_MAP = {
|
||||
1: '崩坏三',
|
||||
@@ -19,8 +17,6 @@ const TYPE_MAP = {
|
||||
3: '资讯',
|
||||
};
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { gids, type = '2', page_size = '20', last_id = '' } = ctx.params;
|
||||
const query = new URLSearchParams({
|
||||
@@ -39,20 +35,7 @@ module.exports = async (ctx) => {
|
||||
throw new Error('未获取到数据!');
|
||||
}
|
||||
const title = `米游社 - ${GITS_MAP[gids] || ''} - ${TYPE_MAP[type] || ''}`;
|
||||
const items = list.map((e) => {
|
||||
const author = e.user.nickname;
|
||||
const title = e.post.subject;
|
||||
const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
const description = renderDescription(e.post.content, e.post.images);
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
};
|
||||
});
|
||||
const items = list.map((e) => post2item(e));
|
||||
const data = {
|
||||
title,
|
||||
link: url,
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const cache = require('./cache');
|
||||
const config = require('@/config').value;
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
const { post2item } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
if (!config.mihoyo.cookie) {
|
||||
@@ -34,32 +30,7 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
const { nickname: username } = await cache.getUserFullInfo(ctx, '');
|
||||
const title = `米游社 - ${username} 的关注动态`;
|
||||
const items = list.map((e) => {
|
||||
const author = e.user.nickname;
|
||||
const title = e.post.subject;
|
||||
const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
let describe = e.post.content || '';
|
||||
try {
|
||||
describe = JSON.parse(e.post.content).describe;
|
||||
} catch (error) {
|
||||
if (!(error instanceof SyntaxError)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
const upvotes = e.stat.like_num;
|
||||
const comments = e.stat.reply_num;
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
upvotes,
|
||||
comments,
|
||||
};
|
||||
});
|
||||
const items = list.map((e) => post2item(e));
|
||||
|
||||
const data = {
|
||||
title,
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
const { post2item } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { uid } = ctx.params;
|
||||
@@ -25,32 +21,7 @@ module.exports = async (ctx) => {
|
||||
}
|
||||
const username = list[0]?.user.nickname;
|
||||
const title = `米游社 - ${username} 的发帖`;
|
||||
const items = list.map((e) => {
|
||||
const author = e.user.nickname;
|
||||
const title = e.post.subject;
|
||||
const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
let describe = e.post.content || '';
|
||||
try {
|
||||
describe = JSON.parse(e.post.content).describe;
|
||||
} catch (error) {
|
||||
if (!(error instanceof SyntaxError)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
const upvotes = e.stat.like_num;
|
||||
const comments = e.stat.reply_num;
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
upvotes,
|
||||
comments,
|
||||
};
|
||||
});
|
||||
const items = list.map((e) => post2item(e));
|
||||
|
||||
const data = {
|
||||
title,
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const renderDescription = (description, images) => art(path.join(__dirname, '../templates/description.art'), { description, images });
|
||||
|
||||
module.exports = {
|
||||
post2item(e) {
|
||||
const author = e.user.nickname;
|
||||
const title = e.post.subject;
|
||||
const link = `https://www.miyoushe.com/ys/article/${e.post.post_id}`;
|
||||
let describe = e.post.content || '';
|
||||
try {
|
||||
describe = JSON.parse(e.post.content).describe;
|
||||
} catch (error) {
|
||||
if (!(error instanceof SyntaxError)) {
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
const description = renderDescription(describe || '', [...new Set([e.post.cover, ...e.post.images])].filter(Boolean));
|
||||
const pubDate = parseDate(e.post.created_at * 1000);
|
||||
const upvotes = e.stat.like_num;
|
||||
const comments = e.stat.reply_num;
|
||||
return {
|
||||
author,
|
||||
title,
|
||||
link,
|
||||
description,
|
||||
pubDate,
|
||||
upvotes,
|
||||
comments,
|
||||
};
|
||||
},
|
||||
};
|
||||
@@ -12,9 +12,9 @@
|
||||
|
||||
<Route author="nczitzk" example="/cia/foia-annual-report" path="/cia/foia-annual-report" notOperational="1" />
|
||||
|
||||
## Constitutional Court of Baden-Württemberg (Germany) {#constitutional-court-of-baden-w%C3%BCrttemberg-germany}
|
||||
## Constitutional Court of Baden-Württemberg (Germany) {#constitutional-court-of-baden-wvrttemberg-germany}
|
||||
|
||||
### Press releases {#constitutional-court-of-baden-w%C3%BCrttemberg-germany-press-releases}
|
||||
### Press releases {#constitutional-court-of-baden-wvrttemberg-germany-press-releases}
|
||||
|
||||
<Route author="quinn-dev" example="/verfghbw/press" path="/verfghbw/press/:keyword?" paramsDesc={['Keyword']} notOperational="1" />
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@ See [#app-store-mac-app-store](/routes/program-update#app-store-mac-app-store)
|
||||
|
||||
<Route author="DIYgod" example="/scmp/coronavirus" path="/scmp/coronavirus" />
|
||||
|
||||
### Macao Pagina Electrónica Especial Contra Epidemias: What’s New {#corona-virus-disease-2019-macao-pagina-electr%C3%B3nica-especial-contra-epidemias-what-s-new}
|
||||
### Macao Pagina Electrónica Especial Contra Epidemias: What’s New {#corona-virus-disease-2019-macao-pagina-electronica-especial-contra-epidemias-what-s-new}
|
||||
|
||||
Official Website: [https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx](https://www.ssm.gov.mo/apps1/PreventWuhanInfection/en.aspx)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user