Skip to content

Commit

Permalink
add domain detection
Browse files Browse the repository at this point in the history
  • Loading branch information
newfish-cmyk committed Oct 31, 2024
1 parent 7c1beb9 commit 9260533
Showing 1 changed file with 25 additions and 19 deletions.
44 changes: 25 additions & 19 deletions projects/fastgpt/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,30 +45,36 @@ export default async function RootLayout({
children: React.ReactNode;
params: { lang: string[] | undefined };
}) {
const isChineseDomain = process.env.NEXT_PUBLIC_USER_URL?.includes('.cn') || process.env.NEXT_PUBLIC_USER_URL?.includes('.run');

return (
<html lang={(lang && lang[0]) || defaultLocale} suppressHydrationWarning>
<head>
<Script
id="gtm-script"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W9HPZZ22');`
}}
/>
{!isChineseDomain && (
<Script
id="gtm-script"
strategy="afterInteractive"
dangerouslySetInnerHTML={{
__html: `(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-W9HPZZ22');`
}}
/>
)}
</head>
<body className={cn('min-h-screen font-sans antialiased', fontSans.variable)}>
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-W9HPZZ22"
height="0"
width="0"
style={{display: 'none', visibility: 'hidden'}}
></iframe>
</noscript>
{!isChineseDomain && (
<noscript>
<iframe
src="https://www.googletagmanager.com/ns.html?id=GTM-W9HPZZ22"
height="0"
width="0"
style={{display: 'none', visibility: 'hidden'}}
></iframe>
</noscript>
)}
<ThemeProvider attribute="class" defaultTheme={siteConfig.nextThemeColor} enableSystem>
{children}
{/* <Footer /> */}
Expand Down

0 comments on commit 9260533

Please sign in to comment.