fix(SCUEC): 修复多段周次丢失与地点识别,避免未排课课程错位 - #7
Merged
Merged
Conversation
- parseSingleCourse 改为提取完整的多段周次串(如 "1-7周,14-16周,9-9周,12-12周") 再交给 parseWeeks,原先只匹配第一段,导致后续周次全部丢失 (实测 2025-2026-2:高等数学A(2)星期五 1-2 节只剩 1-7 周,9/12/14-16 周丢失) - 地点行识别补充关键词(中心/基地/操场/球场),修复 "工程训练中心" 被判为 "待定" - 未安排时间课程不再混入导入数据:day=0 / startSection=0 会被 App 端 normalizeDayOfWeek/normalizeSections 夹到「周一第 1 节」,与真实课程重叠; 周次为空的课程还会被 App 直接丢弃。改为只输出 console.warn 清单。 验证:用两份真实课表 HTML(2026-2027-1 / 2025-2026-2)在 jsdom 中回归, 周次与地点解析 19/19、16/16 全部与页面一致。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
目标分支确认清单 (Target Branch Checklist)
main。(本仓库不使用上游的pending分支流程)PR 描述 (Description)
改动对象
resources/SCUEC/scuec.js(中南民族大学 · 教务系统网页登录导入)解决的问题
1. 多段周次只解析出第一段(周次数据缺失)
中南民大课表的周次列存在多段、乱序写法,例如:
parseWeeks()本身已支持按逗号拆段,但parseSingleCourse()里的weekMatch只匹配第一段:/\d+(?:\s*[-~]\s*\d+)?周(?:\((?:单|双)\))?/结果只拿到
1-7周,14-16周,9-9周,12-12周全部丢失。现改为整体提取多段串后再交给parseWeeks()。实测(2025-2026-2):星期五 1-2 节 高等数学A(2)由
[1..7]修正为[1,2,3,4,5,6,7,9,12,14,15,16];星期四 5-6 节由[10,11]修正为[8,10,11,13]。2. 地点识别漏掉「工程训练中心」
地点行判定为正则
/[楼馆场室厅]/,工程训练中心不含这些字,被判为「待定」。补充中心|基地|操场|球场后正确识别(3 条工程训练A 全部修正)。3. 未安排时间课程混入导入数据(导入后错位)
table.NoFitCourse的课程被以day: 0, startSection: 0, endSection: 0塞进 courses。而 App 端_parseWarehouseCourses()会做:即被夹到「周一第 1 节」,与真实课程重叠显示;周次为空的课程(如
软件开发实习[03])还会因weeks.isEmpty被 App 直接丢弃。docs/SCRIPT_API.md也写明day为 1-7、weeks必填,无时间课程不在导入契约内。因此改为只输出
console.warn清单、不再混入导入数据(如后续 App 端支持「无时间课程」字段,可再回填)。是否新增字段 / 轻屿专用行为
无新增字段,无脚本 API 变更。
是否与上游兼容
仅修改
resources/SCUEC/scuec.js内部实现,目录结构与上游保持兼容。测试环境
extractCoursesFromTable(),与页面 DOM 逐条核对: