Skip to content

Commit

Permalink
替换limit参数
Browse files Browse the repository at this point in the history
  • Loading branch information
ZenoTian committed Jan 3, 2024
1 parent 2e95bc2 commit 43c091a
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions lib/v2/hoyolab/news.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const getEventList = async ({ type, gids, size, language }) => {

const replaceImgDomain = (content) => content.replaceAll(PRIVATE_IMG, PUBLIC_IMG);

const getPostContent = (ctx, list, type, language) =>
const getPostContent = (ctx, list, { type, language }) =>
Promise.all(
list.map(async (row) => {
const post = row.post;
Expand Down Expand Up @@ -65,15 +65,16 @@ const getPostContent = (ctx, list, type, language) =>
);

module.exports = async (ctx) => {
const { type = '2', gids = '2', language = 'zh-cn', size = 15 } = ctx.params;
try {
const list = await getEventList({
type,
gids,
size,
language,
});
const items = await getPostContent(ctx, list, type, language);
const { type, gids, language } = ctx.params;
const params = {
type: type || '2',
gids: gids || '2',
size: parseInt(ctx.query?.limit) || 15,
language: language || 'zh-cn',
};
const list = await getEventList(params);
const items = await getPostContent(ctx, list, params);
ctx.state.data = {
title: `HoYoLAB-${GIDS_MAP[gids]}-${TYPE_MAP[type]}`,
link: LINK,
Expand Down

0 comments on commit 43c091a

Please sign in to comment.