fix(router/u9a9): return cache if need (#14537)
This commit is contained in:
+13
-13
@@ -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) => {
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user