diff --git a/README.md b/README.md new file mode 100644 index 0000000..3a3c1b3 --- /dev/null +++ b/README.md @@ -0,0 +1,76 @@ +# 研途 · 考研数据工作台 + +将 YAM 的择校工作区和历史考情能力,与 yzw 的全国目录采集、代理池和断点功能整合为独立的本地网页应用。 + +当前安装位置:`F:\@Other\kaoyan-studio`。原 YAM、yzw 和 proxy_pool 源码不作修改。 + +## 启动 + +双击 **启动工作台.cmd**,浏览器打开 **http://127.0.0.1:8765**。窗口关闭后后台服务继续运行;双击 **停止工作台.cmd** 结束本项目服务。 + +本机已安装依赖并完成网页构建,可以直接启动。源码包包含已构建网页,复制到另一台 Windows 电脑后需要 Python 3.12+,首次运行会安装锁定的 Python 依赖。重新构建或修改网页需要 Node.js 22+;缺少网页构建时,脚本会安装前端依赖并构建。浏览器登录使用 Microsoft Edge。 + +在 PowerShell 中也可以运行: + +```powershell +& 'F:\@Other\kaoyan-studio\start.ps1' +# 仅启动后台:start.ps1 -NoBrowser +# 改端口:start.ps1 -Port 8768 +``` + +## 第一次采集 + +1. 在「代理 IP 池」刷新,查看池内 HTTPS 候选和当前路由。默认连接 `http://127.0.0.1:5010`;服务目录为 `C:\Users\Jayson\Desktop\proxy_pool`。 +2. 在「设置与登录」选择网络策略。优先代理在池为空时允许直连;严格代理没有可用 IP 时等待处理。备用代理每行一个 `IP:端口`。代理池存在候选并不保证该 IP 对所有目标网站可用,连接失败会切换并隔离。 +3. 点击「打开登录窗口」,在独立 Edge 窗口完成学信网登录和验证码。工作台会检测登录并保存 Cookie。也可粘贴已登录研招网的 Cookie 请求头,或使用账号密码登录。点击「验证目录访问」确认详情接口权限。 +4. 在「采集任务」选择内容、目录年份、地区、专业和院校关键词。建议先按一个地区、一个专业或一所院校验证,再创建全国任务。专业代码可以从内置目录选择,也可直接输入 6 位代码。 +5. 查看任务日志。暂停可继续;需要登录、代理或限流解除时,处理后点击恢复;取消保留已有数据。关闭或重启服务会保留可恢复断点。 + +研招网学校、专业索引有时可以匿名读取,但方向与科目详情需要登录。程序验证实际业务返回状态,不将 HTTP 200 当作登录成功。目录采集先核对研招页面配置中的年份,避免将当前目录标为历史年份。 + +## 数据查询 + +「院校工作区」支持院校/专业/院系关键词、年份、省份、专业代码、学习方式、学位类型、院校层次、科目、院系、方向、人数及参考线筛选和排序。可收藏候选、勾选 2–6 条记录对比,点击院校名查看来源、分数线和计划历史。 + +每条记录按 **年份 + 院校 + 院系 + 专业 + 方向 + 考试方式 + 科目组合 + 来源** 保存。不同年份、方向及可选科目组合独立保留,相同记录重新采集时更新。人数保留原文:明确「专业」人数可用于筛选;学院、方向、范围或待定口径不会被转换成专业总人数。不同方向和科目组合可能重复展示同一专业人数,不能累加。 + +历史分数线区分专业线、学科参考线和门类参考线,匹配院系后才展示;专项计划线独立保留在详情,不作为普通计划的参考线。表格显示不晚于目录年的最近匹配线,空字段显示「未提供」。历年图表按口径、院系、备注和来源分开,不将门类线标为专业线。 + +985/211 是历史工程参考名单。双一流优先采用数据源标识,同时补充已知的 2022 年名单;名单来源见 `data/school_levels.json`。学校更名、新名单或未识别名称可能需要更新参考元数据。 + +内置 2,255 条专业目录条目和 460 所院校公开索引,来自 YAM 的公共数据文件。**索引并不代表已经采集招生详情**;首次安装的目录和分数线数据库为空。全国采集不限定于这些索引,通过研招网查询全部 31 个省级地区的招生单位。 + +## 原项目数据互通 + +在工作区点击「导入数据」: + +| 格式 | 用途 | 年份规则 | +| --- | --- | --- | +| yzw CSV | 原 `export_major_csv.py` 输出的全部字段 | 原文件无年,必须填写实际招生年份 | +| YAM SQLite | Python 数据库中的 schools/departments、score_lines、admission_plans | 无年份目录须填写;历史分数/计划保留文件年份 | +| YAM JSON 种子 | `data/seeds/yan_zhao_*_all_regions.json` | 只有学校列表时仅导入索引;有方向详情时须提供年份 | +| 工作台 JSON | 完整目录和分数线快照 | 保留各条记录年份 | +| CSV / XLSX | 工作台导出,或包含相应机器字段/中文表头的数据 | 优先文件年份,否则须明确填写 | + +支持 UTF-8 / UTF-8 BOM / GB18030 CSV。一次最多 100 MB、30 万条。导入只读取所选文件,不打开原软件环境或修改源文件;SQLite 使用只读模式。其他版本 YAM 表结构不同的数据库,请从原软件导出兼容文件再导入。 + +可将当前筛选结果导出 CSV、Excel 或完整 JSON。表格导出保留院系/方向代码和字段口径,回导不会凭空增加同一记录。JSON 同时保留相关学校专业的历史分数线;凭据不进入导出。CSV/Excel 对可能被表格软件当作公式的文本加保护前缀。 + +## 本地数据与开发 + +所有运行数据位于项目 `.runtime`:`studio.db` 保存目录、分数、收藏、任务和断点;`settings.json` 保存非机密配置;`chsi-cookie.enc` 由当前 Windows 用户的 DPAPI 加密。密码不持久化,接口不返回 Cookie。备份数据库时先停止工作台,再复制 `.runtime`;恢复加密 Cookie 需要原 Windows 用户环境,否则重新登录即可。 + +服务默认仅监听 `127.0.0.1`,拒绝非本机 Host 和跨来源写入。代理池设置页使用现有 `manage.ps1` 控制本机服务;工作台停止脚本只结束自己管理且进程身份匹配的服务,不停止代理池。 + +```powershell +# 后端行为测试 +.\.venv\Scripts\python.exe -m pytest -q +# 前端逻辑测试及生产构建 +cd frontend +npm.cmd test +npm.cmd run build +``` + +浏览器验收使用独立的测试数据库,运行方式及结果见 `docs/verification.md`。没有真人登录的自动验收不能替代账号登录后的全国采集验证。 + +项目结构:`studio/` 为网络、数据源、存储和 API;`frontend/src/` 为 React 网页;`data/` 为公开参考元数据;`tests/` 为后端行为测试。来源与许可证见 `THIRD_PARTY_NOTICES.md`。 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..38a5fae --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,13 @@ +# 来源与第三方声明 + +本项目独立实现采集器、存储、任务和网页服务,参考以下项目的公开接口及字段设计,不直接运行原仓库模块。 + +- [YAM / 研喵](https://github.com/C-Y-T-258/yam):参考全国目录、掌上考研历史分数/计划接口及择校工作区设计。`data/majors.json` 与 `data/schools.json` 整理自其公共专业目录和院校种子,仅保留公开参考字段,未携带签名、Cookie 或账号。原 `pyproject.toml` 声明 MIT,作者 YAM Contributors;本地原仓库没有单独的 LICENSE 文件。 +- [yzw](https://github.com/freecho/yzw):参考学校/专业/方向 API、CSV 字段和代理策略。学校层次参考数据以原文件为基础,补充学信网发布的教育部名单、名称别名,并修正中国中医科学院的 211 误标。原项目 MIT,Copyright (c) 2025 freecho,完整许可副本在 `licenses/yzw-MIT.txt`。 +- [proxy_pool](https://github.com/jhao104/proxy_pool):使用用户已有的 Flask API 和本机 `manage.ps1`,不内嵌或修改代理池源码。 + +参考名单来源:[985 名单](https://www.moe.gov.cn/srcsite/A22/s7065/200612/t20061206_128833.html)、[学信网发布的教育部 211 名单](https://gaokao.chsi.com.cn/gkxx/gxmd/211gc.shtml)、[第二轮双一流通知](https://www.moe.gov.cn/srcsite/A22/s7065/202202/t20220211_598710.html)。985/211 用于历史工程参考;双一流标识优先采用采集来源,静态名单为已知参考子集。 + +Python / JavaScript 依赖保留其自身许可证。运行环境包括 FastAPI、Starlette、Uvicorn、requests、Beautiful Soup、openpyxl、Playwright、React、Vite、TypeScript、Lucide;版本记录在 `requirements.lock` 和 `frontend/package-lock.json`,许可证原文随安装包提供。 + +采集数据的准确性、完整性和开放年份取决于原网站,应用保留来源及口径,并明确标记未知字段。内置索引不等同于已经采集的招生数据。 diff --git a/data/school_levels.json b/data/school_levels.json new file mode 100644 index 0000000..e299182 --- /dev/null +++ b/data/school_levels.json @@ -0,0 +1,294 @@ +{ + "985": [ + "上海交通大学", + "东北大学", + "东南大学", + "中南大学", + "中国人民大学", + "中国农业大学", + "中国海洋大学", + "中国科学技术大学", + "中央民族大学", + "中山大学", + "兰州大学", + "北京大学", + "北京师范大学", + "北京理工大学", + "北京航空航天大学", + "华东师范大学", + "华中科技大学", + "华南理工大学", + "南京大学", + "南开大学", + "厦门大学", + "吉林大学", + "同济大学", + "哈尔滨工业大学", + "四川大学", + "国防科学技术大学", + "国防科技大学", + "复旦大学", + "大连理工大学", + "天津大学", + "山东大学", + "武汉大学", + "浙江大学", + "清华大学", + "湖南大学", + "电子科技大学", + "西北农林科技大学", + "西北工业大学", + "西安交通大学", + "重庆大学" + ], + "211": [ + "上海交通大学", + "上海外国语大学", + "上海大学", + "上海财经大学", + "东北农业大学", + "东北大学", + "东北师范大学", + "东北林业大学", + "东华大学", + "东南大学", + "中南大学", + "中南财经政法大学", + "中国人民大学", + "中国传媒大学", + "中国农业大学", + "中国地质大学(北京)", + "中国地质大学(武汉)", + "中国政法大学", + "中国海洋大学", + "中国石油大学(北京)", + "中国石油大学(华东)", + "中国矿业大学", + "中国矿业大学(北京)", + "中国矿业大学(徐州)", + "中国科学技术大学", + "中国药科大学", + "中央民族大学", + "中央财经大学", + "中央音乐学院", + "中山大学", + "云南大学", + "兰州大学", + "内蒙古大学", + "北京中医药大学", + "北京交通大学", + "北京体育大学", + "北京化工大学", + "北京外国语大学", + "北京大学", + "北京工业大学", + "北京师范大学", + "北京林业大学", + "北京理工大学", + "北京科技大学", + "北京航空航天大学", + "北京邮电大学", + "华东师范大学", + "华东理工大学", + "华中农业大学", + "华中师范大学", + "华中科技大学", + "华北电力大学", + "华北电力大学(保定)", + "华北电力大学(北京)", + "华南师范大学", + "华南理工大学", + "南京农业大学", + "南京大学", + "南京师范大学", + "南京理工大学", + "南京航空航天大学", + "南开大学", + "南昌大学", + "厦门大学", + "合肥工业大学", + "吉林大学", + "同济大学", + "哈尔滨工业大学", + "哈尔滨工程大学", + "四川农业大学", + "四川大学", + "国防科学技术大学", + "国防科技大学", + "复旦大学", + "大连海事大学", + "大连理工大学", + "天津医科大学", + "天津大学", + "太原理工大学", + "宁夏大学", + "安徽大学", + "对外经济贸易大学", + "山东大学", + "广西大学", + "延边大学", + "新疆大学", + "暨南大学", + "武汉大学", + "武汉理工大学", + "江南大学", + "河北工业大学", + "河海大学", + "浙江大学", + "海军军医大学", + "海南大学", + "清华大学", + "湖南大学", + "湖南师范大学", + "电子科技大学", + "石河子大学", + "福州大学", + "空军军医大学", + "第二军医大学", + "第四军医大学", + "苏州大学", + "西北农林科技大学", + "西北大学", + "西北工业大学", + "西南交通大学", + "西南大学", + "西南财经大学", + "西安交通大学", + "西安电子科技大学", + "西藏大学", + "贵州大学", + "辽宁大学", + "郑州大学", + "重庆大学", + "长安大学", + "陕西师范大学", + "青海大学" + ], + "double_first_class_2022_known": [ + "上海中医药大学", + "上海交通大学", + "上海外国语大学", + "上海大学", + "上海财经大学", + "东北农业大学", + "东北大学", + "东北师范大学", + "东北林业大学", + "东华大学", + "东南大学", + "中南大学", + "中南财经政法大学", + "中国人民大学", + "中国传媒大学", + "中国农业大学", + "中国地质大学(北京)", + "中国地质大学(武汉)", + "中国政法大学", + "中国海洋大学", + "中国石油大学(北京)", + "中国石油大学(华东)", + "中国矿业大学", + "中国矿业大学(北京)", + "中国科学技术大学", + "中国药科大学", + "中央民族大学", + "中央财经大学", + "中央音乐学院", + "中山大学", + "云南大学", + "兰州大学", + "内蒙古大学", + "北京中医药大学", + "北京交通大学", + "北京体育大学", + "北京化工大学", + "北京协和医学院", + "北京外国语大学", + "北京大学", + "北京工业大学", + "北京师范大学", + "北京林业大学", + "北京理工大学", + "北京科技大学", + "北京航空航天大学", + "北京邮电大学", + "华东师范大学", + "华东理工大学", + "华中农业大学", + "华中师范大学", + "华中科技大学", + "华北电力大学", + "华南师范大学", + "华南理工大学", + "南京农业大学", + "南京医科大学", + "南京大学", + "南京师范大学", + "南京理工大学", + "南京航空航天大学", + "南开大学", + "南方科技大学", + "南昌大学", + "厦门大学", + "合肥工业大学", + "吉林大学", + "同济大学", + "哈尔滨工业大学", + "哈尔滨工程大学", + "四川大学", + "国防科技大学", + "复旦大学", + "大连海事大学", + "大连理工大学", + "天津中医药大学", + "天津医科大学", + "天津大学", + "天津工业大学", + "太原理工大学", + "宁夏大学", + "安徽大学", + "对外经济贸易大学", + "山东大学", + "广州中医药大学", + "广西大学", + "延边大学", + "成都理工大学", + "新疆大学", + "暨南大学", + "武汉大学", + "武汉理工大学", + "江南大学", + "河北工业大学", + "河海大学", + "浙江大学", + "海南大学", + "清华大学", + "湖南大学", + "湖南师范大学", + "电子科技大学", + "石河子大学", + "福州大学", + "苏州大学", + "西北农林科技大学", + "西北大学", + "西北工业大学", + "西南交通大学", + "西南大学", + "西南财经大学", + "西安交通大学", + "西安电子科技大学", + "西藏大学", + "贵州大学", + "辽宁大学", + "郑州大学", + "重庆大学", + "长安大学", + "青海大学" + ], + "sources": [ + "https://www.moe.gov.cn/srcsite/A22/s7065/200612/t20061206_128833.html", + "https://gaokao.chsi.com.cn/gkxx/gxmd/211gc.shtml", + "https://www.moe.gov.cn/srcsite/A22/s7065/202202/t20220211_598710.html" + ], + "note": "历史工程名单与已知名称别名,用于参考筛选。211以原yzw名单为基础并与学信网教育部名单核对补充、排除中国中医科学院误标。双一流优先实时研招网syl或导入字段;静态2022名单只是已知子集。" +} \ No newline at end of file diff --git a/docs/progress.md b/docs/progress.md index 7716ceb..17dbd6c 100644 --- a/docs/progress.md +++ b/docs/progress.md @@ -7,8 +7,10 @@ Task 1: complete — 5 tests green; cross-year records, alternatives, conservati Task 2: complete — 5 tests green; shared proxy, strict route, fallback, rotation, DPAPI vault. Task 3: complete — 5 tests green; pagination, business login status, year mismatch, exact campus, pause/resume. Task 4: complete — 5 tests green; file import/export, YAM SQLite, favorites, origin guard, formula-safe exports. -Task 5: pending -Task 6: pending +Task 5: complete — 3 frontend logic tests, production build, full Edge acceptance including mobile passed. +Task 6: final packaging — launch/reuse/stop/restart verified; README/notices ready; independent review findings fixed with regression tests. Public index: 2,255 major entries and 460 unique schools extracted from YAM public data files. Seed index contains no admissions snapshots, cookies or signed request tokens. +Final verification: 35 backend tests passed; 3 frontend tests passed; build exit 0; browser QA PASS. Details: docs/verification.md. + diff --git a/docs/verification.md b/docs/verification.md new file mode 100644 index 0000000..44aa1f0 --- /dev/null +++ b/docs/verification.md @@ -0,0 +1,22 @@ +# 验证记录 + +2026-10-11,Windows、本地独立虚拟环境,Python 3.12.13 / Node 24.16。 + +- 后端:`python -m pytest -q`,35 passed。Starlette TestClient 提示一条 httpx 迁移 warning,测试退出 0,生产服务不使用 TestClient。 +- 前端:`npm test`,3 passed;`npm run build`,TypeScript 检查与 Vite 生产构建退出 0。 +- Edge 实际浏览器:独立端口 8766、独立 `.runtime/qa/db`,验证导入→科目筛选→收藏→对比→历史趋势→Excel 下载;任务/代理/设置页面;设置保存;390px 手机宽度无页面溢出;无 pageerror。测试数据均标明「自动验收样例」,没有写入正式数据库。 +- 启动脚本:Windows PowerShell 首启、重复启动、停止、重新启动均退出 0;正式服务在 127.0.0.1:8765,健康检查应用身份和项目路径匹配。 +- 真实数据源:proxy_pool `/count/` 正常响应;研招页面 `curYear=2027` 可核实;匿名北京大学学校及 081200 专业索引可返回,方向接口要求登录,按 LoginRequired 处理;掌上考研精确匹配北京大学,2025 年 081200 查询返回 1 条门类参考线和 2 条历史计划。真实探测只读取少量公开数据,不写入正式目录。 +- 独立只读审查:复现并修复专项线覆盖、同名跨域 Cookie、任务失败恢复竞态、服务退出被误取消、文件往返丢失身份字段、学院人数误升格、YAM 种子误识别、院校关键词范围、参考书 JSON 字符串、业务限流等问题,补充相应回归。 + +自动验收未使用真人学信网账号,未对全部院校进行实网抓取。登录后的全国采集能力取决于账号状态、代理可用性、开放目录年份和数据源限流。 + +复跑浏览器验收(只使用测试库): + +```powershell +.\.venv\Scripts\python.exe -m studio --port 8766 --data-dir .runtime\qa\db +# 在另一个终端运行 +.\.venv\Scripts\python.exe tools\browser_qa.py +``` + +正式服务不会自动开始采集,需要用户在网页创建任务。 diff --git a/frontend/index.html b/frontend/index.html index 552efd2..1106513 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -1,2 +1,17 @@ -研途 · 考研数据工作台
+ + + + + + + 研途 · 考研数据工作台 + + +
+ + + diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 736a5d8..dd8c2be 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,54 +1,522 @@ -import { useState, useEffect, useCallback, useId } from 'react'; -import type { ReactNode } from 'react'; -import { ArrowRight, ArrowUpRight, BarChart3, BookOpen, Check, ChevronLeft, ChevronRight, Database, Download, FileUp, Globe2, GraduationCap, LayoutDashboard, ListFilter, Loader2, Network, Pause, Play, Plus, RefreshCw, Search, Settings2, ShieldCheck, Square, Star, X } from 'lucide-react'; -import { api, post } from './api'; -import { display, scopeName, statusName, modeName, queryString, scoreSeries } from './format'; -import type { Row, Overview, Province, Major, Job, Log, Config, Proxy, Auth, History, Filters } from './types'; +import { useState, useEffect, useCallback, useId } from "react"; +import type { ReactNode } from "react"; +import { + ArrowRight, + ArrowUpRight, + BarChart3, + BookOpen, + Check, + ChevronLeft, + ChevronRight, + Database, + Download, + FileUp, + Globe2, + GraduationCap, + LayoutDashboard, + ListFilter, + Loader2, + Network, + Pause, + Play, + Plus, + RefreshCw, + Search, + Settings2, + ShieldCheck, + Square, + Star, + X, +} from "lucide-react"; +import { api, post } from "./api"; +import { + display, + scopeName, + statusName, + modeName, + queryString, + scoreSeries, +} from "./format"; +import type { + Row, + Overview, + Province, + Major, + Job, + Log, + Config, + Proxy, + Auth, + History, + Filters, +} from "./types"; -type Tab = 'overview' | 'workspace' | 'jobs' | 'proxy' | 'settings'; +type Tab = "overview" | "workspace" | "jobs" | "proxy" | "settings"; type Notify = (message: string, error?: boolean) => void; -const NAV = [{ key: 'overview', label: '数据概览', icon: LayoutDashboard }, { key: 'workspace', label: '院校工作区', icon: GraduationCap }, { key: 'jobs', label: '采集任务', icon: RefreshCw }, { key: 'proxy', label: '代理 IP 池', icon: Network }, { key: 'settings', label: '设置与登录', icon: Settings2 }] as const; +const NAV = [ + { key: "overview", label: "数据概览", icon: LayoutDashboard }, + { key: "workspace", label: "院校工作区", icon: GraduationCap }, + { key: "jobs", label: "采集任务", icon: RefreshCw }, + { key: "proxy", label: "代理 IP 池", icon: Network }, + { key: "settings", label: "设置与登录", icon: Settings2 }, +] as const; const currentYear = new Date().getFullYear(); -const activeStates = ['queued', 'running']; -const resumeStates = ['paused', 'partial', 'failed', 'waiting_login', 'waiting_proxy']; +const activeStates = ["queued", "running"]; +const resumeStates = [ + "paused", + "partial", + "failed", + "waiting_login", + "waiting_proxy", + "waiting_source", +]; -function Badge({ children, tone = '' }: { children: ReactNode; tone?: string }) { return {children}; } -function Empty({ title, children }: { title: string; children?: ReactNode }) { return

{title}

{children}
; } -function Modal({ title, children, close, wide = false }: { title: string; children: ReactNode; close: () => void; wide?: boolean }) { - useEffect(() => { const listener = (e: KeyboardEvent) => { if (e.key === 'Escape') close(); }; document.addEventListener('keydown', listener); const old = document.body.style.overflow; document.body.style.overflow = 'hidden'; return () => { document.removeEventListener('keydown', listener); document.body.style.overflow = old; }; }, [close]); - return
e.stopPropagation()}>

{title}

{children}
; +function Badge({ + children, + tone = "", +}: { + children: ReactNode; + tone?: string; +}) { + return {children}; } -function MajorInput({ majors, value, onChange, label = '专业代码', required = false }: { majors: Major[]; value: string; onChange: (value: string) => void; label?: string; required?: boolean }) { +function Empty({ title, children }: { title: string; children?: ReactNode }) { + return ( +
+ +

{title}

+
{children}
+
+ ); +} +function Modal({ + title, + children, + close, + wide = false, +}: { + title: string; + children: ReactNode; + close: () => void; + wide?: boolean; +}) { + useEffect(() => { + const listener = (e: KeyboardEvent) => { + if (e.key === "Escape") close(); + }; + document.addEventListener("keydown", listener); + const old = document.body.style.overflow; + document.body.style.overflow = "hidden"; + return () => { + document.removeEventListener("keydown", listener); + document.body.style.overflow = old; + }; + }, [close]); + return ( +
+
e.stopPropagation()} + > +
+

{title}

+ +
+ {children} +
+
+ ); +} +function MajorInput({ + majors, + value, + onChange, + label = "专业代码", + required = false, +}: { + majors: Major[]; + value: string; + onChange: (value: string) => void; + label?: string; + required?: boolean; +}) { const id = useId(); - return ; + return ( + + ); +} +function Stat({ + label, + value, + icon, + sub, +}: { + label: string; + value: number; + icon: ReactNode; + sub: string; +}) { + return ( +
+
+ {label} + {icon} +
+ {Number(value || 0).toLocaleString()} + {sub} +
+ ); } -function Stat({ label, value, icon, sub }: { label: string; value: number; icon: ReactNode; sub: string }) { return
{label}{icon}
{Number(value || 0).toLocaleString()}{sub}
; } export default function App() { - const [tab, setTab] = useState('overview'); + const [tab, setTab] = useState("overview"); const [overview, setOverview] = useState(null); const [majors, setMajors] = useState([]); const [version, setVersion] = useState(0); - const [notice, setNotice] = useState<{ message: string; error: boolean } | null>(null); - const notify = useCallback((message, error = false) => setNotice({ message, error }), []); - const refresh = useCallback(() => setVersion(v => v + 1), []); - useEffect(() => { const controller = new AbortController(); Promise.all([api('/overview', { signal: controller.signal }), api('/majors', { signal: controller.signal })]).then(([o, m]) => { setOverview(o); setMajors(m); }).catch(e => { if (e.name !== 'AbortError') notify(e.message, true); }); return () => controller.abort(); }, [version, notify]); - useEffect(() => { if (!notice) return; const timer = setTimeout(() => setNotice(null), 6500); return () => clearTimeout(timer); }, [notice]); + const [notice, setNotice] = useState<{ + message: string; + error: boolean; + } | null>(null); + const notify = useCallback( + (message, error = false) => setNotice({ message, error }), + [], + ); + const refresh = useCallback(() => setVersion((v) => v + 1), []); + useEffect(() => { + const controller = new AbortController(); + Promise.all([ + api("/overview", { signal: controller.signal }), + api("/majors", { signal: controller.signal }), + ]) + .then(([o, m]) => { + setOverview(o); + setMajors(m); + }) + .catch((e) => { + if (e.name !== "AbortError") notify(e.message, true); + }); + return () => controller.abort(); + }, [version, notify]); + useEffect(() => { + if (!notice) return; + const timer = setTimeout(() => setNotice(null), 6500); + return () => clearTimeout(timer); + }, [notice]); const props = { overview, majors, notify, refresh }; - return
工作台 {NAV.find(n => n.key === tab)?.label}
本地运行
{tab === 'overview' && }{tab === 'workspace' && }{tab === 'jobs' && }{tab === 'proxy' && }{tab === 'settings' && }
研途 · 数据以院校当年招生简章为准全国招生目录 / 历年考情 / 本地工作区
{notice &&
{notice.error ? : }{notice.message}
}
; + return ( +
+ +
+
+
+ 工作台 + {NAV.find((n) => n.key === tab)?.label} +
+
+ + 本地运行 + + +
+
+
+ {tab === "overview" && } + {tab === "workspace" && } + {tab === "jobs" && } + {tab === "proxy" && } + {tab === "settings" && } +
+
+ 研途 · 数据以院校当年招生简章为准 + 全国招生目录 / 历年考情 / 本地工作区 +
+
+ {notice && ( +
+ {notice.error ? : } + {notice.message} + +
+ )} +
+ ); } -type Shared = { overview: Overview | null; majors: Major[]; notify: Notify; refresh: () => void }; -function PageTitle({ eyebrow, title, description, children }: { eyebrow: string; title: string; description: string; children?: ReactNode }) { return
{eyebrow}

{title}

{description}

{children}
; } +type Shared = { + overview: Overview | null; + majors: Major[]; + notify: Notify; + refresh: () => void; +}; +function PageTitle({ + eyebrow, + title, + description, + children, +}: { + eyebrow: string; + title: string; + description: string; + children?: ReactNode; +}) { + return ( +
+
+
{eyebrow}
+

{title}

+

{description}

+
+
{children}
+
+ ); +} function Dashboard({ overview: o, go }: Shared & { go: (tab: Tab) => void }) { const [jobs, setJobs] = useState([]); - useEffect(() => { const controller = new AbortController(); api('/jobs', { signal: controller.signal }).then(setJobs).catch(() => {}); return () => controller.abort(); }, []); - return <>
} sub={`另有 ${o?.indexed_schools || 0} 所院校公开索引`} />} sub="按年份、方向和科目组合保存" />} sub="保留专业、学科与门类口径" />} sub="在工作区筛选与横向对比" />
开始你的研究

一个工作区,两种数据来源

先建立招生目录,再补充历年分数线和计划。已有数据也可以直接导入,继续筛选、收藏与对比。

01
连接账号与代理池登录学信网,选择当前网络策略
02
选择年份、地区和专业按省采集,也可覆盖全国 31 个省级地区
03
把数据变成择校清单多条件筛选、历史趋势和 Excel 导出

已接入数据来源

2 个来源
{o?.sources.map((s, i) => {i === 0 ? : }
{s.name}{s.role}
)}

数据保存在本机。每条记录都保留来源和年份,未知字段明确标记。

最近采集任务

{jobs.length ?
{jobs.slice(0, 4).map(j =>
{modeName(j.params.mode)} · {j.params.year} 年{j.message}
{statusName(j.status)}{j.completed_units} 个完成单元
)}
:
还没有采集任务

创建一个任务,或在院校工作区导入 YAM / yzw 的已有数据。

}
; + useEffect(() => { + const controller = new AbortController(); + api("/jobs", { signal: controller.signal }) + .then(setJobs) + .catch(() => {}); + return () => controller.abort(); + }, []); + return ( + <> + + + +
+ } + sub={`另有 ${o?.indexed_schools || 0} 所院校公开索引`} + /> + } + sub="按年份、方向和科目组合保存" + /> + } + sub="保留专业、学科与门类口径" + /> + } + sub="在工作区筛选与横向对比" + /> +
+
+
+
开始你的研究
+

一个工作区,两种数据来源

+

+ 先建立招生目录,再补充历年分数线和计划。已有数据也可以直接导入,继续筛选、收藏与对比。 +

+
+
+ 01 +
+ 连接账号与代理池 + 登录学信网,选择当前网络策略 +
+ +
+
+ 02 +
+ 选择年份、地区和专业 + 按省采集,也可覆盖全国 31 个省级地区 +
+ +
+
+ 03 +
+ 把数据变成择校清单 + 多条件筛选、历史趋势和 Excel 导出 +
+ +
+
+
+
+
+

已接入数据来源

+ 2 个来源 +
+ {o?.sources.map((s, i) => ( + + + {i === 0 ? : } + +
+ {s.name} + {s.role} +
+ +
+ ))} +
+ +

数据保存在本机。每条记录都保留来源和年份,未知字段明确标记。

+
+ +
+
+
+
+

最近采集任务

+ +
+ {jobs.length ? ( +
+ {jobs.slice(0, 4).map((j) => ( +
+ +
+ + {modeName(j.params.mode)} · {j.params.year} 年 + + {j.message} +
+ + {statusName(j.status)} + + {j.completed_units} 个完成单元 +
+ ))} +
+ ) : ( +
+
+ +
+
+ 还没有采集任务 +

创建一个任务,或在院校工作区导入 YAM / yzw 的已有数据。

+
+ +
+ )} +
+ + ); } function Workspace({ overview, majors, notify, refresh }: Shared) { - const [filters, setFilters] = useState({ sort: 'year' }); + const [filters, setFilters] = useState({ sort: "year" }); const [page, setPage] = useState(1); const [rows, setRows] = useState([]); const [total, setTotal] = useState(0); @@ -60,69 +528,1524 @@ function Workspace({ overview, majors, notify, refresh }: Shared) { const [importing, setImporting] = useState(false); const [more, setMore] = useState(false); const query = queryString({ ...filters, page, page_size: 30 }); - useEffect(() => { const controller = new AbortController(); setLoading(true); const timer = setTimeout(() => api<{ items: Row[]; total: number }>('/catalog?' + query, { signal: controller.signal }).then(data => { setRows(data.items); setTotal(data.total); }).catch(e => { if (e.name !== 'AbortError') notify(e.message, true); }).finally(() => { if (!controller.signal.aborted) setLoading(false); }), 180); return () => { clearTimeout(timer); controller.abort(); }; }, [query, localVersion, notify]); - const change = (key: string, value: string | boolean) => { setFilters(f => ({ ...f, [key]: value })); setPage(1); }; - async function favorite(row: Row) { try { await api(`/catalog/${row.id}/favorite`, { method: 'PUT', body: JSON.stringify({ enabled: !row.favorite }) }); setLocalVersion(v => v + 1); refresh(); } catch (e) { notify((e as Error).message, true); } } - const toggleSelected = (row: Row) => { if (selected.some(s => s.id === row.id)) setSelected(s => s.filter(v => v.id !== row.id)); else if (selected.length < 6) setSelected(s => [...s, row]); else notify('最多同时对比 6 条记录', true); }; - return <>
{more &&
change('major_code', v)} />
}
{total.toLocaleString()} 条记录 · 人数保留原文,科目组合分别展示{loading && }
{rows.length ?
{rows.map(row => )}
对比院校 / 专业院系 / 方向初试科目招生人数最近参考线年份 / 来源收藏
s.id === row.id)} onChange={() => toggleSelected(row)} />{row.major_code} · {display(row.major_name)}
{row.province && {row.province}}{row.level && {row.level}}{row.study_mode && {row.study_mode}}
{display(row.department_name)}
{display(row.direction)}
{row.subjects.some(Boolean) ? row.subjects.map((s, i) => s &&
{s}
) : 未提供}
{display(row.quota)}{row.quota_text || '来源未提供人数'}{row.score_total !== null ? <>{row.score_total}{row.score_year} · {scopeName(row.score_scope)} : 未提供}{row.year}{row.source}{!row.year_verified && 年份由文件指定}
: !loading ?

可以调整筛选条件,或导入 YAM / yzw 数据、创建新的采集任务。

:
正在读取本地数据…
}
第 {page} / {Math.max(1, Math.ceil(total / 30))} 页 · 每页 30 条
{selected.length > 0 &&
已选 {selected.length} 条记录{selected.map(s => s.school_name).join(' / ')}
}{detail !== null && setDetail(null)} notify={notify} />}{compare && setCompare(false)} />}{importing && setImporting(false)} notify={notify} done={() => { setLocalVersion(v => v + 1); refresh(); }} />}; + useEffect(() => { + const controller = new AbortController(); + setLoading(true); + const timer = setTimeout( + () => + api<{ items: Row[]; total: number }>("/catalog?" + query, { + signal: controller.signal, + }) + .then((data) => { + setRows(data.items); + setTotal(data.total); + }) + .catch((e) => { + if (e.name !== "AbortError") notify(e.message, true); + }) + .finally(() => { + if (!controller.signal.aborted) setLoading(false); + }), + 180, + ); + return () => { + clearTimeout(timer); + controller.abort(); + }; + }, [query, localVersion, notify]); + const change = (key: string, value: string | boolean) => { + setFilters((f) => ({ ...f, [key]: value })); + setPage(1); + }; + async function favorite(row: Row) { + try { + await api(`/catalog/${row.id}/favorite`, { + method: "PUT", + body: JSON.stringify({ enabled: !row.favorite }), + }); + setLocalVersion((v) => v + 1); + refresh(); + } catch (e) { + notify((e as Error).message, true); + } + } + const toggleSelected = (row: Row) => { + if (selected.some((s) => s.id === row.id)) + setSelected((s) => s.filter((v) => v.id !== row.id)); + else if (selected.length < 6) setSelected((s) => [...s, row]); + else notify("最多同时对比 6 条记录", true); + }; + return ( + <> + + + + +
+
+ + + + + +
+ {more && ( +
+ change("major_code", v)} + /> + + + + + + + + + +
+ )} +
+
+
+
+ {total.toLocaleString()} 条记录{" "} + · 人数保留原文,科目组合分别展示 + {loading && } +
+ +
+ {rows.length ? ( +
+ + + + + + + + + + + + + + + {rows.map((row) => ( + + + + + + + + + + + ))} + +
对比院校 / 专业院系 / 方向初试科目招生人数最近参考线年份 / 来源收藏
+ s.id === row.id)} + onChange={() => toggleSelected(row)} + /> + + + + {row.major_code} · {display(row.major_name)} + +
+ {row.province && {row.province}} + {row.level && {row.level}} + {row.study_mode && {row.study_mode}} +
+
+
{display(row.department_name)}
+ {display(row.direction)} +
+ {row.subjects.some(Boolean) ? ( + row.subjects.map((s, i) => s &&
{s}
) + ) : ( + 未提供 + )} +
+ {display(row.quota)} + {row.quota_text || "来源未提供人数"} + + {row.score_total !== null ? ( + <> + {row.score_total} + + {row.score_year} · {scopeName(row.score_scope)} + + + ) : ( + 未提供 + )} + + {row.year} + {row.source} + {!row.year_verified && ( + + 年份由文件指定 + + )} + + +
+
+ ) : !loading ? ( + +

可以调整筛选条件,或导入 YAM / yzw 数据、创建新的采集任务。

+ +
+ ) : ( +
+ + 正在读取本地数据… +
+ )} +
+ + 第 {page} / {Math.max(1, Math.ceil(total / 30))} 页 · 每页 30 条 + +
+ + +
+
+
+ {selected.length > 0 && ( +
+
+ + 已选 {selected.length} 条记录 + {selected.map((s) => s.school_name).join(" / ")} +
+ + +
+ )} + {detail !== null && ( + setDetail(null)} notify={notify} /> + )} + {compare && ( + setCompare(false)} /> + )} + {importing && ( + setImporting(false)} + notify={notify} + done={() => { + setLocalVersion((v) => v + 1); + refresh(); + }} + /> + )} + + ); } -function ImportDialog({ close, done, notify }: { close: () => void; done: () => void; notify: Notify }) { - const [file, setFile] = useState(null), [year, setYear] = useState(String(currentYear)), [busy, setBusy] = useState(false); - async function submit(e: React.FormEvent) { e.preventDefault(); if (!file) return; const body = new FormData(); body.set('file', file); if (year) body.set('year', year); setBusy(true); try { const result = await api<{ records: number; scores: number }>('/import', { method: 'POST', body }); notify(`已导入 ${result.records} 条目录/计划、${result.scores} 条分数线`); done(); close(); } catch (e) { notify((e as Error).message, true); } finally { setBusy(false); } } - return

支持 yzw CSV、工作台 JSON / Excel,以及 YAM SQLite 数据库。相同记录按年份更新,其他年份保留。

文件本身有年份时使用文件年份。yzw CSV 和 YAM 无年份目录必须明确填写;分数线仍保留其原始年份。
; +function ImportDialog({ + close, + done, + notify, +}: { + close: () => void; + done: () => void; + notify: Notify; +}) { + const [file, setFile] = useState(null), + [year, setYear] = useState(""), + [busy, setBusy] = useState(false); + async function submit(e: React.FormEvent) { + e.preventDefault(); + if (!file) return; + const body = new FormData(); + body.set("file", file); + if (year) body.set("year", year); + setBusy(true); + try { + const result = await api<{ records: number; scores: number; indexed_schools: number }>("/import", { + method: "POST", + body, + }); + notify(`已导入 ${result.records} 条目录/计划、${result.scores} 条分数线${result.indexed_schools ? `,${result.indexed_schools} 所院校索引` : ""}`); + done(); + close(); + } catch (e) { + notify((e as Error).message, true); + } finally { + setBusy(false); + } + } + return ( + +
+

+ 支持 yzw CSV、工作台 JSON / Excel、YAM 院校种子和 SQLite + 数据库。相同记录按年份更新,其他年份保留。 +

+ + +
+ 文件本身有年份时使用文件年份。yzw CSV 和 YAM + 无年份目录必须明确填写;分数线仍保留其原始年份。 + 无详情的 YAM 种子仅导入院校索引。 +
+ +
+
+ ); } function Comparison({ rows, close }: { rows: Row[]; close: () => void }) { - const fields: [string, (row: Row) => ReactNode][] = [['专业', r => `${r.major_code} ${r.major_name}`], ['地区 / 层次', r => `${r.province} ${r.level}`], ['院系', r => display(r.department_name)], ['方向', r => display(r.direction)], ['学制形式', r => display(r.study_mode)], ['初试科目', r => r.subjects.filter(Boolean).map((s, i) =>
{s}
)], ['人数原文', r => display(r.quota_text)], ['明确人数 / 口径', r => `${display(r.quota)} / ${r.quota_scope === 'major' ? '专业' : r.quota_scope === 'college' ? '学院' : '口径待核实'}`], ['最近参考线', r => r.score_total !== null ? `${r.score_year} 年 ${r.score_total} · ${scopeName(r.score_scope)}` : '未提供'], ['导师', r => display(r.advisor)], ['专项计划', r => r.special_plans.join(' / ') || '未提供'], ['来源', r => `${r.year} 年 · ${r.source}`]]; - return

每列是一条独立方向/科目组合。专业人数可能重复展示,不能按列相加。

{rows.map(r => )}{fields.map(([label, field]) => {rows.map(r => )})}
比较项{r.school_name}{r.year} 年
{label}{field(r)}
; + const fields: [string, (row: Row) => ReactNode][] = [ + ["专业", (r) => `${r.major_code} ${r.major_name}`], + ["地区 / 层次", (r) => `${r.province} ${r.level}`], + ["院系", (r) => display(r.department_name)], + ["方向", (r) => display(r.direction)], + ["学制形式", (r) => display(r.study_mode)], + [ + "初试科目", + (r) => r.subjects.filter(Boolean).map((s, i) =>
{s}
), + ], + ["人数原文", (r) => display(r.quota_text)], + [ + "明确人数 / 口径", + (r) => + `${display(r.quota)} / ${r.quota_scope === "major" ? "专业" : r.quota_scope === "college" ? "学院" : "口径待核实"}`, + ], + [ + "最近参考线", + (r) => + r.score_total !== null + ? `${r.score_year} 年 ${r.score_total} · ${scopeName(r.score_scope)}` + : "未提供", + ], + ["导师", (r) => display(r.advisor)], + ["专项计划", (r) => r.special_plans.join(" / ") || "未提供"], + ["来源", (r) => `${r.year} 年 · ${r.source}`], + ]; + return ( + +
+

+ 每列是一条独立方向/科目组合。专业人数可能重复展示,不能按列相加。 +

+
+ + + + + {rows.map((r) => ( + + ))} + + + + {fields.map(([label, field]) => ( + + + {rows.map((r) => ( + + ))} + + ))} + +
比较项 + {r.school_name} + {r.year} 年 +
{label}{field(r)}
+
+
+
+ ); } -function Detail({ rid, close, notify }: { rid: number; close: () => void; notify: Notify }) { +function Detail({ + rid, + close, + notify, +}: { + rid: number; + close: () => void; + notify: Notify; +}) { const [data, setData] = useState(null); - useEffect(() => { const controller = new AbortController(); api(`/catalog/${rid}`, { signal: controller.signal }).then(setData).catch(e => { if (e.name !== 'AbortError') notify(e.message, true); }); return () => controller.abort(); }, [rid, notify]); + useEffect(() => { + const controller = new AbortController(); + api(`/catalog/${rid}`, { signal: controller.signal }) + .then(setData) + .catch((e) => { + if (e.name !== "AbortError") notify(e.message, true); + }); + return () => controller.abort(); + }, [rid, notify]); const r = data?.record; - return {data && r ?
{r.year} 年{r.province || '地区未提供'}{r.source}{r.year_verified ? '来源年份已核实' : '年份由导入文件指定'}{/^https:\/\//.test(r.source_url) && 查看来源 }
{[['院系', r.department_name], ['研究方向', r.direction], ['学习方式', r.study_mode], ['学位类型', r.degree_type], ['导师', r.advisor], ['拟招生人数原文', r.quota_text], ['专项计划', r.special_plans.join(' / ')], ['采集时间', r.fetched_at]].map(([k, v]) =>
{k}{display(v)}
)}
{r.subjects.filter(Boolean).map((s, i) => {s})}
{r.remarks &&
{r.remarks}
}{r.reference_books?.length ?

参考书:{r.reference_books.join(';')}

: null}

历年分数线

{data.scores.map((s, i) => )}
年份口径总分政治外语业务一业务二备注
{s.year}{scopeName(s.scope)}{s.raw_code}{display(s.total)}{display(s.politics)}{display(s.english)}{display(s.special_one)}{display(s.special_two)}{s.note || '—'}

历年招生计划 / 目录快照

{data.plans.map((p, i) => )}
年份方向招生人数原文科目组合来源
{p.year}{display(p.direction)}{display(p.quota_text)}{p.subjects.filter(Boolean).join(' / ') || '未提供'}{p.source}
:
正在读取…
}
; + return ( + + {data && r ? ( +
+
+ {r.year} 年 + {r.province || "地区未提供"} + {r.source} + + {r.year_verified ? "来源年份已核实" : "年份由导入文件指定"} + + {/^https:\/\//.test(r.source_url) && ( + + 查看来源 + + )} +
+
+ {[ + ["院系", r.department_name], + ["研究方向", r.direction], + ["学习方式", r.study_mode], + ["学位类型", r.degree_type], + ["导师", r.advisor], + ["拟招生人数原文", r.quota_text], + ["专项计划", r.special_plans.join(" / ")], + ["采集时间", r.fetched_at], + ].map(([k, v]) => ( +
+ {k} + {display(v)} +
+ ))} +
+
+ {r.subjects.filter(Boolean).map((s, i) => ( + {s} + ))} +
+ {r.remarks &&
{r.remarks}
} + {r.reference_books?.length ? ( +

参考书:{r.reference_books.join(";")}

+ ) : null} +

历年分数线

+ +
+ + + + + + + + + + + + + + + {data.scores.map((s, i) => ( + + + + + + + + + + + ))} + +
年份口径总分政治外语业务一业务二备注
{s.year} + {scopeName(s.scope)} + {s.raw_code} + {display(s.total)}{display(s.politics)}{display(s.english)}{display(s.special_one)}{display(s.special_two)}{s.note || "—"}
+
+

历年招生计划 / 目录快照

+
+ + + + + + + + + + + + {data.plans.map((p, i) => ( + + + + + + + + ))} + +
年份方向招生人数原文科目组合来源
{p.year}{display(p.direction)}{display(p.quota_text)} + {p.subjects.filter(Boolean).join(" / ") || "未提供"} + {p.source}
+
+
+ ) : ( +
+ + 正在读取… +
+ )} +
+ ); } -function Trend({ scores }: { scores: History['scores'] }) { - const groups = scoreSeries(scores), points = groups.flatMap(g => g.points), colors = ['#14816f', '#4279ae', '#bb883c', '#965f93']; - if (!points.length) return
暂未获取该院系的历史分数线。采集历年考情后可查看趋势。
; - const years = [...new Set(points.map(p => p.year))].sort(), low = Math.floor((Math.min(...points.map(p => p.total)) - 10) / 10) * 10, high = Math.ceil((Math.max(...points.map(p => p.total)) + 10) / 10) * 10; - const x = (year: number) => years.length === 1 ? 380 : 55 + (year - years[0]) / (years[years.length - 1] - years[0]) * 650; - const y = (score: number) => 170 - (score - low) / (high - low) * 140; - return
{[low, (low + high) / 2, high].map(t => {t})}{years.map(t => {t})}{groups.map((g, i) => `${x(p.year)},${y(p.total)}`).join(' ')} />{g.points.map((p, j) => {p.total})})}
{groups.map((g, i) => {g.label})}
; +function Trend({ scores }: { scores: History["scores"] }) { + const groups = scoreSeries(scores), + points = groups.flatMap((g) => g.points), + colors = ["#14816f", "#4279ae", "#bb883c", "#965f93"]; + if (!points.length) + return ( +
+ 暂未获取该院系的历史分数线。采集历年考情后可查看趋势。 +
+ ); + const years = [...new Set(points.map((p) => p.year))].sort(), + low = Math.floor((Math.min(...points.map((p) => p.total)) - 10) / 10) * 10, + high = Math.ceil((Math.max(...points.map((p) => p.total)) + 10) / 10) * 10; + const x = (year: number) => + years.length === 1 + ? 380 + : 55 + ((year - years[0]) / (years[years.length - 1] - years[0])) * 650; + const y = (score: number) => 170 - ((score - low) / (high - low)) * 140; + return ( +
+ + {[low, (low + high) / 2, high].map((t) => ( + + + + {t} + + + ))} + {years.map((t) => ( + + {t} + + ))} + {groups.map((g, i) => ( + + `${x(p.year)},${y(p.total)}`) + .join(" ")} + /> + {g.points.map((p, j) => ( + + + + {p.total} + + + ))} + + ))} + +
+ {groups.map((g, i) => ( + + + {g.label} + + ))} +
+
+ ); } function Tasks({ overview, majors, notify, refresh }: Shared) { - const [mode, setMode] = useState('combined'), [year, setYear] = useState(currentYear + 1), [major, setMajor] = useState(''), [province, setProvince] = useState(''), [school, setSchool] = useState(''), [years, setYears] = useState([currentYear - 2, currentYear - 1, currentYear]), [plans, setPlans] = useState(true), [jobs, setJobs] = useState([]), [logs, setLogs] = useState([]), [selected, setSelected] = useState(''), [busy, setBusy] = useState(false), [config, setConfig] = useState(null); - const load = useCallback(async () => { const data = await api('/jobs'); setJobs(data); setSelected(s => s || data[0]?.id || ''); }, []); - useEffect(() => { load().catch(e => notify(e.message, true)); api('/settings').then(setConfig).catch(e => notify(e.message, true)); }, [load, notify]); - const hasActive = jobs.some(j => activeStates.includes(j.status)); - useEffect(() => { if (!hasActive) return; const timer = setInterval(() => { load().catch(() => {}); refresh(); }, 2500); return () => clearInterval(timer); }, [hasActive, load, refresh]); - const job = jobs.find(j => j.id === selected); + const [mode, setMode] = useState("combined"), + [year, setYear] = useState(currentYear + 1), + [major, setMajor] = useState(""), + [province, setProvince] = useState(""), + [school, setSchool] = useState(""), + [years, setYears] = useState([ + currentYear - 2, + currentYear - 1, + currentYear, + ]), + [plans, setPlans] = useState(true), + [jobs, setJobs] = useState([]), + [logs, setLogs] = useState([]), + [selected, setSelected] = useState(""), + [busy, setBusy] = useState(false), + [config, setConfig] = useState(null); + const load = useCallback(async () => { + const data = await api("/jobs"); + setJobs(data); + setSelected((s) => s || data[0]?.id || ""); + }, []); + useEffect(() => { + load().catch((e) => notify(e.message, true)); + api("/settings") + .then(setConfig) + .catch((e) => notify(e.message, true)); + }, [load, notify]); + const hasActive = jobs.some((j) => activeStates.includes(j.status)); + useEffect(() => { + if (!hasActive) return; + const timer = setInterval(() => { + load().catch(() => {}); + refresh(); + }, 2500); + return () => clearInterval(timer); + }, [hasActive, load, refresh]); + const job = jobs.find((j) => j.id === selected); const stamp = job?.updated_at; - useEffect(() => { if (!selected) return; const controller = new AbortController(); api(`/jobs/${selected}/logs`, { signal: controller.signal }).then(setLogs).catch(e => { if (e.name !== 'AbortError') notify(e.message, true); }); return () => controller.abort(); }, [selected, stamp, notify]); - async function start(e: React.FormEvent) { e.preventDefault(); setBusy(true); try { const result = await post('/jobs', { mode, year, major_code: major, school_keyword: school, provinces: province ? [province] : [], score_years: years, include_plans: plans }); setSelected(result.id); await load(); notify('采集任务已启动'); } catch (e) { notify((e as Error).message, true); } finally { setBusy(false); } } - async function action(action: string) { if (!job) return; setBusy(true); try { await post(`/jobs/${job.id}/${action}`); await load(); refresh(); } catch (e) { notify((e as Error).message, true); } finally { setBusy(false); } } - return <>{config ? modeName(config.network_mode) : '读取网络策略…'}

新建采集

{mode !== 'catalog' && <>
{Array.from({ length: 8 }, (_, i) => currentYear - i).map(y => )}
}
研招网仅开放当前目录。任务开始时核验年份;历史目录可从文件导入。仅采集历年考情时,使用已存目录或指定专业的院校索引。

首次使用,请先在「设置与登录」完成学信网登录。

任务记录

{jobs.length ? jobs.map(j => ) :
还没有任务。填写左侧条件开始采集。
}

运行日志

{job &&
{activeStates.includes(job.status) && }{resumeStates.includes(job.status) && }{!['completed', 'cancelled'].includes(job.status) && }
}
{job ? <>
状态 {statusName(job.status)}完成单元 {job.completed_units}保存记录 {job.records}失败单元 {job.errors}
{job.message}
{logs.map(l =>
{l.message}
)}{!logs.length && 暂无日志}
:
选择一个任务查看进度和日志。
}
; + useEffect(() => { + if (!selected) return; + const controller = new AbortController(); + api(`/jobs/${selected}/logs`, { signal: controller.signal }) + .then(setLogs) + .catch((e) => { + if (e.name !== "AbortError") notify(e.message, true); + }); + return () => controller.abort(); + }, [selected, stamp, notify]); + async function start(e: React.FormEvent) { + e.preventDefault(); + setBusy(true); + try { + const result = await post("/jobs", { + mode, + year, + major_code: major, + school_keyword: school, + provinces: province ? [province] : [], + score_years: years, + include_plans: plans, + }); + setSelected(result.id); + await load(); + notify("采集任务已启动"); + } catch (e) { + notify((e as Error).message, true); + } finally { + setBusy(false); + } + } + async function action(action: string) { + if (!job) return; + setBusy(true); + try { + await post(`/jobs/${job.id}/${action}`); + await load(); + refresh(); + } catch (e) { + notify((e as Error).message, true); + } finally { + setBusy(false); + } + } + return ( + <> + + + {config ? modeName(config.network_mode) : "读取网络策略…"} + + +
+
+

新建采集

+
+ +
+ + +
+ + + {mode !== "catalog" && ( + <> + +
+ {Array.from({ length: 8 }, (_, i) => currentYear - i).map( + (y) => ( + + ), + )} +
+ + + )} +
+ 研招网仅开放当前目录。任务开始时核验年份;历史目录可从文件导入。仅采集历年考情时,使用已存目录或指定专业的院校索引。 +
+ +

+ 首次使用,请先在「设置与登录」完成学信网登录。 +

+ +
+
+
+
+

任务记录

+ +
+ {jobs.length ? ( + jobs.map((j) => ( + + )) + ) : ( +
+ 还没有任务。填写左侧条件开始采集。 +
+ )} +
+
+
+

运行日志

+ {job && ( +
+ {activeStates.includes(job.status) && ( + + )} + {resumeStates.includes(job.status) && ( + + )} + {!["completed", "cancelled"].includes(job.status) && ( + + )} +
+ )} +
+ {job ? ( + <> +
+ + 状态 {statusName(job.status)} + + + 完成单元 {job.completed_units} + + + 保存记录 {job.records} + + + 失败单元 {job.errors} + +
+
{job.message}
+
+ {logs.map((l) => ( +
+ + {l.message} +
+ ))} + {!logs.length && 暂无日志} +
+ + ) : ( +
选择一个任务查看进度和日志。
+ )} +
+
+
+ + ); } function ProxyPanel({ notify }: { notify: Notify }) { - const [data, setData] = useState(null), [busy, setBusy] = useState(false), [output, setOutput] = useState(''); - const load = useCallback(async () => setData(await api('/proxy?refresh=true')), []); - useEffect(() => { load().catch(e => notify(e.message, true)); }, [load, notify]); - async function operate(action: string) { setBusy(true); try { if (action === 'rotate') { setData(await post('/proxy/rotate')); notify('已切换当前路由'); } else if (action === 'refresh') await load(); else { const result = await post<{ output: string; ok: boolean }>('/proxy/manage', { action }); setOutput(result.output); notify(result.ok ? '代理池操作完成' : '代理池返回异常,请查看输出', !result.ok); await load(); } } catch (e) { notify((e as Error).message, true); } finally { setBusy(false); } } - return <>
} sub="以代理池 API 返回为准" />} sub="用于两个 HTTPS 数据源" />} sub="连接失败会切换其他候选" />} sub="保留池记录,修改配置可重置" />
当前网络路由 · {data ? modeName(data.mode) : '加载中'}

{data?.route === 'direct' ? '直接连接' : data?.route === 'pending' ? '等待可用代理' : data?.route || '正在读取代理池…'}

{data?.fallback ? '代理池暂无可用 IP,优先代理模式已回退直连。' : '登录、招生目录和历年考情共用该路由。'}

{data?.fallback ? '直连回退' : data?.active_proxy ? '代理已选择' : '当前策略'}
{data?.error &&
{data.error}
}

可用代理列表

{data?.proxies.length || 0} 个候选
{data?.proxies.length ? data.proxies.map(p =>
{p.url}{p.failed ? '已隔离' : p.active ? '当前 IP' : '池内可选'}
) :
没有 HTTPS 候选。可启动代理池抓取服务,或在设置中添加备用 IP。
}

本机代理池服务

通过现有项目的 manage.ps1 控制 Redis、API 与抓取调度器。

{busy &&

正在处理…

}{output &&
{output}
}
切换 IP 保留原代理;连接失败仅在本次工作台运行中隔离。代理池的持续可用性由其检测服务维护。
; + const [data, setData] = useState(null), + [busy, setBusy] = useState(false), + [output, setOutput] = useState(""); + const load = useCallback( + async () => setData(await api("/proxy?refresh=true")), + [], + ); + useEffect(() => { + load().catch((e) => notify(e.message, true)); + }, [load, notify]); + async function operate(action: string) { + setBusy(true); + try { + if (action === "rotate") { + setData(await post("/proxy/rotate")); + notify("已切换当前路由"); + } else if (action === "refresh") await load(); + else { + const result = await post<{ output: string; ok: boolean }>( + "/proxy/manage", + { action }, + ); + setOutput(result.output); + notify( + result.ok ? "代理池操作完成" : "代理池返回异常,请查看输出", + !result.ok, + ); + await load(); + } + } catch (e) { + notify((e as Error).message, true); + } finally { + setBusy(false); + } + } + return ( + <> + + + + +
+ } + sub="以代理池 API 返回为准" + /> + } + sub="用于两个 HTTPS 数据源" + /> + } + sub="连接失败会切换其他候选" + /> + } + sub="保留池记录,修改配置可重置" + /> +
+
+
+ +
+ + 当前网络路由 · {data ? modeName(data.mode) : "加载中"} + +

+ {data?.route === "direct" + ? "直接连接" + : data?.route === "pending" + ? "等待可用代理" + : data?.route || "正在读取代理池…"} +

+

+ {data?.fallback + ? "代理池暂无可用 IP,优先代理模式已回退直连。" + : "登录、招生目录和历年考情共用该路由。"} +

+
+
+ + {data?.fallback + ? "直连回退" + : data?.active_proxy + ? "代理已选择" + : "当前策略"} + +
+ {data?.error &&
{data.error}
} +
+
+
+

可用代理列表

+ {data?.proxies.length || 0} 个候选 +
+
+ {data?.proxies.length ? ( + data.proxies.map((p) => ( +
+ {p.url} + + {p.failed ? "已隔离" : p.active ? "当前 IP" : "池内可选"} + +
+ )) + ) : ( +
+ 没有 HTTPS 候选。可启动代理池抓取服务,或在设置中添加备用 IP。 +
+ )} +
+
+
+

本机代理池服务

+

通过现有项目的 manage.ps1 控制 Redis、API 与抓取调度器。

+
+ + + +
+ {busy && ( +

+ + 正在处理… +

+ )} + {output &&
{output}
} +
+ 切换 IP + 保留原代理;连接失败仅在本次工作台运行中隔离。代理池的持续可用性由其检测服务维护。 +
+
+
+ + ); } function SettingsPanel({ notify }: { notify: Notify }) { - const [config, setConfig] = useState(null), [auth, setAuth] = useState(null), [backup, setBackup] = useState(''), [cookie, setCookie] = useState(''), [username, setUsername] = useState(''), [password, setPassword] = useState(''), [busy, setBusy] = useState(''); - useEffect(() => { Promise.all([api('/settings'), api('/auth')]).then(([c, a]) => { setConfig(c); setBackup(c.backup_proxies.join('\n')); setAuth(a); }).catch(e => notify(e.message, true)); }, [notify]); - const browserWaiting = auth && ['opening', 'waiting'].includes(auth.browser_state); - useEffect(() => { if (!browserWaiting) return; const timer = setInterval(() => api('/auth').then(setAuth).catch(() => {}), 2000); return () => clearInterval(timer); }, [browserWaiting]); - async function save(e: React.FormEvent) { e.preventDefault(); setBusy('save'); try { setConfig(await api('/settings', { method: 'PUT', body: JSON.stringify({ ...config, backup_proxies: backup.split('\n').filter(Boolean) }) })); notify('网络设置已保存'); } catch (e) { notify((e as Error).message, true); } finally { setBusy(''); } } - async function authenticate(action: string) { setBusy(action); try { const result = await post('/auth/' + action, action === 'cookie' ? { cookie } : action === 'login' ? { username, password } : {}); setAuth(result); notify(action === 'browser' ? result.browser_message : result.message, action === 'check' && !result.valid); } catch (e) { notify((e as Error).message, true); } finally { setBusy(''); if (action === 'cookie') setCookie(''); if (action === 'login') setPassword(''); } } - function update(key: keyof Config, value: string | number) { setConfig(c => c ? { ...c, [key]: value } : c); } - return <>

网络与代理设置

{config ?