feat: release undergraduate integration 0.7.0

This commit is contained in:
Codex
2026-10-15 01:14:06 +08:00
parent b28f333720
commit 674df1ceb3
22 changed files with 173 additions and 63 deletions
@@ -21,14 +21,16 @@ class UndergraduateTimetableAdapter {
uri.userInfo.isNotEmpty ||
!uri.path.startsWith('/eams/') ||
source == CourseSource.demo ||
utf8.encode(content).length > 2 * 1024 * 1024)
utf8.encode(content).length > 2 * 1024 * 1024) {
throw const FormatException('不是本科课表页面');
}
final doc = html.parse(content),
table = html
.parse(content)
.querySelector('#manualArrangeCourseTable');
if (table == null || doc.querySelector('input[type="password"]') != null)
if (table == null || doc.querySelector('input[type="password"]') != null) {
throw const FormatException('请先在学校网页打开课表');
}
final termIds = doc
.querySelectorAll('input[name="semester.id"]')
.map((e) => e.attributes['value'])
@@ -51,8 +53,9 @@ class UndergraduateTimetableAdapter {
: <UndergraduateActivity>[];
final explicitEmpty =
activities.isEmpty && RegExp(r'暂无课程|无课程安排|没有课程').hasMatch(table.text);
if (activities.isEmpty && !explicitEmpty)
if (activities.isEmpty && !explicitEmpty) {
throw const FormatException('课表尚未加载完整');
}
final roster = <String, ({String code, String notes})>{};
for (final grid in doc.querySelectorAll('table')) {
final rows = grid.querySelectorAll('tr');
@@ -64,8 +67,9 @@ class UndergraduateTimetableAdapter {
note = headers.indexOf('选课备注');
for (final row in rows.skip(1)) {
final cells = row.children;
if (cells.length != headers.length)
if (cells.length != headers.length) {
throw const FormatException('课程名单不完整');
}
roster[cells[seq].text.trim()] = (
code: cells[code].text.trim(),
notes: note >= 0 ? cells[note].text.trim() : '',
@@ -162,8 +166,9 @@ class UndergraduateTimetableAdapter {
);
}
}
if (courses.isEmpty && !explicitEmpty)
if (courses.isEmpty && !explicitEmpty) {
throw const FormatException('没有识别到有效上课安排');
}
return ImportDraft(
courses: List.unmodifiable(courses),
explicitlyEmpty: explicitEmpty,