feat: v3 migration - 4/n

This commit is contained in:
DIYgod 2024-02-28 16:51:42 +08:00
parent fdf3fcac57
commit 7a719369be
No known key found for this signature in database
1158 changed files with 2591 additions and 1434 deletions

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -24,7 +25,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { art } from '@/utils/render';
const path = require('path');
@ -18,8 +19,8 @@ async function getJSESSIONID(linkUrl) {
return res.headers['set-cookie'].join(',').match(/JSESSIONID=([^;]+);/)[0];
}
function getStationInfo(stationName, ctx) {
return ctx.cache.tryGet(stationName, async () => {
function getStationInfo(stationName) {
return cache.tryGet(stationName, async () => {
const res = await got({
method: 'get',
url: `${rootUrl}/otn/resources/js/framework/station_name.js`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const url = require('url');
@ -29,9 +30,9 @@ module.exports = async (ctx) => {
const date = info.date;
const itemUrl = url.resolve(link, info.link);
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return JSON.parse(cache);
const cacheIn = await cache.get(itemUrl);
if (cacheIn) {
return JSON.parse(cacheIn);
}
const response = await got.get(itemUrl);
@ -45,7 +46,7 @@ module.exports = async (ctx) => {
description,
pubDate: new Date(date).toUTCString(),
};
ctx.cache.set(itemUrl, JSON.stringify(single));
cache.set(itemUrl, JSON.stringify(single));
return single;
})
);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
@ -17,7 +18,7 @@ module.exports = async (ctx) => {
imgsrc: e.imgsrc,
}));
const items = await Promise.all(list.map((e) => parseDyArticle(charset, e, ctx.cache.tryGet)));
const items = await Promise.all(list.map((e) => parseDyArticle(charset, e, cache.tryGet)));
ctx.set('data', {
title: `网易号 - ${list[0].author}`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@ -29,7 +30,7 @@ module.exports = async (ctx) => {
};
});
const items = await Promise.all(list.map((item) => parseDyArticle(charset, item, ctx.cache.tryGet)));
const items = await Promise.all(list.map((item) => parseDyArticle(charset, item, cache.tryGet)));
ctx.set('data', {
title: `${$('head title').text()} - 网易号`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -96,7 +97,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
try {
if (item.videoId) {
const detailResponse = await got({

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@ -110,7 +111,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
try {
let link;
if (category === 'auto' || category === 'house' || category === 'travel') {

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
@ -91,7 +92,7 @@ module.exports = async (ctx) => {
url = `https://3g.163.com/exclusive/video/${vid[1]}.html`;
}
}
return ctx.cache.tryGet(url, async () => {
return cache.tryGet(url, async () => {
const article_response = await got(url);
const $ = load(article_response.data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -28,7 +29,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const {
data: { data },
} = await got.post(`${url}/open/trade/pc/course/getCourseInfo.do`, {

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@ -50,7 +51,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -25,7 +26,7 @@ module.exports = async (ctx) => {
if (needContent) {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -47,7 +48,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.guid, async () => {
cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.guid, async () => {
cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -42,7 +43,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.guid, async () => {
cache.tryGet(item.guid, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -46,7 +47,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -28,7 +29,7 @@ module.exports = async (ctx) => {
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
@ -12,6 +13,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: `一亩三分地 - ${id}${types[type]}`,
link: currentUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
item: await ProcessThreads(cache.tryGet, apiUrl, order),
});
};

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
const sections = {
@ -23,6 +24,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: `一亩三分地 - ${Object.hasOwn(sections, id) ? sections[id] : id}${types[type]}`,
link: currentUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
item: await ProcessThreads(cache.tryGet, apiUrl, order),
});
};

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
const { rootUrl, apiRootUrl, types, ProcessThreads } = require('./utils');
module.exports = async (ctx) => {
@ -10,6 +11,6 @@ module.exports = async (ctx) => {
ctx.set('data', {
title: `一亩三分地 - ${types[type]}`,
link: rootUrl,
item: await ProcessThreads(ctx.cache.tryGet, apiUrl, order),
item: await ProcessThreads(cache.tryGet, apiUrl, order),
});
};

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const rootUrl = 'https://hjd2048.com';
const entranceDomain = await ctx.cache.tryGet('2048:entranceDomain', async () => {
const entranceDomain = await cache.tryGet('2048:entranceDomain', async () => {
const { data: response } = await got('https://hjd.tw', {
headers: {
accept: '*/*',
@ -52,7 +53,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.guid, async () => {
cache.tryGet(item.guid, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -34,7 +35,7 @@ module.exports = async (ctx) => {
// console.log(list);
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link, {
responseType: 'buffer',
});

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@ -49,7 +50,7 @@ module.exports = async (ctx) => {
};
});
items = await Promise.all(items.map((item) => ProcessItem(item, ctx.cache.tryGet)));
items = await Promise.all(items.map((item) => ProcessItem(item, cache.tryGet)));
ctx.set('data', {
title: `36氪 - ${categories[category].title}`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -42,7 +43,7 @@ module.exports = async (ctx) => {
});
if (!/^\/(search|newsflashes)/.test(path)) {
items = await Promise.all(items.map((item) => ProcessItem(item, ctx.cache.tryGet)));
items = await Promise.all(items.map((item) => ProcessItem(item, cache.tryGet)));
}
ctx.set('data', {

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
};
});
const items = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
const items = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: $('head title').text().split('_')[0],

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -31,7 +32,7 @@ module.exports = async (ctx) => {
};
});
const out = await Promise.all(list.map((item) => parseArticle(item, ctx.cache.tryGet)));
const out = await Promise.all(list.map((item) => parseArticle(item, cache.tryGet)));
ctx.set('data', {
title: '3DM - ' + $('title').text().split('_')[0],

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -83,7 +84,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map(async (item) => {
item = await ctx.cache.tryGet(item.link, async () => {
item = await cache.tryGet(item.link, async () => {
const detailResponse = await got.get(item.link);
const $ = load(detailResponse.data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseList, parseItem, getCategories } = require('./utils');
@ -14,12 +15,12 @@ module.exports = async (ctx) => {
});
const list = parseList(response.data.results);
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
let categories = [];
let categoryName = '最新消息';
if (!isLatest) {
categories = await getCategories(ctx.cache.tryGet);
categories = await getCategories(cache.tryGet);
categoryName = categories.find((c) => c.id === Number.parseInt(category)).name;
}

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseList, parseItem } = require('./utils');
@ -13,7 +14,7 @@ module.exports = async (ctx) => {
});
const list = parseList(response.data.results);
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('data', {
title: `4Gamers - #${tag}`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseList, parseItem } = require('./utils');
@ -12,7 +13,7 @@ module.exports = async (ctx) => {
});
const list = parseList(response.data.results);
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseItem(item))));
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseItem(item))));
ctx.set('data', {
title: `4Gamers - ${topic}`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -34,7 +35,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
const path = require('path');
@ -8,8 +9,8 @@ module.exports = async (ctx) => {
const { id } = ctx.params;
const limit = Number.parseInt(ctx.req.query('limit')) || 100;
const { tribe } = await getTribeDetail(id, ctx.cache.tryGet);
const tribeSets = await getTribeSets(id, limit, ctx.cache.tryGet);
const { tribe } = await getTribeDetail(id, cache.tryGet);
const tribeSets = await getTribeSets(id, limit, cache.tryGet);
const items = tribeSets.map((item) => ({
title: item.title,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { art } from '@/utils/render';
import { parseDate } from '@/utils/parse-date';
const path = require('path');
@ -8,11 +9,11 @@ module.exports = async (ctx) => {
const limit = Number.parseInt(ctx.req.query('limit')) || 100;
if (id.length !== 33) {
id = (await getUserInfoFromUsername(id, ctx.cache.tryGet)).id;
id = (await getUserInfoFromUsername(id, cache.tryGet)).id;
}
const userInfo = await getUserInfoFromId(id, ctx.cache.tryGet);
const userWorks = await getUserWorks(id, limit, ctx.cache.tryGet);
const userInfo = await getUserInfoFromId(id, cache.tryGet);
const userWorks = await getUserWorks(id, limit, cache.tryGet);
const items = userWorks.map((item) => ({
title: item.title || '无题',

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -31,7 +32,7 @@ module.exports = async (ctx) => {
out = await Promise.all(
out.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const result = await got(item.link);
const $ = load(result.data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -34,7 +35,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
const { rootUrl, fetchItems } = require('./util');
module.exports = async (ctx) => {
@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const currentUrl = new URL(`class/${category}.html`, rootUrl).href;
ctx.set('data', await fetchItems(limit, currentUrl, ctx.cache.tryGet));
ctx.set('data', await fetchItems(limit, currentUrl, cache.tryGet));
};

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
const { rootUrl, fetchItems } = require('./util');
module.exports = async (ctx) => {
@ -6,5 +7,5 @@ module.exports = async (ctx) => {
const currentUrl = new URL(`top/${category.split(/_/)[0]}_1.html`, rootUrl).href;
ctx.set('data', await fetchItems(limit, currentUrl, ctx.cache.tryGet));
ctx.set('data', await fetchItems(limit, currentUrl, cache.tryGet));
};

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { load } from 'cheerio';
const zlib = require('zlib');
import got from '@/utils/got';
@ -16,7 +17,7 @@ module.exports = async (ctx) => {
});
// get acw_sc__v2
const acw_sc__v2 = await ctx.cache.tryGet(
const acw_sc__v2 = await cache.tryGet(
articleUrl,
async () => {
// Zlib Z_BUF_ERROR: unexpected end of file, should close decompress
@ -52,7 +53,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
response.data.list.map((item) =>
ctx.cache.tryGet(item.jump_link, async () => {
cache.tryGet(item.jump_link, async () => {
if (!acw_sc__v2) {
return {
title: item.title,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -36,7 +37,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -42,7 +43,7 @@ module.exports = async (ctx) => {
items
.filter((item) => /6parknews\.com/.test(item.link))
.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
try {
const detailResponse = await got({
method: 'get',

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const iconv = require('iconv-lite');
import { load } from 'cheerio';
@ -49,7 +50,7 @@ const utils = {
const itemUrl = 'https://www.hao6v.cc' + link.attr('href');
return ctx.cache.tryGet(itemUrl, async () => {
return cache.tryGet(itemUrl, async () => {
const detailInfo = await utils.loadDetailPage(itemUrl);
if (detailInfo.enclosure_urls.length > 1) {

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -32,7 +33,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -37,7 +38,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -31,7 +32,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@ -38,7 +39,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
});

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
@ -15,7 +16,7 @@ module.exports = async (ctx) => {
item: await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
const { href } = load(e)('h2 > a')[0].attribs;
return ctx.cache.tryGet(href, () => loadArticle(href));
return cache.tryGet(href, () => loadArticle(href));
})
),
});

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
@ -16,7 +17,7 @@ module.exports = async (ctx) => {
(await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
const { href } = load(e)('h2 > a')[0].attribs;
return ctx.cache.tryGet(href, () => loadArticle(href));
return cache.tryGet(href, () => loadArticle(href));
})
)),
});

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { SUB_NAME_PREFIX, SUB_URL } = require('./const');
@ -16,7 +17,7 @@ module.exports = async (ctx) => {
item: await Promise.all(
(limit ? itemRaw.slice(0, limit) : itemRaw).map((e) => {
const { href } = load(e)('h2 > a')[0].attribs;
return ctx.cache.tryGet(href, () => loadArticle(href));
return cache.tryGet(href, () => loadArticle(href));
})
),
});

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -28,7 +29,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
const $ = load(data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
cache.tryGet(`91porn:${lang}:${new URL(item.link).searchParams.get('viewkey')}`, async () => {
const { data } = await got(item.link);
const $ = load(data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@ -34,7 +35,7 @@ module.exports = {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const parser = require('@/utils/rss-parser');
const utils = require('./utils');
@ -41,7 +42,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
feed.items.splice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 10).map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const response = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -29,7 +30,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -67,7 +68,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
try {
const { data: detailResponse } = await got(item.link);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({ method: 'get', url: item.link });
const $detail = load(detailResponse.data);
$detail('article.post-content').find('.lwptoc').remove();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -70,7 +71,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const response = await got(item.link, {
headers: {
referer: url,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@ -14,7 +15,7 @@ module.exports = async (ctx) => {
let title = '';
const browser = await puppeteer();
const items = await ctx.cache.tryGet(
const items = await cache.tryGet(
currentUrl,
async () => {
const page = await browser.newPage();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -44,7 +45,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { art } from '@/utils/render';
@ -6,7 +7,7 @@ const path = require('path');
const getData = async (ctx, list) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { rootUrl } = require('./utils');
@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got(item.link);
const content = load(detailResponse.data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseArticle } = require('./utils');
@ -19,7 +20,7 @@ module.exports = async (ctx) => {
};
});
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseArticle(item))));
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseArticle(item))));
ctx.set('data', {
title: $('head title').text().trim(),

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const { baseUrl, parseArticle } = require('./utils');
@ -19,7 +20,7 @@ module.exports = async (ctx) => {
};
});
const items = await Promise.all(list.map((item) => ctx.cache.tryGet(item.link, () => parseArticle(item))));
const items = await Promise.all(list.map((item) => cache.tryGet(item.link, () => parseArticle(item))));
ctx.set('data', {
title: $('head title').text().trim(),

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
$('h1').remove();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -33,7 +34,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,10 +1,11 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseRelativeDate, parseDate } from '@/utils/parse-date';
import { load } from 'cheerio';
const parseArticle = (item, ctx) => {
const parseArticle = (item) => {
const articleUrl = `https://aijishu.com${item.url || item.object.url}`;
return ctx.cache.tryGet(articleUrl, async () => {
return cache.tryGet(articleUrl, async () => {
const d1 = parseDate(item.createdDate, ['YYYY-MM-DD', 'M-DD']);
const d2 = parseRelativeDate(item.createdDate);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { load } from 'cheerio';
const { puppeteerGet, renderDesc } = require('./utils');
import { config } from '@/config';
@ -16,7 +17,7 @@ module.exports = async (ctx) => {
// use Puppeteer due to the obstacle by cloudflare challenge
const browser = await puppeteer();
const { jrnlName, list } = await ctx.cache.tryGet(
const { jrnlName, list } = await cache.tryGet(
jrnlUrl,
async () => {
const response = await puppeteerGet(jrnlUrl, browser);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const buildData = require('@/utils/common-config');
@ -26,7 +27,7 @@ module.exports = async (ctx) => {
await Promise.all(
ctx.state.data.item.map(async (item) => {
const detailLink = baseUrl + item.link;
item.description = await ctx.cache.tryGet(detailLink, async () => {
item.description = await cache.tryGet(detailLink, async () => {
const result = await got(detailLink);
const $ = load(result.data);
return $('.serviceMsg').html();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -34,7 +35,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $('div.tips').text(),

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@ -38,7 +39,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $('div.thinktank-author-description-box p').text(),

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -33,7 +34,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
language: 'zh-cn',

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -34,7 +35,7 @@ module.exports = async (ctx) => {
});
ctx.set('data', {
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
item: await ProcessFeed(limit, cache.tryGet, items),
title: `爱思想 - ${title}`,
link: currentUrl,
description: $('div.tips p').text(),

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: `${rootUrl}/ch/getArticle`,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
list.map((item) => {
const link = item.link;
return ctx.cache.tryGet(link, async () => {
return cache.tryGet(link, async () => {
const itemReponse = await got(link);
const itemElement = load(itemReponse.data);
item.description = itemElement('.content').html();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -38,7 +39,7 @@ module.exports = async (ctx) => {
const result = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const itemReponse = await got(item.link);
const itemElement = load(itemReponse.data);
item.description = itemElement('#se-knowledge').html();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -55,7 +56,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 50).map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@ -55,7 +56,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $ = load(response.data);
// fix weird format

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -41,7 +42,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.guid, async () => {
cache.tryGet(item.guid, async () => {
const apiUrl = `${apiRootUrl}/works/${item.doi}`;
const detailResponse = await got({

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -18,7 +19,7 @@ module.exports = async (ctx) => {
title: item.title,
description:
fulltext === 'fulltext' || fulltext === 'quanwen'
? await ctx.cache.tryGet(art_url, async () => {
? await cache.tryGet(art_url, async () => {
const { data: res } = await got(art_url);
const content = load(res);
return content('#js-article').html();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const articles = await getArticles();
const items = await Promise.all(
articles.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: res } = await got(item.link);
const $ = load(res);
const json = JSON.parse($('#__NEXT_DATA__').text());

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import timezone from '@/utils/timezone';
@ -19,7 +20,7 @@ module.exports = async (ctx) => {
}))
.filter((e) => typeof e.link === 'string')
.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: response } = await got(item.link);
const $ = load(response);
$('div.Enhancement').remove();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { art } from '@/utils/render';
@ -42,7 +43,7 @@ module.exports = async (ctx) => {
const md = new MarkdownIt();
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const releaseResponse = await got(item.link);
const releaseInfo = releaseResponse.data;

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const out = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const response = await got(item.link);
const $$ = load(response.data);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -29,7 +30,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -18,7 +19,7 @@ module.exports = async (ctx) => {
announceList = await Promise.all(
announceList.map((item) =>
ctx.cache.tryGet(item.webUrl, async () => {
cache.tryGet(item.webUrl, async () => {
const { data } = await got({
method: 'get',
url: item.webUrl,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -19,7 +20,7 @@ module.exports = async (ctx) => {
.map(async (index, item) => {
item = $(item);
const link = `https://ak.hypergryph.com${item.attr('href')}`;
const description = await ctx.cache.tryGet(link, async () => {
const description = await cache.tryGet(link, async () => {
const result = await got(link);
const $ = load(result.data);
return $('.article-content').html();

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const path = require('path');
@ -14,7 +15,7 @@ module.exports = async (ctx) => {
'user-agent': config.trueUA,
};
const csrfToken = await ctx.cache.tryGet('artstation:csrfToken', async () => {
const csrfToken = await cache.tryGet('artstation:csrfToken', async () => {
const tokenResponse = await got.post('https://www.artstation.com/api/v2/csrf_protection/token.json', {
headers,
});
@ -60,7 +61,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
if (item.assetsCount > 1 || !item.icons.image) {
const { data } = await got(`https://www.artstation.com/projects/${item.hashId}.json`, {
headers: {

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -61,7 +62,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link);
const content = load(detailResponse);

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -39,7 +40,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const iconv = require('iconv-lite');
@ -35,7 +36,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data: detailResponse } = await got(item.link, {
responseType: 'buffer',
});

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const { baseUrl, apiHost, parseEventDetail, parseItem } = require('./utils');
@ -17,7 +18,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
item.description = await parseEventDetail(item);
return item;
})

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@ -36,7 +37,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
if (item.eventId) {
item.description = await parseEventDetail(item);
} else {

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
posts.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const { data } = await got(item.apiUrl);
const post = data.pageProps.post || data.pageProps.lockedPost;

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { art } from '@/utils/render';
@ -10,7 +11,7 @@ module.exports = async (ctx) => {
const url = `https://www.baidu.com/s?wd=${encodeURIComponent(keyword)}`;
const key = `baidu-search:${url}`;
const items = await ctx.cache.tryGet(
const items = await cache.tryGet(
key,
async () => {
const response = (await got(url)).data;

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
@ -22,7 +23,7 @@ module.exports = async (ctx) => {
const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,

View File

@ -1,3 +1,4 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
@ -23,7 +24,7 @@ module.exports = async (ctx) => {
tag_id = await Promise.all(
params.map((param) =>
ctx.cache.tryGet(param, async () => {
cache.tryGet(param, async () => {
const paramResponse = await got({
method: 'post',
url: tagUrl,
@ -61,7 +62,7 @@ module.exports = async (ctx) => {
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'post',
url: `${rootUrl}/api/tag/fetch`,

View File

@ -1,9 +1,10 @@
import cache from '@/utils/cache';
const getData = require('./_base');
import { art } from '@/utils/render';
const path = require('path');
module.exports = async (ctx) => {
const [list, data] = await getData(ctx.cache.tryGet);
const [list, data] = await getData(cache.tryGet);
const siteMeta = data.siteMeta;
const today = new Date(Date.now());

Some files were not shown because too many files have changed in this diff Show More