@@ -2548,6 +2548,21 @@ async def _generate_html_content(
25482548 --venue-icon-bg: { cfg .get ("theme_primary" , "#0A4D68" )} ;
25492549 }}"""
25502550
2551+ baidu_tongji_id = os .getenv ("BAIDU_TONGJI_ID" , "" )
2552+ analytics_script = ""
2553+ if baidu_tongji_id :
2554+ analytics_script = (
2555+ "\n <script>"
2556+ "\n var _hmt = _hmt || [];"
2557+ "\n (function() {"
2558+ '\n var hm = document.createElement("script");'
2559+ f'\n hm.src = "https://hm.baidu.com/hm.js?{ baidu_tongji_id } ";'
2560+ '\n var s = document.getElementsByTagName("script")[0];'
2561+ "\n s.parentNode.insertBefore(hm, s);"
2562+ "\n })();"
2563+ "\n </script>"
2564+ )
2565+
25512566 html_content = f"""<!DOCTYPE html>
25522567<html lang="zh-CN">
25532568<head>
@@ -2576,7 +2591,7 @@ async def _generate_html_content(
25762591 <!-- Modern UI Components -->
25772592 <link rel="stylesheet" href="/public/css/components.css">
25782593
2579- { schema_script }
2594+ { schema_script } { analytics_script }
25802595 <style>
25812596 { dynamic_style } /* Inject dynamic theme colors here */
25822597
@@ -2991,6 +3006,13 @@ async def _generate_html_content(
29913006 </style>
29923007</head>
29933008<body>
3009+ <nav style="background:#001524;padding:10px 20px;display:flex;justify-content:space-between;align-items:center;position:sticky;top:0;z-index:1000;">
3010+ <a href="/" style="color:white;text-decoration:none;font-family:'Outfit',sans-serif;font-weight:700;font-size:1.1rem;">MeetSpot</a>
3011+ <div style="display:flex;gap:16px;align-items:center;">
3012+ <a href="/public/meetspot_finder.html" style="color:#06D6A0;text-decoration:none;font-size:0.9rem;">重新搜索</a>
3013+ <button onclick="navigator.clipboard.writeText(location.href).then(function(){{this.textContent='已复制!'}}.bind(this))" data-track="result_share" data-track-label="copy_link" style="background:#FF6B35;color:white;border:none;padding:6px 14px;border-radius:8px;cursor:pointer;font-size:0.85rem;">复制链接</button>
3014+ </div>
3015+ </nav>
29943016 <header>
29953017 <div class="container">
29963018 <div class="header-logo">
@@ -3184,6 +3206,20 @@ async def _generate_html_content(
31843206
31853207 <!-- Modern Toast Notification System -->
31863208 <script src="/public/js/toast.js"></script>
3209+
3210+ <script>
3211+ if (typeof _hmt !== "undefined") {{
3212+ _hmt.push(["_trackEvent", "meetspot", "result_page_view",
3213+ "{ primary_keyword } ", { len (places )} ]);
3214+ }}
3215+ document.addEventListener("click", function(e) {{
3216+ var el = e.target.closest("[data-track]");
3217+ if (el && typeof _hmt !== "undefined") {{
3218+ _hmt.push(["_trackEvent", "meetspot", el.dataset.track,
3219+ el.dataset.trackLabel || ""]);
3220+ }}
3221+ }});
3222+ </script>
31873223</body>
31883224</html>"""
31893225 return html_content
0 commit comments