Skip to content

Commit

Permalink
fix(router/u9a9): return cache if need (DIYgod#14537)
Browse files Browse the repository at this point in the history
  • Loading branch information
storytellerF authored Feb 23, 2024
1 parent 79d391b commit 65ba168
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/v2/u9a9/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ module.exports = async (ctx) => {
const { data: response } = await got(link);
const $ = cheerio.load(response);

const items = $('table tr')
const list = $('table tr')
.slice(1) // skip thead
.toArray()
.map((item) => {
Expand All @@ -43,20 +43,20 @@ module.exports = async (ctx) => {
};
});

if (preview) {
await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);
const items = preview
? await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = cheerio.load(response);

item.description = $('.panel-body').eq(1).html();
item.description = $('.panel-body').eq(1).html();

return item;
})
)
);
}
return item;
})
)
)
: list;

ctx.state.data = {
title,
Expand Down

0 comments on commit 65ba168

Please sign in to comment.