From d42412848382fa205467f61ded3a214c82924cbf Mon Sep 17 00:00:00 2001 From: xmz7891 Date: Wed, 7 Oct 2026 20:53:58 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E7=BA=BF=E4=B8=8A=E5=AE=98=E7=BD=91?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E6=B5=8B=E8=AF=95=20+=20=E6=96=B0=E5=AE=98?= =?UTF-8?q?=E7=BD=91=E6=88=AA=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit _tests/test_landing_live.py 检查线上(本机 + 公网)官网确实是新版: * 有数据带 / 评价区 / 平台标签行 / 滚动淡入脚本 * HTML 里没有裸 reveal(没 JS 时内容可见) * **没有管理页字眼**(对外的清洁度规矩) 实测 14/14 通过。 --- _tests/test_landing_live.py | 84 +++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 _tests/test_landing_live.py diff --git a/_tests/test_landing_live.py b/_tests/test_landing_live.py new file mode 100644 index 0000000..c3fc1e9 --- /dev/null +++ b/_tests/test_landing_live.py @@ -0,0 +1,84 @@ +# -*- coding: utf-8 -*- +r'''验证线上官网已经是新版。''' +from __future__ import annotations + +import sys +import urllib.error +import urllib.request +from pathlib import Path + +sys.path.insert(0, str(Path(__file__).resolve().parent.parent / "_build")) +from devssh import run as ssh_run # noqa: E402 + +BASE = "https://relay.xxmxxs.top" +UA = {"User-Agent": "LanRemote/1.8.2"} + +passed = 0 +failed = 0 + + +def check(name, ok, detail=""): + global passed, failed + if ok: + passed += 1 + print(" [PASS] " + name) + else: + failed += 1 + print(" [FAIL] " + name + ((" —— " + str(detail)) if detail else "")) + + +def main() -> int: + print("=" * 56) + print(" 线上官网验证") + print("=" * 56) + + # 先用设备上的本机地址绕开 Cloudflare 缓存看个准的 + _c, local, _e = ssh_run( + "curl -s --max-time 15 -H 'User-Agent: LanRemote/1.8.2' " + "http://127.0.0.1:8080/", timeout=60, quiet=True) + + # 再看公网(可能有最多 60 秒缓存) + req = urllib.request.Request(BASE + "/", headers=UA) + try: + with urllib.request.urlopen(req, timeout=25) as resp: + pub = resp.read().decode("utf-8", "replace") + cc = resp.headers.get("cf-cache-status", "") + ok_pub = True + except Exception as exc: # noqa: BLE001 + pub = "" + cc = "" + ok_pub = False + print(" 公网拉取失败:%s" % exc) + + for label, html in (("本机", local or ""), ("公网", pub)): + if not html: + continue + print() + print(" ---- %s 版本 ----" % label) + check("%s:是新版" % label, "scroll-hint" in html, + "没有 scroll-hint,还是旧版") + check("%s:有数据带" % label, 'class="stats"' in html, "没有") + check("%s:有评价区" % label, 'class="quotes"' in html, "没有") + check("%s:有平台标签行" % label, 'class="plats"' in html, "没有") + check("%s:有滚动淡入脚本" % label, + "IntersectionObserver" in html, "没有") + check("%s:HTML 里没有裸 reveal(没 JS 也可见)" % label, + "reveal\"" not in html.split("