diff --git a/projects/fastgpt/components/header/LangSwitcher.tsx b/projects/fastgpt/components/header/LangSwitcher.tsx index 2317b24..b5abbeb 100644 --- a/projects/fastgpt/components/header/LangSwitcher.tsx +++ b/projects/fastgpt/components/header/LangSwitcher.tsx @@ -19,6 +19,7 @@ export const LangSwitcher = () => { const router = useRouter(); const handleSwitchLanguage = (value: string) => { + localStorage.setItem('preferredLang', value); if (value === defaultLocale) { router.push('/'); return; @@ -26,6 +27,13 @@ export const LangSwitcher = () => { router.push(value); }; + useEffect(() => { + const storedLang = localStorage.getItem('preferredLang'); + if (storedLang && storedLang !== lang) { + router.push(storedLang); + } + }, []); + return (