From dadab9f724c1d2561e9f699dd5ef26d548b9cf86 Mon Sep 17 00:00:00 2001 From: heheer <1239331448@qq.com> Date: Tue, 12 Nov 2024 15:14:50 +0800 Subject: [PATCH] add baidu keywords --- projects/fastgpt/app/BdVidHandler.tsx | 12 --------- projects/fastgpt/app/layout.tsx | 2 -- .../fastgpt/components/home/CTAButton.tsx | 26 ++++++++++++++----- 3 files changed, 20 insertions(+), 20 deletions(-) delete mode 100644 projects/fastgpt/app/BdVidHandler.tsx diff --git a/projects/fastgpt/app/BdVidHandler.tsx b/projects/fastgpt/app/BdVidHandler.tsx deleted file mode 100644 index fc5e914..0000000 --- a/projects/fastgpt/app/BdVidHandler.tsx +++ /dev/null @@ -1,12 +0,0 @@ -'use client'; - -export default function BdVidHandler() { - if (typeof window !== 'undefined') { - const urlParams = new URLSearchParams(window.location.search); - const bd_vid = urlParams.get('bd_vid'); - if (bd_vid) { - localStorage.setItem('bd_vid', bd_vid); - } - } - return null; -} \ No newline at end of file diff --git a/projects/fastgpt/app/layout.tsx b/projects/fastgpt/app/layout.tsx index 8f01536..eb6b707 100644 --- a/projects/fastgpt/app/layout.tsx +++ b/projects/fastgpt/app/layout.tsx @@ -12,7 +12,6 @@ import { Analytics } from '@vercel/analytics/react'; import { Viewport } from 'next'; import { Inter as FontSans } from 'next/font/google'; import Script from 'next/script'; -import BdVidHandler from './BdVidHandler'; const fontSans = FontSans({ subsets: ['latin'], @@ -84,7 +83,6 @@ export default async function RootLayout({ - ); diff --git a/projects/fastgpt/components/home/CTAButton.tsx b/projects/fastgpt/components/home/CTAButton.tsx index d8c566d..ab0a329 100644 --- a/projects/fastgpt/components/home/CTAButton.tsx +++ b/projects/fastgpt/components/home/CTAButton.tsx @@ -8,11 +8,6 @@ import { useEffect, useState } from 'react'; const CTAButton = ({ locale, stars: initialStars, showGithub = true }: { locale: any; stars: number, showGithub?: boolean }) => { const [stars, setStars] = useState(initialStars); - const [bd_vid, setBdVid] = useState(null); - - useEffect(() => { - setBdVid(typeof window !== 'undefined' ? localStorage.getItem('bd_vid') : null); - }, []); useEffect(() => { const getStars = async () => { @@ -28,6 +23,22 @@ const CTAButton = ({ locale, stars: initialStars, showGithub = true }: { locale: getStars(); }, [initialStars]); + const getLinkConfig = () => { + if (typeof window === 'undefined') return { pathname: siteConfig.userUrl }; + + const urlParams = new URLSearchParams(window.location.search); + const bd_vid = urlParams.get('bd_vid'); + const k = urlParams.get('k'); + + return { + pathname: siteConfig.userUrl, + query: { + ...(bd_vid && { bd_vid }), + ...(k && { k }) + } + }; + }; + return (
{ @@ -47,7 +58,10 @@ const CTAButton = ({ locale, stars: initialStars, showGithub = true }: { locale: ) } - +