feat: replace require with import 5/n

This commit is contained in:
DIYgod 2024-03-07 00:39:42 +08:00
parent 34d889743b
commit e42ff57cb4
No known key found for this signature in database
59 changed files with 69 additions and 67 deletions

View File

@ -1,13 +1,6 @@
const toZzkx = (ctx) => {
// https://www.cs.com.cn/sylm/jsbd/
const redirectTo = '/cs/sylm/jsbd';
ctx.redirect(redirectTo);
};
export default (router) => {
router.get('/news/zzkx', toZzkx);
router.get('/zzkx', toZzkx);
router.get('/news/zzkx', './zzkx');
router.get('/zzkx', './zzkx');
router.get('/video/:category?', './video');
router.get('/:category{.+}?', './');
};

6
lib/routes/cs/zzkx.ts Normal file
View File

@ -0,0 +1,6 @@
export default (ctx) => {
// https://www.cs.com.cn/sylm/jsbd/
const redirectTo = '/cs/sylm/jsbd';
ctx.redirect(redirectTo);
};

View File

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

View File

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

View File

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

View File

@ -15,7 +15,7 @@ import cache from '@/utils/cache';
// [] hdjlpt 互动交流
// 使用方法
// const { gdgov } = require('../general/general');
// import { gdgov } from '../general/general';
//
// export default async (ctx) => {
// const info = {

View File

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

View File

@ -1,5 +1,5 @@
import { getSubPath } from '@/utils/common-utils';
const { gdgov } = require('../general/general');
import { gdgov } from '../general/general';
export default async (ctx) => {
const path = getSubPath(ctx)

View File

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

View File

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

View File

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

View File

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

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

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import { ig, login } from './utils';
import logger from '@/utils/logger';
import { config } from '@/config';
const { renderItems } = require('../common-utils');
import { renderItems } from '../common-utils';
// loadContent pulls the desired user/tag/etc
async function loadContent(category, nameOrId, tryGet) {

View File

@ -1,7 +1,7 @@
import cache from '@/utils/cache';
const { CookieJar } = require('tough-cookie');
import { config } from '@/config';
const { renderItems } = require('../common-utils');
import { renderItems } from '../common-utils';
import { baseUrl, COOKIE_URL, checkLogin, getUserInfo, getUserFeedItems, getTagsFeedItems, getLoggedOutTagsFeedItems, renderGuestItems } from './utils';
export default async (ctx) => {

View File

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const getCookie = require('../utils/pypasswaf');
import getCookie from '../utils/pypasswaf';
const host = 'https://cae.nuaa.edu.cn/';
const map = new Map([

View File

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const getCookie = require('../utils/pypasswaf');
import getCookie from '../utils/pypasswaf';
const host = 'https://cs.nuaa.edu.cn/';
const map = new Map([

View File

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const getCookie = require('../utils/pypasswaf');
import getCookie from '../utils/pypasswaf';
const host = 'http://aao.nuaa.edu.cn/';
const map = new Map([

View File

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const getCookie = require('../utils/pypasswaf');
import getCookie from '../utils/pypasswaf';
const host = 'http://www.graduate.nuaa.edu.cn/';
const map = new Map([

View File

@ -5,7 +5,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import timezone from '@/utils/timezone';
import { parseDate } from '@/utils/parse-date';
const { parseArticle } = require('../utils');
import { parseArticle } from '../utils';
import { art } from '@/utils/render';
import * as path from 'node:path';

View File

@ -3,7 +3,7 @@ const __dirname = getCurrentPath(import.meta.url);
import cache from '@/utils/cache';
import got from '@/utils/got';
const { parseArticle } = require('../utils');
import { parseArticle } from '../utils';
import { art } from '@/utils/render';
import * as path from 'node:path';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
import queryString from 'query-string';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
import queryString from 'query-string';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
import queryString from 'query-string';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
const assert = require('assert');
import queryString from 'query-string';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
import queryString from 'query-string';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
import queryString from 'query-string';

View File

@ -1,4 +1,4 @@
const got = require('../pixiv-got');
import got from '../pixiv-got';
const maskHeader = require('../constants').maskHeader;
import queryString from 'query-string';

View File

@ -2,7 +2,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
const { appsUrl } = require('../utils');
import { appsUrl } from '../utils';
export default async (ctx) => {
const { id, lang = '' } = ctx.req.param();

View File

@ -5,7 +5,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
const { appsUrl } = require('../utils');
import { appsUrl } from '../utils';
import { art } from '@/utils/render';
import * as path from 'node:path';

View File

@ -3,7 +3,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
const { appsUrl } = require('../utils');
import { appsUrl } from '../utils';
export default async (ctx) => {
const { id, lang = '' } = ctx.req.param();

View File

@ -3,7 +3,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
const { appsUrl, newsUrl, fixImg } = require('../utils');
import { appsUrl, newsUrl, fixImg } from '../utils';
export default async (ctx) => {
const { id, lang = '' } = ctx.req.param();

View File

@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const { ssoUrl, notesUrl } = require('../utils');
import { ssoUrl, notesUrl } from '../utils';
import { art } from '@/utils/render';
import * as path from 'node:path';

View File

@ -1,6 +1,6 @@
import got from '@/utils/got';
import { load } from 'cheerio';
const { notesUrl, extractNotes } = require('../utils');
import { notesUrl, extractNotes } from '../utils';
export default async (ctx) => {
const { topic, lang } = ctx.req.param();

View File

@ -1,6 +1,6 @@
import got from '@/utils/got';
import { load } from 'cheerio';
const { notesUrl, extractNotes } = require('../utils');
import { notesUrl, extractNotes } from '../utils';
export default async (ctx) => {
const { uid, lang } = ctx.req.param();

View File

@ -5,7 +5,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
const { userUrl, appsUrl } = require('../utils');
import { userUrl, appsUrl } from '../utils';
import { art } from '@/utils/render';
import * as path from 'node:path';

View File

@ -0,0 +1 @@
export { announcementsRouter as default } from './physics-school-announcements-and-news';

View File

@ -0,0 +1 @@
export { newsRouter as default } from './physics-school-announcements-and-news';

View File

@ -44,7 +44,7 @@ const getItemsFromURLs = async (URLs, cache) => {
return items;
};
module.exports.announcementsRouter = async (ctx) => {
export const announcementsRouter = async (ctx) => {
const URLs = {
: 'https://physics.scnu.edu.cn/NEWS/Notices/PartyAndGovernment/',
: 'https://physics.scnu.edu.cn/NEWS/Notices/Education/',
@ -61,7 +61,7 @@ module.exports.announcementsRouter = async (ctx) => {
});
};
module.exports.newsRouter = async (ctx) => {
export const newsRouter = async (ctx) => {
const URLs = {
: 'https://physics.scnu.edu.cn/NEWS/News/College/',
: 'https://physics.scnu.edu.cn/NEWS/News/Education/',
@ -77,7 +77,7 @@ module.exports.newsRouter = async (ctx) => {
});
};
module.exports.researchNewsRouter = async (ctx) => {
export const researchNewsRouter = async (ctx) => {
const URLs = {
: 'https://physics.scnu.edu.cn/RESEARCH/EVENTS/Seminars/',
: 'https://physics.scnu.edu.cn/RESEARCH/EVENTS/Conferences/',

View File

@ -0,0 +1 @@
export { researchNewsRouter as default } from './physics-school-announcements-and-news';

View File

@ -2,9 +2,9 @@ export default (router) => {
router.get('/cs/match', './cs/match');
router.get('/jw', './jw');
router.get('/library', './library');
router.get('/physics-school-announcements', './physics-school-announcements-and-news'.announcementsRouter);
router.get('/physics-school-news', './physics-school-announcements-and-news'.newsRouter);
router.get('/physics-school-research-news', './physics-school-announcements-and-news'.researchNewsRouter);
router.get('/physics-school-announcements', './announcements-router');
router.get('/physics-school-news', './news-router');
router.get('/physics-school-research-news', './research-news-router');
router.get('/ss', './ss');
router.get('/yjs', './yjs');
};

View File

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const data = require('../data').wh.jwc;
const extractor = require('../extractor');
import extractor from '../extractor';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';

View File

@ -2,7 +2,7 @@ import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
const data = require('../data').wh.news;
const extractor = require('../extractor');
import extractor from '../extractor';
import { parseDate } from '@/utils/parse-date';
export default async (ctx) => {

View File

@ -3,7 +3,7 @@ import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import { config } from '@/config';
const { getAcwScV2ByArg1 } = require('../5eplay/utils');
import { getAcwScV2ByArg1 } from '../5eplay/utils';
const host = 'https://segmentfault.com';

View File

@ -1,5 +1,5 @@
import cache from '@/utils/cache';
const { getRollNewsList, parseRollNewsList, parseArticle } = require('../utils');
import { getRollNewsList, parseRollNewsList, parseArticle } from '../utils';
export default async (ctx) => {
const map = {

View File

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

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 id = ctx.req.param('id');

View File

@ -1,4 +1,4 @@
const utils = require('../utils');
import utils from '../utils';
// import { config } from '@/config';
import { getUser, getUserMedia } from './twitter-api';
import { initToken } from './token';

View File

@ -1,4 +1,4 @@
const utils = require('../utils');
import utils from '../utils';
import { getSearch } from './twitter-api';
import { initToken } from './token';

View File

@ -1,6 +1,6 @@
// import { config } from '@/config';
import { getUser, getUserTweet } from './twitter-api';
const utils = require('../utils');
import utils from '../utils';
import { fallback, queryToBoolean } from '@/utils/readable-social';
import { config } from '@/config';
import { initToken } from './token';

View File

@ -1,4 +1,4 @@
const utils = require('../utils');
import utils from '../utils';
import { getUser, getUserTweets, getUserTweetsAndReplies, excludeRetweet } from './twitter-api';
import { initToken } from './token';

View File

@ -1,5 +1,5 @@
import buildData from '@/utils/common-config';
const weiboUtils = require('../utils');
import weiboUtils from '../utils';
export default async (ctx) => {
const userid = ctx.req.param('userid');

View File

@ -7,7 +7,7 @@ import { config } from '@/config';
import { art } from '@/utils/render';
import { load } from 'cheerio';
import * as path from 'node:path';
// const weiboUtils = require('../utils');
// import weiboUtils from '../utils';
// Default hide all picture
let wpic = 'false';

View File

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

View File

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

View File

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

View File

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