diff --git a/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx b/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx index 5012549..6b4ad03 100644 --- a/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx +++ b/src/app/settings/_libs/components/sync-localstorage-with-cookie.tsx @@ -14,17 +14,17 @@ export function SyncLocalStorageWithCookie({ withRedirect = false, }: SyncLocalStorageWithCookieProps) { const [selectedSchool] = useAtom(selectedSchoolAtom); - + const { host } = selectedSchool || {}; useEffect(() => { - if (selectedSchool) { - Cookies.set('selectedSchool', selectedSchool.host); + if (host) { + Cookies.set('selectedSchool', host); if (withRedirect) { redirect('/'); } } else { Cookies.remove('selectedSchool'); } - }, [selectedSchool, withRedirect]); + }, [host, withRedirect]); return <>; } diff --git a/src/app/settings/_libs/ui/settings-ui.tsx b/src/app/settings/_libs/ui/settings-ui.tsx index c6641f4..d25361b 100644 --- a/src/app/settings/_libs/ui/settings-ui.tsx +++ b/src/app/settings/_libs/ui/settings-ui.tsx @@ -3,6 +3,7 @@ import SchoolCustomization from '@/app/settings/_libs/components/school-customiz import SchoolAction from '@/app/settings/_libs/components/school-action'; import { SettingsConfig } from '@/app/_libs/types'; import JumpToFullscreen from '@/app/settings/_libs/components/jump-to-fullscreen'; +import { SyncLocalStorageWithCookie } from '@/app/settings/_libs/components/sync-localstorage-with-cookie'; export default async function SettingsUI({ mode = 'settings', @@ -10,6 +11,7 @@ export default async function SettingsUI({ }: SettingsConfig) { return (
+ {type === 'modal' && } diff --git a/src/app/settings/setup/page.tsx b/src/app/settings/setup/page.tsx index 8a4bb36..619c8af 100644 --- a/src/app/settings/setup/page.tsx +++ b/src/app/settings/setup/page.tsx @@ -1,7 +1,6 @@ import type { Metadata } from 'next'; import Title from '@/app/_libs/components/title'; import SettingsUI from '../_libs/ui/settings-ui'; -import { SyncLocalStorageWithCookie } from '@/app/settings/_libs/components/sync-localstorage-with-cookie'; export const metadata: Metadata = { title: '选择学校', @@ -10,7 +9,6 @@ export const metadata: Metadata = { export default async function Page() { return (
-