From 70d40284c93c8bd745cd9e259ba29da3ee29d6db Mon Sep 17 00:00:00 2001 From: EsuRt <15177069+EsuRt@users.noreply.github.com> Date: Sun, 2 Feb 2020 13:58:12 +0800 Subject: [PATCH] fix: slice issue (#3855) --- lib/routes/gov/news/index.js | 2 +- lib/routes/gov/statecouncil/briefing.js | 35 ++++++++++++------------- lib/routes/gov/suzhou/doc.js | 2 +- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/lib/routes/gov/news/index.js b/lib/routes/gov/news/index.js index 4425cf7a5..806fd06db 100644 --- a/lib/routes/gov/news/index.js +++ b/lib/routes/gov/news/index.js @@ -44,7 +44,7 @@ module.exports = async (ctx) => { link: url, item: await Promise.all( list - .slice(1, 12) + .slice(0, 12) .map(async (index, item) => { item = $(item); let fullText = ''; diff --git a/lib/routes/gov/statecouncil/briefing.js b/lib/routes/gov/statecouncil/briefing.js index b52f3ddef..73744602b 100644 --- a/lib/routes/gov/statecouncil/briefing.js +++ b/lib/routes/gov/statecouncil/briefing.js @@ -11,24 +11,23 @@ module.exports = async (ctx) => { title: '国务院 - 吹风会', link: link, item: await Promise.all( - list && - list - .slice(1, 12) - .map(async (index, item) => { - item = $(item); - const contenlUrl = item.find('a').attr('href'); - const description = await ctx.cache.tryGet(contenlUrl, async () => { - const fullText = await got.get(contenlUrl); - const fullTextData = cheerio.load(fullText.data); - return fullTextData('.online_list').html(); - }); - return { - title: item.find('a').text(), - description: description, - link: contenlUrl, - }; - }) - .get() + list + .slice(0, 12) + .map(async (index, item) => { + item = $(item); + const contenlUrl = item.find('a').attr('href'); + const description = await ctx.cache.tryGet(contenlUrl, async () => { + const fullText = await got.get(contenlUrl); + const fullTextData = cheerio.load(fullText.data); + return fullTextData('.online_list').html(); + }); + return { + title: item.find('a').text(), + description: description, + link: contenlUrl, + }; + }) + .get() ), }; }; diff --git a/lib/routes/gov/suzhou/doc.js b/lib/routes/gov/suzhou/doc.js index f5763f96a..c3c8ab6be 100644 --- a/lib/routes/gov/suzhou/doc.js +++ b/lib/routes/gov/suzhou/doc.js @@ -13,7 +13,7 @@ module.exports = async (ctx) => { link: link, item: await Promise.all( list - .slice(1, 12) + .slice(0, 12) .map(async (index, item) => { item = $(item); // 获取全文