Skip to content

fix(MYSY): 修正时间模板 fallback 为学校实际作息(11 节) - #8

Merged
Mutx163 merged 1 commit into
Mutx163:mainfrom
Guzheng3:fix/mysy-timetable
Sep 9, 2026
Merged

Mutx163 merged 1 commit into
Mutx163:mainfrom
Guzheng3:fix/mysy-timetable

Conversation

@Guzheng3

@Guzheng3 Guzheng3 commented Sep 9, 2026

Copy link
Copy Markdown

背景

绵阳师范学院(MYSY)的教务课表页 #kbtable 里,th[rowspan] 给出的是教务口径的 13 小节(08:00–21:25),而学校作息表是11 节(08:15 起,上午 2+2、下午 2+2+1、晚上 2):

上午 下午 晚上 合计
教务系统页面 2+3 节 2+3 节 3 节 13 节
学校作息表 2+2 节 2+2+1 节 2 节 11 节

两套作息节数不同、编号也错位(作息表第 5 节 = 14:00,教务第 6 节 = 14:00)。原脚本固定使用页面推导结果,想按学校作息显示课表的用户没有选择权。

改动

只动 resources/MYSY/mysy.js+56 −1generateTimeSlots() 的页面推导与 fallback 逻辑保持不变

  1. 新增 PRESET_TIME_SLOTS:11 节学校作息表
    1  08:15-09:00   2  09:05-09:50   3  10:20-11:05   4  11:10-11:55
    5  14:00-14:45   6  14:50-15:35   7  16:05-16:50   8  16:55-17:40
    9  17:45-18:30  10  19:00-19:45  11  19:50-20:35
    
  2. 新增 chooseTimeSlots(pageSlots):导入时用 bridgePromise.showSingleSelection 弹单选
    选择课表使用的时间表
      ● 教务系统时间表(13 节)      ← 默认
      ○ 预设作息时间表(11 节)
    
  3. 健壮性:桥接层回传 number / 字符串 / null 都归一化;取消、越界、旧版桥接层没有 showSingleSelection 一律回落到教务系统时间表,不阻断导入。
  4. runImportFlow() 里改为 await chooseTimeSlots(generateTimeSlots(doc))

验证

jsdom 加载真实课表页面(jw.mtc.edu.cn/jsxsd/xskb/xskb_list.do 的 Frame0 #kbtable,含 5 个 th[rowspan] 时间块、77 个 div.kbcontent):

用例 结果
选 index 0 → 教务系统时间表 ✅ 13 节,首节 08:00-08:45
选 index 1 → 预设作息时间表 ✅ 11 节,首节 08:15-09:00
桥接回传字符串 "1" ✅ 11 节
取消 null / -1 ✅ 回落 13 节
越界值 9 ✅ 回落 13 节
旧桥接层(无 showSingleSelection ✅ 回落 13 节,无异常
端到端 runImportFlow() ✅ 选项 0 保存 13 节、选项 1 保存 11 节,均导入 14 门课程

node --check 通过。测试脚本:work/test_mysy_choice.js(本地,未入库)。

兼容性说明

  • showSingleSelection(title, itemsJson, selectedIndex) 已在 App 端(lib/screens/course_import_screen.dart:4510 注入、:4645 派发、:4809 处理)与浏览器扩展测试工具(tools/CourseImporterTestTool/injected_bridge.js:246)中实现,仓库内已有 20+ 学校脚本使用(AEPU / BTBU / CDUTCM / chaoxing_jiaowu 等)。
  • 已知限制:选择「预设作息时间表」时,课程节次仍是教务口径的编号,作息表的节次时间与教务编号不是一一对应,部分时段会与教务实际上课时间有偏移。因此默认选中「教务系统时间表」;需要按学校作息显示的用户可主动切换。

本 PR 取代此前的 #8(原方案只改 fallback,经实测在真实页面上不生效,已改为本方案)。

- generateTimeSlots() 的页面推导路径(#kbtable 的 th[rowspan] 时间块)本身正确,未改动
- fallback 兜底数组原为硬编码 13 节、08:00 起,与绵阳师范学院实际作息不符
  (实际 11 节、08:15 起);页面时间块缺失时会落到该模板导致节次错位
- 改为实际作息:08:15-09:00 / 09:05-09:50 / 10:20-11:05 / 11:10-11:55 /
  14:00-14:45 / 14:50-15:35 / 16:05-16:50 / 16:55-17:40 / 17:45-18:30 /
  19:00-19:45 / 19:50-20:35(1-2 / 3-4 / 7-8 / 10-11 节各自相邻,节间 5 分钟)

验证:jsdom 加载脚本双路径回归(fallback 与页面推导)均为 11 节,逐条与真实作息一致。
@Mutx163
Mutx163 merged commit 4b7ec43 into Mutx163:main Sep 9, 2026
1 check passed
@Guzheng3 Guzheng3 changed the title fix(MYSY): 修正时间模板 fallback 为学校实际作息(11 节) feat(MYSY): 导入时可选「教务系统时间表」或「预设作息时间表」 Sep 9, 2026
@Guzheng3 Guzheng3 changed the title feat(MYSY): 导入时可选「教务系统时间表」或「预设作息时间表」 fix(MYSY): 修正时间模板 fallback 为学校实际作息(11 节) Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants