diff --git a/lib/routes/hdu/auto/graduate.ts b/lib/routes/hdu/auto/graduate.ts deleted file mode 100644 index 9dd10202979e01..00000000000000 --- a/lib/routes/hdu/auto/graduate.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Route } from '@/types'; -import { fetchAutoNews } from './utils'; - -export const route: Route = { - path: '/auto/graduate', - categories: ['university'], - example: '/hdu/auto/graduate', - parameters: {}, - features: { - requireConfig: false, - requirePuppeteer: false, - antiCrawler: false, - supportBT: false, - supportPodcast: false, - supportScihub: false, - }, - name: '自动化学院 - 研究生教育通知', - maintainers: ['jalenzz'], - handler: () => fetchAutoNews('3754/list.htm', '研究生教育'), - description: '杭州电子科技大学自动化学院研究生教育', - radar: [ - { - source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3754/list.htm'], - target: '/auto/graduate', - }, - ], -}; diff --git a/lib/routes/hdu/auto/notice.ts b/lib/routes/hdu/auto/notice.ts index 610b1f20afb26b..c28e87beef42bb 100644 --- a/lib/routes/hdu/auto/notice.ts +++ b/lib/routes/hdu/auto/notice.ts @@ -1,11 +1,31 @@ import { Route } from '@/types'; import { fetchAutoNews } from './utils'; +import logger from '@/utils/logger'; + +const typeMap = { + notice: { + name: '通知公告', + path: '3779/list.htm', + }, + graduate: { + name: '研究生教育', + path: '3754/list.htm', + }, + undergraduate: { + name: '本科教学', + path: '3745/list.htm', + }, + student: { + name: '学生工作', + path: '3726/list.htm', + }, +}; export const route: Route = { - path: '/auto', + path: '/auto/:type?', categories: ['university'], example: '/hdu/auto', - parameters: {}, + parameters: { type: '分类,见下表,默认为通知公告' }, features: { requireConfig: false, requirePuppeteer: false, @@ -14,14 +34,35 @@ export const route: Route = { supportPodcast: false, supportScihub: false, }, - name: '自动化学院 - 通知公告', + name: '自动化学院', maintainers: ['jalenzz'], - handler: () => fetchAutoNews('3779/list.htm', '通知公告'), - description: '杭州电子科技大学自动化学院通知公告', + handler: (ctx) => { + let type = ctx.req.param('type') || 'notice'; + if (!(type in typeMap)) { + logger.error(`Invalid type: ${type}. Valid types are: ${Object.keys(typeMap).join(', ')}, defaulting to notice`); + type = 'notice'; + } + return fetchAutoNews(typeMap[type].path, typeMap[type].name); + }, + description: `| 通知公告 | 研究生教育 | 本科教学 | 学生工作 | +| -------- | -------- | -------- | -------- | +| notice | graduate | undergraduate | student |`, radar: [ { source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3779/list.htm'], - target: '/auto', + target: '/auto/notice', + }, + { + source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3754/list.htm'], + target: '/auto/graduate', + }, + { + source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3745/list.htm'], + target: '/auto/undergraduate', + }, + { + source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3726/list.htm'], + target: '/auto/student', }, ], }; diff --git a/lib/routes/hdu/auto/student.ts b/lib/routes/hdu/auto/student.ts deleted file mode 100644 index e38c6e65a730ba..00000000000000 --- a/lib/routes/hdu/auto/student.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Route } from '@/types'; -import { fetchAutoNews } from './utils'; - -export const route: Route = { - path: '/auto/student', - categories: ['university'], - example: '/hdu/auto/student', - parameters: {}, - features: { - requireConfig: false, - requirePuppeteer: false, - antiCrawler: false, - supportBT: false, - supportPodcast: false, - supportScihub: false, - }, - name: '自动化学院 - 学生工作', - maintainers: ['jalenzz'], - handler: () => fetchAutoNews('3726/list.htm', '学生工作'), - description: '杭州电子科技大学自动化学院学生工作', - radar: [ - { - source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3726/list.htm'], - target: '/auto/student', - }, - ], -}; diff --git a/lib/routes/hdu/auto/undergraduate.ts b/lib/routes/hdu/auto/undergraduate.ts deleted file mode 100644 index 07078ed75b1b8c..00000000000000 --- a/lib/routes/hdu/auto/undergraduate.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Route } from '@/types'; -import { fetchAutoNews } from './utils'; - -export const route: Route = { - path: '/auto/undergraduate', - categories: ['university'], - example: '/hdu/auto/undergraduate', - parameters: {}, - features: { - requireConfig: false, - requirePuppeteer: false, - antiCrawler: false, - supportBT: false, - supportPodcast: false, - supportScihub: false, - }, - name: '自动化学院 - 本科教学', - maintainers: ['jalenzz'], - handler: () => fetchAutoNews('3745/list.htm', '本科教学'), - description: '杭州电子科技大学自动化学院本科教学', - radar: [ - { - source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3745/list.htm'], - target: '/auto/undergraduate', - }, - ], -};