mirror of
https://gitee.com/xmz7891/ykxmz.git
synced 2026-10-18 20:40:43 +00:00
阶段1 网络加速 - 发现隧道在跑 QUIC(ExecStart 丢了 --protocol http2), 实测 QUIC 可用率 48% vs HTTP/2 80%+,是重大性能回退。 恢复后公网延迟从 4141ms 降到 690ms(快 6 倍),可用率 92%。 - 优选 IP 结论:无效。hosts 覆盖确实生效了(日志里连的就是指定 IP), 但落点仍是 lax —— 运营商把所有 Cloudflare anycast 都路由到美西。 已清掉这段无效配置。 - BBR 不可用:设备是自定义内核 6.4.0-rc4-jsbsbxjxh66, 没编 tcp_bbr 模块也没配置项。改用 cubic + 调优: TCP 缓冲 4MB、tcp_fastopen=3、tcp_slow_start_after_idle=0 (长轮询场景关键)、tcp_tw_reuse=1。 阶段2 官网重做 - 拆出独立模块 relay/landing.py(relay.py 已两千多行, 再塞 HTML 没法看) - 信息结构参考成熟产品站:吸顶导航 / Hero / 九宫格功能 / 三步上手 / 下载 / FAQ / 页脚 - 保持白色简洁:底白、浅灰面板、细边框、大量留白 - logo 用内联 SVG(ICO 放 img 里实测是破图) - 管理入口从官网移除(管理不对外开放) 过程中被自己的测试抓到两个 bug: - 模块叫 site.py 会和 Python 标准库重名,import site 拿到的是标准库 - _logo() 里把 % 格式化和字符串拼接混用,直接抛 TypeError
120 lines
3.9 KiB
Python
120 lines
3.9 KiB
Python
# -*- coding: utf-8 -*-
|
||
r'''本地渲染官网,检查内容完整性 + 生成预览文件。
|
||
|
||
用法:python _build/test_site_render.py
|
||
'''
|
||
from __future__ import annotations
|
||
|
||
import re
|
||
import sys
|
||
from pathlib import Path
|
||
|
||
ROOT = Path(__file__).resolve().parent.parent
|
||
sys.path.insert(0, str(ROOT / "relay"))
|
||
|
||
import landing # noqa: E402
|
||
|
||
# 模拟 _list_downloads() 的返回
|
||
FILES = [
|
||
{"name": "ykxmz-setup-1.7.1.exe", "size": 15063814, "mtime": 1},
|
||
{"name": "ykxmz-server-1.7.1.zip", "size": 194633, "mtime": 1},
|
||
{"name": "ykxmz-watch-1.7.1.apk", "size": 201523, "mtime": 1},
|
||
{"name": "ykxmz-watch-1.7.1-说明.txt", "size": 1875, "mtime": 1},
|
||
]
|
||
|
||
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))
|
||
|
||
|
||
def main() -> int:
|
||
html = landing.render_site(FILES)
|
||
print(" 渲染 %d 字符" % len(html))
|
||
print()
|
||
|
||
print("一、结构完整")
|
||
for label, needle in (
|
||
("DOCTYPE", "<!DOCTYPE html>"),
|
||
("语言 zh-CN", 'lang="zh-CN"'),
|
||
("吸顶导航", "nav-in"),
|
||
("Hero 标题", "老师抬一下手腕"),
|
||
("功能网格", 'id="features"'),
|
||
("三步上手", 'id="how"'),
|
||
("下载区", 'id="download"'),
|
||
("FAQ", 'id="faq"'),
|
||
("页脚", "foot-in"),
|
||
("响应式 viewport", "width=device-width")):
|
||
check(label, needle in html)
|
||
|
||
print()
|
||
print("二、内容数量")
|
||
feats = len(re.findall(r'class="feat"', html))
|
||
steps = len(re.findall(r'class="step"', html))
|
||
dls = len(re.findall(r'class="dl-card"', html))
|
||
faqs = len(re.findall(r'<details class="faq"', html))
|
||
check("9 张功能卡", feats == 9, "实际 %d" % feats)
|
||
check("3 个步骤卡", steps == 3, "实际 %d" % steps)
|
||
check("3 个下载卡", dls == 3, "实际 %d" % dls)
|
||
check("6 条 FAQ", faqs == 6, "实际 %d" % faqs)
|
||
|
||
print()
|
||
print("三、logo 与图标")
|
||
check("导航 logo 是内联 SVG(不是破图 img)",
|
||
'class="brand"' in html and "src=\"/favicon.ico\" alt=\"\"" not in html)
|
||
check("图标数量足够(9 功能 + 2 logo;步骤卡用数字不用图标)",
|
||
html.count("<svg") >= 11, "实际 %d" % html.count("<svg"))
|
||
check("favicon 的 link 还在", 'rel="icon"' in html)
|
||
|
||
print()
|
||
print("四、下载链接")
|
||
for name in ("ykxmz-setup-1.7.1.exe", "ykxmz-server-1.7.1.zip",
|
||
"ykxmz-watch-1.7.1.apk"):
|
||
check("链接 " + name, ("/download/" + name) in html)
|
||
check("没把说明 txt 当下载卡",
|
||
"说明.txt" not in html or "dl-card" in html)
|
||
|
||
print()
|
||
print("五、白色简洁配色")
|
||
colors = sorted(set(re.findall(r"#[0-9a-fA-F]{6}", html)))
|
||
check("底色是白", "#ffffff" in colors)
|
||
check("有浅灰面板", "#fafbfc" in colors)
|
||
# 深色只允许正文色和主色
|
||
allow = {"#1a1d21", "#2563eb", "#1d4ed8", "#6b7280", "#9ca3af",
|
||
"#e6e8eb", "#eff6ff", "#d1d5db", "#f3f4f6", "#ffffff", "#fafbfc"}
|
||
weird = [c for c in colors if c not in allow]
|
||
check("没有意外的颜色", not weird, weird)
|
||
print(" 颜色: %s" % " ".join(colors))
|
||
|
||
print()
|
||
print("六、版本号")
|
||
check("显示最新版号", "1.7.1" in html)
|
||
|
||
print()
|
||
print("七、不能有管理入口")
|
||
check("官网里没有管理入口", "管理入口" not in html)
|
||
check("官网里没有管理页路径", "zhongzhuanzhan" not in html)
|
||
|
||
# 写预览
|
||
out = ROOT / "_build" / "site_preview.html"
|
||
out.write_text(html, encoding="utf-8")
|
||
print()
|
||
print(" 预览 -> %s" % out.name)
|
||
|
||
print()
|
||
print("=" * 58)
|
||
print("通过 %d 项,失败 %d 项" % (passed, failed))
|
||
return 0 if failed == 0 else 1
|
||
|
||
|
||
if __name__ == "__main__":
|
||
sys.exit(main())
|