"""多页对比(multi)的页面模板:手机页(390 宽)和电脑网页(1440 宽,带浏览器外框)。 每个模板吃一个 dict(场景数据),吐一整页 HTML。同一类页面至少两种长相(style 参数或不同模板)。 全部虚构:店名、App 名、公司名;域名 .example;地名可以是真的。只用系统字体,不引外部资源。 """ import html as _html FONT = '"PingFang SC", "Hiragino Sans GB", sans-serif' def esc(s): return _html.escape(str(s), quote=False) def hue(s): return sum(ord(c) * (i + 7) for i, c in enumerate(str(s))) % 360 BASE = """*{box-sizing:border-box;margin:0;padding:0} body{font-family:%s;color:#222;-webkit-font-smoothing:antialiased;font-size:14px;line-height:1.5} s{color:#999}.mu{color:#999}.sm{font-size:12px}b{font-weight:600} """ % FONT PHONE_CSS = """ body{width:390px;background:#f4f4f6} .sb{height:47px;display:flex;justify-content:space-between;align-items:center;padding:0 26px 0 34px;font-size:15px;font-weight:600} .sbr{display:flex;align-items:center;gap:6px;font-size:13px} .sig{display:inline-flex;gap:2px;align-items:flex-end;height:11px}.sig b{width:3px;background:currentColor;border-radius:1px;display:block} .sig b:nth-child(1){height:4px}.sig b:nth-child(2){height:6px}.sig b:nth-child(3){height:8px}.sig b:nth-child(4){height:11px} .bat{display:inline-block;width:25px;height:12px;border:1.5px solid currentColor;border-radius:3.5px;position:relative;opacity:.85} .bat em{position:absolute;left:1.5px;top:1.5px;bottom:1.5px;background:currentColor;border-radius:1px} .nav{height:44px;display:flex;align-items:center;justify-content:space-between;padding:0 14px;font-size:17px;font-weight:600} .nav .bk{font-size:26px;font-weight:300;width:56px;line-height:1}.nav .nr{width:56px;text-align:right;font-size:15px;font-weight:400} .card{background:#fff;margin:10px 12px;border-radius:12px;padding:14px 16px} .card h3{font-size:16px;margin-bottom:8px} .kv{display:flex;justify-content:space-between;gap:16px;padding:9px 0;border-bottom:1px solid #f0f0f0;font-size:14px} .kv:last-child{border-bottom:0}.kv .k{color:#888;flex:none}.kv .v{text-align:right} .home{height:34px;display:flex;justify-content:center;align-items:center}.home i{width:134px;height:5px;border-radius:3px;background:#111;display:block} .btm{position:sticky;bottom:0;background:#fff;border-top:1px solid #eee;display:flex;align-items:center;gap:10px;padding:8px 12px} .tagr{display:inline-block;border:1px solid currentColor;border-radius:3px;font-size:11px;padding:0 5px;line-height:17px;margin-right:5px} """ def statusbar(time, bg="#fff", fg="#111", bat=78): return ('
%s
%s
%s
%s%s
" % esc(x) for x in p["paras"]) tag = '%s' % (p["tag"][1], esc(p["tag"][0])) if p.get("tag") else "" cms = "".join('%s