diff --git a/projects/fastgpt/app/[[...lang]]/page.tsx b/projects/fastgpt/app/[[...lang]]/page.tsx index 163cd40..7d27fe9 100644 --- a/projects/fastgpt/app/[[...lang]]/page.tsx +++ b/projects/fastgpt/app/[[...lang]]/page.tsx @@ -1,31 +1,34 @@ -import Header from "@/components/header/Header"; -import Ability from "@/components/home/Ability"; -import CTA from "@/components/home/CTA"; -import FAQ from "@/components/home/FAQ"; -import Feature from "@/components/home/Feature"; -import Hero from "@/components/home/Hero"; -import Pricing from "@/components/home/Pricing"; -import SocialProof from "@/components/home/SocialProof"; -import VideoPlayer from "@/components/home/Video"; -import { defaultLocale, getDictionary, localeNames } from "@/lib/i18n"; - -export default async function LangHome({ - params: { lang }, -}: { - params: { lang?: string[] }; -}) { - let langName = - lang && lang[0] && lang[0] !== "index" ? lang[0] : defaultLocale; +import Header from '@/components/header/Header'; +import Ability from '@/components/home/Ability'; +import CTA from '@/components/home/CTA'; +import FAQ from '@/components/home/FAQ'; +import Feature from '@/components/home/Feature'; +import Hero from '@/components/home/Hero'; +import Pricing from '@/components/home/Pricing'; +import SocialProof from '@/components/home/SocialProof'; +import VideoPlayer from '@/components/home/Video'; +import { defaultLocale, getDictionary, localeNames } from '@/lib/i18n'; + +export default async function LangHome({ params: { lang } }: { params: { lang?: string[] } }) { + let langName = lang && lang[0] && lang[0] !== 'index' ? lang[0] : defaultLocale; const dict = await getDictionary(langName); - + let stars = 13 * 1000; + try { + const { stargazers_count } = await ( + await fetch('https://api.github.com/repos/labring/FastGPT') + ).json(); + if (stargazers_count) { + stars = stargazers_count; + } + } catch (error) {} return ( <>
{/* Hero Section */} - + {/* Can be used to display technology stack, partners, project honors, etc. */} {/**/} @@ -43,7 +46,7 @@ export default async function LangHome({ {/* CTA (Call to Action) */} - +
); @@ -51,6 +54,5 @@ export default async function LangHome({ export async function generateStaticParams() { const keys = Object.keys(localeNames).map((lang) => ({ lang: [lang] })); - return [{ lang: [""] }, ...keys]; + return [{ lang: [''] }, ...keys]; } - diff --git a/projects/fastgpt/components/home/CTA.tsx b/projects/fastgpt/components/home/CTA.tsx index 11e68eb..72bb921 100644 --- a/projects/fastgpt/components/home/CTA.tsx +++ b/projects/fastgpt/components/home/CTA.tsx @@ -1,8 +1,8 @@ /* eslint-disable react/no-unescaped-entities */ -import CTAButton from "@/components/home/CTAButton"; -import { RoughNotation } from "react-rough-notation"; +import CTAButton from '@/components/home/CTAButton'; +import { RoughNotation } from 'react-rough-notation'; -const CTA = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => { +const CTA = ({ locale, CTALocale, stars }: { locale: any; CTALocale: any; stars: number }) => { return (
@@ -10,19 +10,19 @@ const CTA = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => {

{locale.description1} - {" "} - {locale.description2}{" "} + + {locale.description2} {locale.description3} - {" "} - {locale.description4}{" "} + + {locale.description4} {locale.description5} {locale.description6}

- +
); }; diff --git a/projects/fastgpt/components/home/CTAButton.tsx b/projects/fastgpt/components/home/CTAButton.tsx index 4aee68b..ebf4cea 100644 --- a/projects/fastgpt/components/home/CTAButton.tsx +++ b/projects/fastgpt/components/home/CTAButton.tsx @@ -4,20 +4,22 @@ import { RocketIcon } from 'lucide-react'; import Link from 'next/link'; import { useEffect, useState } from 'react'; -const CTAButton = ({ locale }: { locale: any }) => { - const [stars, setStars] = useState(13 * 1000); +const CTAButton = ({ locale, stars: initialStars }: { locale: any; stars: number }) => { + const [stars, setStars] = useState(initialStars); useEffect(() => { const getStars = async () => { try { const { stargazers_count } = await ( - await fetch('https://api.github.com/repos/labring/FastGPT', { cache: 'force-cache' }) + await fetch('https://api.github.com/repos/labring/FastGPT') ).json(); - setStars(stargazers_count ? stargazers_count : 13 * 1000); + if (stargazers_count && stargazers_count !== initialStars) { + setStars(stargazers_count); + } } catch (error) {} }; getStars(); - }, []); + }, [initialStars]); return (
diff --git a/projects/fastgpt/components/home/Hero.tsx b/projects/fastgpt/components/home/Hero.tsx index e303097..6cd1355 100644 --- a/projects/fastgpt/components/home/Hero.tsx +++ b/projects/fastgpt/components/home/Hero.tsx @@ -1,10 +1,9 @@ -"use client"; -import { LineText } from "@/components/LineText"; -import CTAButton from "@/components/home/CTAButton"; -import { motion } from "framer-motion"; - -const Hero = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => { +'use client'; +import { LineText } from '@/components/LineText'; +import CTAButton from '@/components/home/CTAButton'; +import { motion } from 'framer-motion'; +const Hero = ({ locale, CTALocale, stars }: { locale: any; CTALocale: any; stars: number }) => { return ( <> { duration: 0.3, ease: [0, 0.71, 0.2, 1], scale: { - type: "tween", // tween spring + type: 'tween' // tween spring // damping: 10, // if spring // stiffness: 50, // if spring // restDelta: 0.001, // if spring - }, + } }} >
@@ -31,7 +30,7 @@ const Hero = ({ locale, CTALocale }: { locale: any; CTALocale: any; }) => {

- + ); };