feat: 期刊路由优化,增加 scihub 模式 (#4094)

This commit is contained in:
Henry Wang
2020-03-01 04:24:31 +00:00
committed by GitHub
parent 70b333c400
commit 19fa95d553
25 changed files with 194 additions and 241 deletions

View File

@@ -186,7 +186,7 @@ module.exports = async (ctx, next) => {
});
}
// fulltest
// fulltext
if (ctx.query.mode && ctx.query.mode.toLowerCase() === 'fulltext') {
const tasks = ctx.state.data.item.map(async (item) => {
const { link, author, description } = item;
@@ -209,6 +209,14 @@ module.exports = async (ctx, next) => {
});
await Promise.all(tasks);
}
// scihub
if (ctx.query.scihub) {
ctx.state.data.item.map((item) => {
item.link = item.doi ? `https://sci-hub.tw/${item.doi}` : `https://sci-hub.tw/${item.link}`;
return item;
});
}
}
}
};