feat: 添加账号支持选择学习平台

账号新增 platform 字段,登录/刷新课程/发现课程按平台分发;同时把 JS 脚本收进 script/(目录规范调整)。
This commit is contained in:
study-tool
2026-10-30 01:13:47 +08:00
parent e8634a6317
commit 1a3347f7f9
29 changed files with 449 additions and 297 deletions
+28
View File
@@ -2,6 +2,34 @@
已实现、但还需要你实测确认的事项。确认没问题后把对应条目删掉。
## 添加账号选择平台
**状态**:已实现,待实测确认。
### 做了什么
- 「添加账号」弹窗最上面新增「学习平台」下拉,选项来自 `GET /api/platforms`(当前只有「莞易学」)。
- 账号记录新增 `platform` 字段(SQLite 老库启动时自动 `ALTER TABLE` 补列)。
- 登录(`/api/login`)、刷新课程(`/api/courses`)、发现课程(`/api/discover`、`/api/quiz`)、
开始学习(引擎 `run_one_course`)都按账号所选平台取 `Platform` 上的实现;选「莞易学」时
仍然自动识别旧版 / 新版课程页。
- 以后新增平台:在 `platforms/<名字>.py` 实现 `session` / `login` / `list_courses` / `discover` /
`study` 并注册,下拉里就会多一个选项。
### 怎么测
1. 打开「添加账号」,确认最上面能看到「学习平台 / 莞易学」。
2. 正常添加账号并登录,卡片右上角显示所选平台的 label(当前为「莞易学」)。
3. 用一个已有账号点「刷新课程」「开始学习」,行为应与改动前一致(旧版 / 新版都能跑)。
### 如果没生效
- 下拉是空的:`GET /api/platforms` 应返回 `[{id, label}]`;检查 `platforms/__init__.py` 的
`load_builtin()` 是否导入了平台模块。
- 登录报「平台 xxx 还没有实现登录」:该平台的 `Platform.login` 没注册或 id 对不上。
- 老库启动报 `no such column: platform`:删掉 `data/study.db` 重启(当前账号数据为空),
或确认 `store._ensure_columns()` 已执行。
## 新旧平台合并为「莞易学」
**状态**:已实现,待实测确认。