Wrap auth pages in suspense (#327)

This commit is contained in:
shenlan 2025-09-30 21:04:13 +08:00 committed by GitHub
parent ea5b851768
commit 706de5c2fd
2 changed files with 22 additions and 2 deletions

View File

@ -1,14 +1,25 @@
export const dynamic = 'error'
import { Suspense } from 'react'
import { notFound } from 'next/navigation'
import { isFeatureEnabled } from '@lib/featureToggles'
import { LoginForm } from './LoginForm'
import LoginContent from './LoginContent'
function LoginPageFallback() {
return <div className="flex min-h-screen flex-col bg-gray-50" />
}
export default function LoginPage() {
if (!isFeatureEnabled('globalNavigation', '/login')) {
notFound()
}
// 统一返回:容器包裹表单,兼容两边改动
return <LoginContent><LoginForm /></LoginContent>
return (
<Suspense fallback={<LoginPageFallback />}>
<LoginContent>
<LoginForm />
</LoginContent>
</Suspense>
)
}

View File

@ -1,15 +1,24 @@
export const dynamic = 'error'
import { Suspense } from 'react'
import { notFound } from 'next/navigation'
import { isFeatureEnabled } from '@lib/featureToggles'
import RegisterContent from './RegisterContent'
function RegisterPageFallback() {
return <div className="flex min-h-screen flex-col bg-gray-50" />
}
export default function RegisterPage() {
if (!isFeatureEnabled('globalNavigation', '/register')) {
notFound()
}
return <RegisterContent />
return (
<Suspense fallback={<RegisterPageFallback />}>
<RegisterContent />
</Suspense>
)
}