From f256c9707a17ad52b0cbf6bb56ce2c875190c8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A9=BA?= Date: Thu, 11 Jul 2024 01:51:15 +0800 Subject: [PATCH] fix(route/neea): fix routing priority and improve descriptions (#16131) * feat(route/neea): update routes and improve description * fix neea jlpt routing priority * use https instead of http * style: simplify logic for better readability * revert commits * incorporate necessary changes --- lib/routes/neea/index.ts | 68 +++++++++++++++++++++++++----------- lib/routes/neea/jlpt.ts | 27 +++++++------- lib/routes/neea/namespace.ts | 4 +-- 3 files changed, 62 insertions(+), 37 deletions(-) diff --git a/lib/routes/neea/index.ts b/lib/routes/neea/index.ts index c02d90c33..fa0570ce7 100644 --- a/lib/routes/neea/index.ts +++ b/lib/routes/neea/index.ts @@ -2,6 +2,9 @@ import { Route } from '@/types'; import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; +import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; + function loadContent(link) { return cache.tryGet(link, async () => { // 开始加载页面 @@ -20,16 +23,9 @@ function loadContent(link) { }); } -export const route: Route = { - path: '/:type?', - name: 'Unknown', - maintainers: ['SunShinenny'], - handler, -}; - async function handler(ctx) { const type = ctx.req.param('type'); - const host = `http://${type}.neea.edu.cn${typeDic[type].url}`; + const host = `https://${type}.neea.edu.cn${typeDic[type].url}`; const response = await got({ method: 'get', url: host, @@ -43,14 +39,13 @@ async function handler(ctx) { list.map(async (item) => { const ReportIDname = $(item).find('#ReportIDname > a'); const ReportIDIssueTime = $(item).find('#ReportIDIssueTime'); - const itemUrl = `http://${type}.neea.edu.cn` + $(ReportIDname).attr('href'); - let time = new Date(ReportIDIssueTime.text()).getTime(); - time += new Date().getTimezoneOffset() * 60 * 1000 + 8 * 60 * 60 * 1000; // beijing timezone + const itemUrl = `https://${type}.neea.edu.cn` + $(ReportIDname).attr('href'); + const time = ReportIDIssueTime.text(); const single = { title: $(ReportIDname).text(), link: itemUrl, guid: itemUrl, - pubDate: new Date(time).toUTCString(), + pubDate: timezone(parseDate(time), +8), }; const other = await loadContent(String(itemUrl)); return Object.assign({}, single, other); @@ -86,10 +81,14 @@ const typeDic = { url: '/html1/category/1507/1148-1.htm', title: '中小学教师资格考试', }, + tdxl: { + url: '/html1/category/2210/313-1.htm', + title: '同等学力申请硕士学位考试', + }, // 社会证书考试 cet: { url: '/html1/category/16093/1124-1.htm', - title: '全国四六级(CET)', + title: '全国四六级考试(CET)', }, ncre: { url: '/html1/category/1507/872-1.htm', @@ -102,18 +101,47 @@ const typeDic = { pets: { url: '/html1/category/1507/1570-1.htm', - title: '全国英语等级考试 (PETS)', + title: '全国英语等级考试(PETS)', }, wsk: { url: '/html1/category/1507/1646-1.htm', - title: '全国外语水平考试 (WSK)', + title: '全国外语水平考试(WSK)', }, ccpt: { url: '/html1/category/1507/2035-1.htm', - title: '书画等级考试 (CCPT)', - }, - mets: { - url: '/html1/category/1507/2065-1.htm', - title: '医护英语水平考试 (METS)', + title: '书画等级考试(CCPT)', }, }; + +export const route: Route = { + path: '/local/:type', + name: '国内考试动态', + url: 'www.neea.edu.cn', + maintainers: ['SunShinenny'], + example: '/neea/local/cet', + parameters: { type: '考试项目,见下表' }, + categories: ['study'], + features: { + supportRadar: true, + }, + radar: Object.entries(typeDic).map(([type, value]) => ({ + title: `${value.title}动态`, + source: [`${type}.neea.edu.cn`, `${type}.neea.cn`], + target: `/local/${type}`, + })), + handler, + description: `| | 考试项目 | type | +| ------------ | ----------------------------- | -------- | +| 国家教育考试 | 普通高考 | gaokao | +| | 成人高考 | chengkao | +| | 研究生考试 | yankao | +| | 自学考试 | zikao | +| | 中小学教师资格考试 | ntce | +| | 同等学力申请硕士学位考试 | tdxl | +| 社会证书考试 | 全国四六级考试(CET) | cet | +| | 全国计算机等级考试(NCRE) | ncre | +| | 全国计算机应用水平考试(NIT) | nit | +| | 全国英语等级考试(PETS) | pets | +| | 全国外语水平考试(WSK) | wsk | +| | 书画等级考试(CCPT) | ccpt |`, +}; diff --git a/lib/routes/neea/jlpt.ts b/lib/routes/neea/jlpt.ts index a01647622..5255ee71d 100644 --- a/lib/routes/neea/jlpt.ts +++ b/lib/routes/neea/jlpt.ts @@ -3,29 +3,26 @@ import cache from '@/utils/cache'; import got from '@/utils/got'; import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; +import timezone from '@/utils/timezone'; export const route: Route = { - path: '/jlpt', - categories: ['study'], - example: '/neea/jlpt', + path: '/global/jlpt', + name: '日本语能力测试(JLPT)通知', + url: 'jlpt.neea.edu.cn', + maintainers: ['nczitzk'], + example: '/neea/global/jlpt', parameters: {}, + categories: ['study'], features: { - requireConfig: false, - requirePuppeteer: false, - antiCrawler: false, - supportBT: false, - supportPodcast: false, - supportScihub: false, + supportRadar: true, }, radar: [ { - source: ['jlpt.neea.cn/'], + source: ['jlpt.neea.edu.cn', 'jlpt.neea.cn'], + target: '/global/jlpt', }, ], - name: '教育部考试中心日本语能力测试重要通知', - maintainers: ['nczitzk'], handler, - url: 'jlpt.neea.cn/', }; async function handler() { @@ -49,7 +46,7 @@ async function handler() { return { title: item.text(), link: `${rootUrl}/JLPT/1/${item.attr('href')}`, - pubDate: matches ? parseDate(matches[1]) : '', + pubDate: matches ? timezone(parseDate(matches[1]), +8) : '', }; }); @@ -71,7 +68,7 @@ async function handler() { ); return { - title: '重要通知 - 教育部考试中心日本语能力测试', + title: '日本语能力测试(JLPT)通知', link: currentUrl, item: items, }; diff --git a/lib/routes/neea/namespace.ts b/lib/routes/neea/namespace.ts index d3aeb74d2..add291ac3 100644 --- a/lib/routes/neea/namespace.ts +++ b/lib/routes/neea/namespace.ts @@ -1,6 +1,6 @@ import type { Namespace } from '@/types'; export const namespace: Namespace = { - name: 'NEEA 中国教育考试网', - url: 'jlpt.neea.cn', + name: '中国教育考试网', + url: 'www.neea.edu.cn', };