This commit is contained in:
hzm
2026-02-21 12:54:14 +08:00
parent f691435f22
commit 22f05061ab
9 changed files with 21 additions and 13 deletions

View File

@@ -1,17 +1,9 @@
'use client';
import { useEffect, useState } from 'react';
import Script from 'next/script';
export default function AnalyticsGate({ GA_ID }) {
const [enabled, setEnabled] = useState(false);
useEffect(() => {
try {
const href = window.location.href || '';
setEnabled(href.includes('hzm0321'));
} catch {}
}, []);
if (!enabled) return null;
if (!GA_ID) return null;
return (
<>

View File

@@ -8,7 +8,7 @@ export const metadata = {
};
export default function RootLayout({ children }) {
const GA_ID = 'G-PD2JWJHVEM'; // 请在此处替换您的 Google Analytics ID
const GA_ID = process.env.NEXT_PUBLIC_GA_ID;
return (
<html lang="zh-CN">