Skip to content

Commit

Permalink
feat(route): add 山东大学计算机科学与技术学院相关通知 (DIYgod#16792)
Browse files Browse the repository at this point in the history
* feat: 山东大学计算机科学与技术学院-[ 本科 | 研究生 ]教育

* feat: add route 山东大学计算机科学与技术学院

* fix: markdown render
  • Loading branch information
wiketool committed Sep 19, 2024
1 parent d31b3cf commit 492c952
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions lib/routes/sdu/cs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,26 @@ import { parseDate } from '@/utils/parse-date';
import { finishArticleItem } from '@/utils/wechat-mp';

const host = 'https://www.cs.sdu.edu.cn/';
const typelist = ['学院公告', '学术报告', '科技简讯'];
const urlList = ['xygg.htm', 'xsbg.htm', 'kjjx.htm'];
const urlMap = {
announcement: 'xygg.htm',
academic: 'xsbg.htm',
technology: 'kjjx.htm',
undergraduate: 'bkjy.htm',
postgraduate: 'yjsjy.htm',
};
const titleMap = {
announcement: '学院公告',
academic: '学术报告',
technology: '科技简讯',
undergraduate: '本科教育',
postgraduate: '研究生教育',
};

export const route: Route = {
path: '/cs/:type?',
categories: ['university'],
example: '/sdu/cs/0',
parameters: { type: '默认为 `0`' },
example: '/sdu/cs/announcement',
parameters: { type: '默认为 `announcement`' },
features: {
requireConfig: false,
requirePuppeteer: false,
Expand All @@ -25,14 +37,14 @@ export const route: Route = {
name: '计算机科学与技术学院通知',
maintainers: ['Ji4n1ng'],
handler,
description: `| 学院公告 | 学术报告 | 科技简讯 |
| -------- | -------- | -------- |
| 0 | 1 | 2 |`,
description: `| 学院公告 | 学术报告 | 科技简讯 | 本科教育 | 研究生教育 |
| -------- | -------- | -------- | -------- | -------- |
| announcement | academic | technology | undergraduate | postgraduate |`,
};

async function handler(ctx) {
const type = ctx.req.param('type') ? Number.parseInt(ctx.req.param('type')) : 0;
const link = new URL(urlList[type], host).href;
const type = ctx.req.param('type') ?? 'announcement';
const link = new URL(urlMap[type], host).href;

const response = await got(link);

Expand Down Expand Up @@ -72,7 +84,7 @@ async function handler(ctx) {
);

return {
title: `山东大学计算机科学与技术学院${typelist[type]}通知`,
title: `山东大学计算机科学与技术学院${titleMap[type]}`,
description: $('title').text(),
link,
item,
Expand Down

0 comments on commit 492c952

Please sign in to comment.