feat: CDP 接管开关 + 扫码登录面板 + Docker 部署
- runner: enable_cdp_mode 从硬编码 False 改为系统设置 cdp_enabled。服务器部署下爬虫接管已开启远程调试的 Chrome(默认 9222),复用其 profile 登录态;本机桌面默认仍为关,行为不变 - qrlogin: 新增 CDP 扫码登录。Chrome 在服务器上跑于 Xvfb,show_qrcode 依赖的 PIL 桌面看图程序不存在,二维码无处可显示;改为经 CDP 从页面取出二维码交给 WebUI 渲染。刻意复用 browser.contexts[0](新建 context 是无痕 profile,扫了也白扫),且绝不调用 browser.close()(会连带关掉操作者自己的 Chrome) - webui: 设置页新增扫码面板,替换原本跳到采集页看终端二维码的入口 - Dockerfile / .dockerignore / docker-compose.yml: 服务器部署。host 网络是必需而非图省事——容器里 127.0.0.1:9222 必须落到宿主机回环 - UPSTREAM.md: 补充 gitcode 镜像,用于 GitHub 大包传输必断时补历史
This commit is contained in:
+23
-2
@@ -25,9 +25,14 @@ webui/src/components/{monitor,settings,auth}/ 新视图
|
||||
webui/src/components/layout/{PlatformSwitcher,UnwiredPlatformNotice}.tsx
|
||||
webui/src/{hooks/useMonitor.ts,hooks/usePlatform.ts,store/platformStore.ts,lib/monitorFormat.ts,types/monitor.ts}
|
||||
docs/监控功能使用说明.md
|
||||
tests/test_{auth,settings,platforms,monitor_*}.py
|
||||
tests/test_{auth,settings,platforms,qrlogin,monitor_*}.py
|
||||
Dockerfile / .dockerignore / docker-compose.yml 服务器部署用
|
||||
```
|
||||
|
||||
其中 `api/monitor/qrlogin.py` + `webui/.../QrLoginPanel.tsx` 是**服务器专用**的扫码登录:
|
||||
那台机器上 Chrome 跑在 Xvfb 里,`show_qrcode` 调的 PIL `Image.show()` 需要桌面看图程序,
|
||||
服务器没有,二维码会无处可去。所以改成用 CDP 把二维码从页面里读出来交给前端 `<img>` 显示。
|
||||
|
||||
### 2. 加法改动(低冲突)
|
||||
|
||||
只在既有文件里**新增**内容,不改动原有行:
|
||||
@@ -90,9 +95,25 @@ tests/test_{auth,settings,platforms,monitor_*}.py
|
||||
git stash # 或先 commit 到自己的分支(推荐)
|
||||
git fetch origin main
|
||||
git rebase origin/main # 冲突只会出现在上表第 3、4 类文件里
|
||||
./.venv/Scripts/python.exe -m pytest tests/ -q # 486 个测试就是回归网
|
||||
./.venv/Scripts/python.exe -m pytest tests/ -q # 502 个测试就是回归网
|
||||
```
|
||||
|
||||
### 直连 GitHub 不通时(本机常见)
|
||||
|
||||
本机到 `github.com` 时通时不通,**大包传输必断**(`Recv failure: Connection was reset`
|
||||
或 `unexpected disconnect while reading sideband packet`),所以 `git clone` / `--unshallow`
|
||||
这类一次性拉全量的操作基本必失败。可用的替代源:
|
||||
|
||||
```bash
|
||||
# gitcode 的 GitHub 镜像,国内直连,比 GitHub 本身还新一天以内
|
||||
git remote add gitcode https://gitcode.com/gh_mirrors/me/MediaCrawler.git
|
||||
git fetch --no-tags --unshallow gitcode # 本仓库当初就是这样补全历史的,约 2 秒
|
||||
```
|
||||
|
||||
注意 `git fetch` 只写 `refs/remotes/*`,**不会动本地 `main`**;
|
||||
但拉镜像会把 `upstream/main` 指到镜像的 tip(可能比 GitHub 晚一天),
|
||||
等 GitHub 通了再 `git fetch upstream` 正回来即可。
|
||||
|
||||
### 强烈建议:先把改动提交掉
|
||||
|
||||
当前状态是**未提交**的(25 个上游文件被改 + 31 个新文件)。在 `main` 分支上裸着工作区,
|
||||
|
||||
Reference in New Issue
Block a user