From fd09d2fb153e59501f4b1d57e146147973bd1706 Mon Sep 17 00:00:00 2001 From: afred Date: Wed, 11 Dec 2024 12:25:47 +0800 Subject: [PATCH] change owner --- app/page.tsx | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index b3f169a9b..2b2318a7e 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -6,15 +6,30 @@ import { getServerSideConfig } from "./config/server"; const serverConfig = getServerSideConfig(); -export default async function App() { - return ( - <> - - {serverConfig?.isVercel && ( +export default function App() { + // 使用 useEffect 加载 Hotjar 脚本 + React.useEffect(() => { + if (serverConfig?.isVercel) { + (function (h, o, t, j, a, r) { + h.hj = + h.hj || + function () { + (h.hj.q = h.hj.q || []).push(arguments); + }; + h._hjSettings = { hjid: 3414362, hjsv: 6 }; + a = o.getElementsByTagName("head")[0]; + r = o.createElement("script"); + r.async = 1; + r.src = t + h._hjSettings.hjid + j + h._hjSettings.hjsv; + a.appendChild(r); + })(window, document, "https://static.hotjar.com/c/hotjar-", ".js?sv="); + } + }, []); // 空依赖数组,确保只在组件加载时运行一次 + + return ( <> - + + {serverConfig?.isVercel && } - )} - - ); + ); }