From ce0370fee121a8c1b45d838f43cac052b4453cdb Mon Sep 17 00:00:00 2001 From: hzm <934585316@qq.com> Date: Thu, 5 Feb 2026 12:20:18 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E8=B0=83=E6=95=B4google=20analysi?= =?UTF-8?q?s=E5=8A=A0=E8=BD=BD=E6=9D=A1=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/components/AnalyticsGate.jsx | 29 +++++++++++++++++++++++++++++ app/layout.jsx | 15 ++------------- 2 files changed, 31 insertions(+), 13 deletions(-) create mode 100644 app/components/AnalyticsGate.jsx diff --git a/app/components/AnalyticsGate.jsx b/app/components/AnalyticsGate.jsx new file mode 100644 index 0000000..10be6cf --- /dev/null +++ b/app/components/AnalyticsGate.jsx @@ -0,0 +1,29 @@ +'use client'; +import { useLayoutEffect, useState } from 'react'; +import Script from 'next/script'; + +export default function AnalyticsGate({ GA_ID }) { + const [enabled, setEnabled] = useState(false); + useLayoutEffect(() => { + try { + const href = window.location.href || ''; + setEnabled(href.includes('hzm0321')); + } catch {} + }, []); + + if (!enabled) return null; + + return ( + <> + + + ); +} diff --git a/app/layout.jsx b/app/layout.jsx index 5118050..954bf9d 100644 --- a/app/layout.jsx +++ b/app/layout.jsx @@ -1,5 +1,6 @@ import Script from 'next/script'; import './globals.css'; +import AnalyticsGate from './components/AnalyticsGate'; export const metadata = { title: '基估宝', @@ -13,21 +14,9 @@ export default function RootLayout({ children }) { - {/* Google Analytics */} - + {children}