feat: Add course code (#47)

This commit is contained in:
霧雨バニラ 2025-10-20 20:42:21 +08:00 committed by GitHub
commit 49bda84716
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
38 changed files with 91 additions and 4 deletions

2
.gitignore vendored
View File

@ -18,3 +18,5 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
from_name_to_code

View File

@ -1,5 +1,6 @@
---
title: 高级日语1
description: "课程代码: SFLK3117"
---
## 2024-2025学年上学期

View File

@ -1,5 +1,6 @@
---
title: 高级日语2
description: "课程代码: SFLK3119"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 英语畅谈中国文化
description: "课程代码: SFLE0030"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 通用学术英语读写
description: "课程代码: SFLE0001"
---

View File

@ -1,3 +1,4 @@
---
title: 高等数学A
description: "课程代码: MATH1601"
---

View File

@ -1,3 +1,4 @@
---
title: 高等数学A
description: "课程代码: MATH2602"
---

View File

@ -1,5 +1,6 @@
---
title: 大学物理C
description: "课程代码: PHYS2647"
---
- [2024-2025学年下学期补考_B卷_回忆版](./2024-2025学年下学期补考_B_回忆)

View File

@ -1,5 +1,6 @@
---
title: 云计算
description: "课程代码: SE3431"
---
## 2024-2025学年上学期

View File

@ -1,5 +1,6 @@
---
title: 人工智能的数学思维
description: "课程代码: SE1212"
---
## 2022-2023学年下学期

View File

@ -1,5 +1,6 @@
---
title: 信息安全数学导论
description: "课程代码: SE1204"
---
很简单

View File

@ -1,5 +1,6 @@
---
title: 区块链基础
description: "课程代码: SE3324"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 密码分析学
description: "课程代码: SE3430"
---

View File

@ -1,5 +1,6 @@
---
title: 并行程序设计
description: "课程代码: SE2425"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 数字逻辑
description: "课程代码: SE1203"
---

View File

@ -1,5 +1,6 @@
---
title: 数据科学
description: "课程代码: SE3435"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 数据结构与算法
description: "课程代码: SE1209"
---

View File

@ -1,5 +1,6 @@
---
title: 数据结构与算法实践
description: "课程代码: SE1208"
---

View File

@ -1,5 +1,6 @@
---
title: 无线网络安全
description: "课程代码: SE3335"
---
## 2023-2024学年上学期

View File

@ -1,5 +1,6 @@
---
title: 程序设计基础
description: "课程代码: SE1201"
---

View File

@ -1,5 +1,6 @@
---
title: 线性代数
description: "课程代码: SE1101"
---
> 2023Fall 与 2024Fall 的《线性代数计算机拔尖基地》由btm老师授课.

View File

@ -1,5 +1,6 @@
---
title: 网络安全协议分析
description: "课程代码: SE3338"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 计算机安全
description: "课程代码: SE2318"
---
## 2023-2024学年下学期

View File

@ -1,5 +1,6 @@
---
title: 计算机系统
description: "课程代码: SE1210"
---
## 2022-2023学年下学期

View File

@ -1,5 +1,6 @@
---
title: 计算机网络
description: "课程代码: SE2214"
---

View File

@ -1,5 +1,6 @@
---
title: 计算机网络实践
description: "课程代码: SE2215"
---
## 2023-2024学年上学期

View File

@ -1,5 +1,6 @@
---
title: 计算机逻辑基础
description: "课程代码: SE3442"
---
## 2024-2025学年上学期

View File

@ -1,5 +1,6 @@
---
title: 计算理论基础
description: "课程代码: SE3436"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 软件分析与验证前沿
description: "课程代码: SE3343"
---
## 2025-2026学年上学期

View File

@ -1,5 +1,6 @@
---
title: 软件工程实践
description: "课程代码: SE3230"
---

View File

@ -1,5 +1,6 @@
---
title: 软件工程数学
description: "课程代码: SE1207"
---

View File

@ -1,5 +1,6 @@
---
title: 软件开发实践
description: "课程代码: SOFT0031131076"
---
## 2024-2025学年下学期

View File

@ -1,5 +1,6 @@
---
title: 高等数学(一)
description: "课程代码: SE1102"
---
## 本页面不再适用

View File

@ -1,5 +1,6 @@
---
title: 高等数学(二)
description: "课程代码: SE1103"
---
## 本页面不再适用

View File

@ -24,7 +24,7 @@ const sidebars = {
link: {
type: 'generated-index',
title: '本科生院',
description: '本科期间的课程资料汇总,涵盖各类专业必修课和选修课。',
description: '本科期间的课程资料汇总,涵盖各类专业必修课和选修课。(在课程名称后面标注了课程代码,但考虑到学校近期对相关内容修改频繁,参考价值较低)',
slug: '/undergraduate',
},
items: [

View File

@ -0,0 +1,18 @@
import React from 'react';
import styles from './CourseCodeTag.module.css';
/**
* 课程代码标签组件
* 用于显示课程编号
*/
export default function CourseCodeTag({ code }) {
if (!code) {
return null;
}
return (
<span className={styles.courseCodeTag}>
{code}
</span>
);
}

View File

@ -0,0 +1,21 @@
.courseCodeTag {
display: inline-block;
padding: 0.2rem 0.6rem;
margin-top: 0.5rem;
font-size: 0.75rem;
font-weight: 600;
line-height: 1;
color: var(--ifm-color-primary);
background-color: #e8f4fd;
border: 1px solid var(--ifm-color-primary-light);
border-radius: 0.375rem;
white-space: nowrap;
width: fit-content;
max-width: 100%;
}
html[data-theme='dark'] .courseCodeTag {
color: var(--ifm-color-primary-lightest);
background-color: #1a2838;
border-color: var(--ifm-color-primary-dark);
}

View File

@ -10,6 +10,7 @@ import isInternalUrl from '@docusaurus/isInternalUrl';
import { translate } from '@docusaurus/Translate';
import Heading from '@theme/Heading';
import styles from './styles.module.css';
import CourseCodeTag from './CourseCodeTag';
function useCategoryItemsPlural() {
const { selectMessage } = usePluralForm();
return (count) =>
@ -36,6 +37,16 @@ function CardContainer({ className, href, children }) {
);
}
function CardLayout({ className, href, icon, title, description }) {
// 检查是否以"课程代码:"开头
const courseCodePrefix = '课程代码:';
let courseCode = null;
let displayDescription = description;
if (description && description.startsWith(courseCodePrefix)) {
courseCode = description.substring(courseCodePrefix.length).trim();
displayDescription = null; // 不显示原始描述
}
return (
<CardContainer href={href} className={className}>
<Heading
@ -44,13 +55,14 @@ function CardLayout({ className, href, icon, title, description }) {
title={title}>
{icon} {title}
</Heading>
{description && (
{displayDescription && (
<p
className={clsx('text--truncate', styles.cardDescription)}
title={description}>
{description}
title={displayDescription}>
{displayDescription}
</p>
)}
{courseCode && <CourseCodeTag code={courseCode} />}
</CardContainer>
);
}
@ -69,6 +81,7 @@ function CardCategory({ item }) {
} catch (e) {
doc = null;
}
console.log(item.description, doc?.description);
return (
<CardLayout
className={item.className}