fix(route): use `list = await Promise.all(...)` instead of `await Promise.all(...)`; (#9985)
* feat(fix): use `list = await Promise.all(...)` instead of `await Promise.all(..)` * feat: use `const` instead of `let` for items * fix: scitation * revert: scitation * update
This commit is contained in:
parent
e8266add8f
commit
d581d778c6
|
|
@ -37,7 +37,7 @@ module.exports = async (ctx) => {
|
|||
art(path.join(__dirname, 'templates/description.art'), {
|
||||
item,
|
||||
});
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response2 = await got(`${host}/science/article/pii/${item.id}`, {
|
||||
|
|
@ -57,6 +57,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: `${jrnlName} - ${issue}`,
|
||||
link: issueUrl,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ module.exports = async (ctx) => {
|
|||
art(path.join(__dirname, 'templates/description.art'), {
|
||||
item,
|
||||
});
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response3 = await got(`${host}/science/article/pii/${item.id}`, {
|
||||
|
|
@ -67,6 +67,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: jrnlName,
|
||||
link: jrnlUrl,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ module.exports = async (ctx) => {
|
|||
})
|
||||
.get();
|
||||
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (item.link.indexOf('info') !== -1) {
|
||||
|
|
@ -68,6 +68,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: '工学-' + bigTitle,
|
||||
link: toUrl,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module.exports = async (ctx) => {
|
|||
})
|
||||
.get();
|
||||
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (item.link.indexOf('HrbeuJY') !== -1) {
|
||||
|
|
@ -65,6 +65,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: '就业服务平台-' + idMap[id].name,
|
||||
link: idMap[id].url,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ module.exports = async (ctx) => {
|
|||
})
|
||||
.get();
|
||||
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (item.link.indexOf('page.htm') !== -1) {
|
||||
|
|
@ -57,6 +57,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: '水声学院-' + bigTitle,
|
||||
link: rootUrl.concat('/', id, '/list.htm'),
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ module.exports = async (ctx) => {
|
|||
})
|
||||
.get();
|
||||
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
if (item.link.indexOf('page.htm') !== -1) {
|
||||
|
|
@ -60,6 +60,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: '研究生院-' + bigTitle,
|
||||
link: rootUrl.concat('/', id, '/list.htm'),
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ module.exports = async (ctx) => {
|
|||
art(path.join(__dirname, 'templates/description.art'), {
|
||||
item,
|
||||
});
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response2 = await got.post(`${host}/action/PB2showAjaxAbstract`, {
|
||||
|
|
@ -62,6 +62,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: jrnlName,
|
||||
link: jrnlUrl,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -25,13 +25,13 @@ module.exports = async (ctx) => {
|
|||
}))
|
||||
.get();
|
||||
|
||||
let list;
|
||||
let ifContainSection = false;
|
||||
for (let i = 0, l = section.length; i < l; i++) {
|
||||
if (section[i].name === sec) {
|
||||
ifContainSection = true;
|
||||
}
|
||||
}
|
||||
let list;
|
||||
if (ifContainSection === true) {
|
||||
const secUrl = `${issueUrl}?tocSection=${sec}`;
|
||||
const response2 = await got(secUrl, {
|
||||
|
|
@ -60,7 +60,7 @@ module.exports = async (ctx) => {
|
|||
art(path.join(__dirname, 'templates/description.art'), {
|
||||
item,
|
||||
});
|
||||
await Promise.all(
|
||||
list = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response3 = await got.post(host.concat('/action/PB2showAjaxAbstract'), {
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ module.exports = async (ctx) => {
|
|||
art(path.join(__dirname, 'templates/description.art'), {
|
||||
item,
|
||||
});
|
||||
await Promise.all(
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response3 = await got(item.link, {
|
||||
|
|
@ -67,6 +67,6 @@ module.exports = async (ctx) => {
|
|||
ctx.state.data = {
|
||||
title: jrnlName,
|
||||
link: jrnlUrl,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue