mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 01:30:33 +08:00
refactor: 重构方格子 vocus 全文缓存 (#2151)
* refactor: 重构方格子 vocus 全文缓存 * fix: return await Promise.all()
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const axios = require('@/utils/axios');
|
||||
const { ProcessFeed } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
@@ -20,36 +21,7 @@ module.exports = async (ctx) => {
|
||||
},
|
||||
})).data;
|
||||
|
||||
const items = await Promise.all(
|
||||
articles.map(async (item) => {
|
||||
const itemUrl = `https://api.sosreader.com/api/article/${item._id}`;
|
||||
|
||||
const cache = await ctx.cache.get(itemUrl);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: itemUrl,
|
||||
headers: {
|
||||
Referer: link,
|
||||
},
|
||||
});
|
||||
|
||||
const description = response.data.article.content;
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
link: `https://vocus.cc/@${id}/${item._id}`,
|
||||
author: item.user.fullname,
|
||||
description: description,
|
||||
pubDate: new Date(item.updatedAt).toUTCString(),
|
||||
};
|
||||
ctx.cache.set(itemUrl, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
const items = await ProcessFeed(articles, link, ctx.cache);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${fullname}的个人文章 - 方格子`,
|
||||
|
||||
Reference in New Issue
Block a user