Files
web/src/app/admin/layout.tsx

37 lines
927 B
TypeScript
Raw Normal View History

import {ReactNode} from 'react'
import Header from './_client/header'
import Navbar from './_client/navbar'
import Layout from './_client/layout'
2025-06-18 17:57:12 +08:00
import {getProfile} from '@/actions/auth'
import {redirect} from 'next/navigation'
import {PasswordSetupWrapper} from './_client/passwordSetupWrapper'
export type AdminLayoutProps = {
children: ReactNode
}
export default async function AdminLayout(props: AdminLayoutProps) {
2025-06-18 17:57:12 +08:00
const resp = await getProfile()
const profile = resp.success ? resp.data : null
2025-06-18 17:57:12 +08:00
if (!profile) {
redirect('/login')
}
return (
<Layout
navbar={<Navbar/>}
2025-06-18 17:57:12 +08:00
header={<Header profile={profile}/>}
content={(
<>
{props.children}
{/* 需要时显示密码设置和实名认证 */}
{(!profile?.has_password && !profile?.id_token) && (
<PasswordSetupWrapper profile={profile}/>
)}
</>
)}
/>
)
}