49 lines
1.0 KiB
TypeScript
49 lines
1.0 KiB
TypeScript
import type { Metadata } from 'next'
|
|
import './globals.css'
|
|
import Providers from './providers'
|
|
import { prisma } from '@/lib/prisma'
|
|
|
|
// 强制动态渲染,避免构建时数据库连接错误
|
|
export const dynamic = 'force-dynamic'
|
|
|
|
async function getSystemSettings() {
|
|
try {
|
|
// 直接从数据库查询,避免网络请求超时问题
|
|
const settings = await prisma.systemSettings.findFirst({
|
|
select: {
|
|
siteName: true,
|
|
}
|
|
})
|
|
return settings
|
|
} catch (error) {
|
|
console.error('Failed to fetch system settings:', error)
|
|
}
|
|
return null
|
|
}
|
|
|
|
export async function generateMetadata(): Promise<Metadata> {
|
|
const settings = await getSystemSettings()
|
|
|
|
return {
|
|
title: settings?.siteName || '由壹点3D素材',
|
|
description: '3D素材分享平台',
|
|
}
|
|
}
|
|
|
|
export default function RootLayout({
|
|
children,
|
|
}: {
|
|
children: React.ReactNode
|
|
}) {
|
|
return (
|
|
<html lang="zh-CN">
|
|
<body className="font-sans antialiased">
|
|
<Providers>
|
|
{children}
|
|
</Providers>
|
|
</body>
|
|
</html>
|
|
)
|
|
}
|
|
|