feat: replace require with import 2/n

This commit is contained in:
DIYgod 2024-03-06 23:56:33 +08:00
parent 156b58d780
commit 935649be9f
No known key found for this signature in database
89 changed files with 95 additions and 95 deletions

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
import { load } from 'cheerio';

View File

@ -32,4 +32,4 @@ const parseArticle = (item) => {
});
};
export { parseArticle };
export default { parseArticle };

View File

@ -2,7 +2,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate, parseRelativeDate } from '@/utils/parse-date';
module.exports = async (subjectID, minLength) => {
export default async (subjectID, minLength) => {
// bangumi.tv未提供获取“吐槽comments”的API因此仍需要通过抓取网页来获取
const link = `https://bgm.tv/subject/${subjectID}/comments`;
const { data: html } = await got(link);

View File

@ -7,7 +7,7 @@ import { art } from '@/utils/render';
import * as path from 'node:path';
import { getLocalName } from './utils';
module.exports = async (subjectID, showOriginalName) => {
export default async (subjectID, showOriginalName) => {
const url = `https://api.bgm.tv/subject/${subjectID}?responseGroup=large`;
const { data: epsInfo } = await got(url);
const activeEps = [];

View File

@ -1,6 +1,6 @@
const getComments = require('./comments.js');
const getFromAPI = require('./offcial-subject-api.js');
const getEps = require('./ep.js');
import getComments from './comments';
import getFromAPI from './offcial-subject-api';
import getEps from './ep';
import { queryToBoolean } from '@/utils/readable-social';
export default async (ctx) => {

View File

@ -2,7 +2,7 @@ import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
import { getLocalName } from './utils';
module.exports = (type) => {
export default (type) => {
const mapping = {
blog: {
en: 'reviews',

View File

@ -1,4 +1,4 @@
const fetchItems = require('./utils');
import fetchItems from './utils';
export default async (ctx) => {
const id = ctx.req.param('id');

View File

@ -1,4 +1,4 @@
const fetchItems = require('./utils');
import fetchItems from './utils';
export default async (ctx) => {
const currentUrl = 'posts';

View File

@ -3,7 +3,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx, currentUrl) => {
export default async (ctx, currentUrl) => {
const rootUrl = 'https://coomer.party';
currentUrl = `${rootUrl}/${currentUrl}`;

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
ctx.set('data', await utils.parseFeed({ subjectid: ctx.req.param('id') }));

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
ctx.set('data', await utils.parseFeed({ subjectid: 70 }));

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const playerId = ctx.req.param('id');

View File

@ -1,6 +1,6 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import utils from './utils';
import { parseDate } from '@/utils/parse-date';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const teamId = ctx.req.param('team');

View File

@ -1,6 +1,6 @@
import cache from '@/utils/cache';
import got from '@/utils/got';
const utils = require('./utils');
import utils from './utils';
import { parseDate } from '@/utils/parse-date';
export default async (ctx) => {

View File

@ -162,4 +162,4 @@ const ProcessFeedType3 = (item, response) => {
}
};
export { ProcessVideo, ProcessFeed, ProcessFeedType2, ProcessFeedType3, ProcessHref, ProcessImg };
export default { ProcessVideo, ProcessFeed, ProcessFeedType2, ProcessFeedType3, ProcessHref, ProcessImg };

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const keyword = ctx.req.param('keyword');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const timeframe = ctx.req.param('timeframe');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const name = ctx.req.param('name');

View File

@ -155,4 +155,4 @@ const getData = async (ctx, url, title) => {
};
};
export { getData };
export default { getData };

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
ctx.set(

View File

@ -87,4 +87,4 @@ const getData = async ({ site = 'www', channel }) => {
};
};
export { getData };
export default { getData };

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const url = `https://www.grubstreet.com/_components/newsfeed/instances/grubstreet-index@published`;

View File

@ -80,4 +80,4 @@ const getData = async (ctx, url, title, description) => {
};
};
export { getData };
export default { getData };

View File

@ -1,4 +1,4 @@
const parseList = require('./utils');
import parseList from './utils';
export default async (ctx) => {
// set default router type

View File

@ -17,7 +17,7 @@ const typeMap = {
// Number of get articles
let limit = 10;
module.exports = async (ctx, type) => {
export default async (ctx, type) => {
const link = typeMap[type].url;
const title = typeMap[type].title;

View File

@ -1,4 +1,4 @@
const getContent = require('./utils/common');
import getContent from './utils/common';
export default async (ctx) => {
await getContent(ctx, {

View File

@ -1,4 +1,4 @@
const getContent = require('./utils/common');
import getContent from './utils/common';
export default async (ctx) => {
await getContent(ctx, {

View File

@ -28,4 +28,4 @@ const categoryTitle = (type) => {
return title;
};
module.exports = categoryTitle;
export default categoryTitle;

View File

@ -2,9 +2,9 @@ import cache from '@/utils/cache';
// common.js
import { load } from 'cheerio';
import got from '@/utils/got';
const categoryTitle = require('./category-title');
const newsContent = require('./news-content');
const indexPage = require('./index-page');
import categoryTitle from './category-title';
import newsContent from './news-content';
import indexPage from './index-page';
async function getContent(ctx, { baseHost, baseCategory, baseType, baseTitle, baseDescription = '', baseDeparment = '', baseClass = 'div.article_list ul li:has(a)' }) {
const { category = baseCategory, type = baseType, page = '1' } = ctx.req.param();
@ -59,4 +59,4 @@ async function getContent(ctx, { baseHost, baseCategory, baseType, baseTitle, ba
});
}
module.exports = getContent;
export default getContent;

View File

@ -7,4 +7,4 @@ const indexPage = (page) => {
return `${fileName}${filePage}.${fileType}`;
};
module.exports = indexPage;
export default indexPage;

View File

@ -44,4 +44,4 @@ async function newsContent(link, department = '') {
}
}
module.exports = newsContent;
export default newsContent;

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const id = ctx.req.param('id');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const category = ctx.req.param('category') ?? 'censored';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const id = ctx.req.param('id');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const id = ctx.req.param('id');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const category = ctx.req.param('category') ?? 'censored';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const filter = ctx.req.param('filter') ?? '';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const id = ctx.req.param('id');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const category = ctx.req.param('category') ?? 'censored';

View File

@ -78,4 +78,4 @@ const ProcessItems = async (ctx, currentUrl, title) => {
};
};
export { ProcessItems };
export default { ProcessItems };

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
// number is shorthand for company

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const ls = await utils.company();

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const acct = ctx.req.param('acct');

View File

@ -1,5 +1,5 @@
import got from '@/utils/got';
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
export default async (ctx) => {

View File

@ -1,5 +1,5 @@
import got from '@/utils/got';
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
export default async (ctx) => {

View File

@ -131,4 +131,4 @@ async function getAccountIdByAcct(acct) {
return { site, account_id };
}
export { apiHeaders, parseStatuses, getAccountStatuses, getAccountIdByAcct, allowSiteList };
export default { apiHeaders, parseStatuses, getAccountStatuses, getAccountIdByAcct, allowSiteList };

View File

@ -1,4 +1,4 @@
const util = require('./utils');
import util from './utils';
export default async (ctx) => {
const type = ctx.req.param('type');

View File

@ -1,4 +1,4 @@
const util = require('./utils');
import util from './utils';
const baseUrl = 'https://grad.nua.edu.cn';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const util = require('./utils');
import util from './utils';
export default async (ctx) => {
const type = ctx.req.param('type');

View File

@ -1,4 +1,4 @@
const util = require('./utils');
import util from './utils';
const baseUrl = 'https://lib.nua.edu.cn';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const util = require('./utils');
import util from './utils';
export default async (ctx) => {
const type = ctx.req.param('type');

View File

@ -70,4 +70,4 @@ const ProcessFeed = (items, artiContent) =>
)
);
export { ProcessList, ProcessFeed };
export default { ProcessList, ProcessFeed };

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { load } from 'cheerio';
import got from '@/utils/got';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { load } from 'cheerio';
import got from '@/utils/got';

View File

@ -116,4 +116,4 @@ const parseList = (items, ctx, contentParser) =>
)
);
export { parseList, parseBooks, parseArticle };
export default { parseList, parseBooks, parseArticle };

View File

@ -1,4 +1,4 @@
const cache = require('./cache');
import cache from './cache';
import { parseDate } from '@/utils/parse-date';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const fetchFeed = require('./utils');
import fetchFeed from './utils';
export default async (ctx) => {
const category = ctx.req.param('category');

View File

@ -1,4 +1,4 @@
const fetchFeed = require('./utils');
import fetchFeed from './utils';
export default async (ctx) => {
const currentUrl = '';

View File

@ -1,4 +1,4 @@
const fetchFeed = require('./utils');
import fetchFeed from './utils';
export default async (ctx) => {
const keyword = ctx.req.param('keyword');

View File

@ -1,4 +1,4 @@
const fetchFeed = require('./utils');
import fetchFeed from './utils';
export default async (ctx) => {
const id = ctx.req.param('id');

View File

@ -3,7 +3,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx, currentUrl) => {
export default async (ctx, currentUrl) => {
const rootUrl = 'https://www.ruancan.com';
currentUrl = `${rootUrl}${currentUrl}`;

View File

@ -1,4 +1,4 @@
const workerFactory = require('./utils');
import workerFactory from './utils';
module.exports = workerFactory(
() => ({

View File

@ -1,4 +1,4 @@
const workerFactory = require('./utils');
import workerFactory from './utils';
module.exports = workerFactory(
(ctx) => {

View File

@ -5,7 +5,7 @@ import { parseDate } from '@/utils/parse-date';
const host = 'https://bjwb.seiee.sjtu.edu.cn';
module.exports = function (meta, extract) {
export default function (meta, extract) {
return async (ctx) => {
const { title, local, author } = meta(ctx);
@ -38,4 +38,4 @@ module.exports = function (meta, extract) {
item: out,
});
};
};
}

View File

@ -1,4 +1,4 @@
const workerFactory = require('./utils');
import workerFactory from './utils';
module.exports = workerFactory(
(ctx) => {

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const date = ctx.req.param('date') ?? `${new Date().getFullYear()}/${new Date().getMonth()}`;

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const category = ctx.req.param('category') ?? '';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
export default async (ctx) => {
const id = ctx.req.param('id') ?? '小说';

View File

@ -3,7 +3,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
module.exports = async (ctx, currentUrl) => {
export default async (ctx, currentUrl) => {
const rootUrl = 'https://www.sobooks.net';
currentUrl = `${rootUrl}/${currentUrl}`;
const response = await got({

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
export default async (ctx) => {

View File

@ -54,4 +54,4 @@ const parseTrack = (x) => ({
const parseArtist = (x) => ({ title: x.name, description: `${x.name}, with ${x.followers.total} followers`, link: x.external_urls.spotify });
export { getPublicToken, getPrivateToken, parseTrack, parseArtist };
export default { getPublicToken, getPrivateToken, parseTrack, parseArtist };

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { load } from 'cheerio';
import got from '@/utils/got';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { load } from 'cheerio';
import got from '@/utils/got';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { load } from 'cheerio';
import got from '@/utils/got';

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import got from '@/utils/got';
const sections = {

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
const T = {};
const { TwitterApi } = require('twitter-api-v2');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
const T = {};
const { TwitterApi } = require('twitter-api-v2');

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
export default async (ctx) => {

View File

@ -1,4 +1,4 @@
const utils = require('./utils');
import utils from './utils';
import { config } from '@/config';
export default async (ctx) => {

View File

@ -474,4 +474,4 @@ const parseRouteParams = (routeParams) => {
return { count, exclude_replies, include_rts, force_web_api };
};
export { ProcessFeed, getAppClient, parseRouteParams };
export default { ProcessFeed, getAppClient, parseRouteParams };