gongxiangp2/app/layout.tsx
2026-09-01 17:03:41 +08:00

78 lines
3.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import type { Metadata, Viewport } from 'next'
import './globals.css'
import Providers from './providers'
import { prisma } from '@/lib/prisma'
export const viewport: Viewport = {
width: 'device-width',
initialScale: 1,
viewportFit: 'cover',
}
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素材分享平台',
icons: {
icon: '/api/favicon',
shortcut: '/api/favicon',
apple: '/api/favicon',
},
}
}
export default function RootLayout({
children,
}: {
children: React.ReactNode
}) {
return (
<html lang="zh-CN">
<head>
{/* 禁用浏览器缓存,确保用户总是获取最新代码 */}
<meta httpEquiv="Cache-Control" content="no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0" />
<meta httpEquiv="Pragma" content="no-cache" />
<meta httpEquiv="Expires" content="0" />
{/* 允许 blob URL 在 HTTP 页面上使用(解决 HTTPS 警告) */}
{/* 注意:frame-ancestors 只能通过 HTTP 响应头设置,不能通过 meta 标签 */}
<meta httpEquiv="Content-Security-Policy" content="default-src 'self' 'unsafe-inline' 'unsafe-eval' blob: data: http: https: ws: wss:; img-src 'self' 'unsafe-inline' blob: data: http: https:; script-src 'self' 'unsafe-inline' 'unsafe-eval' blob: https://g.alicdn.com; style-src 'self' 'unsafe-inline'; connect-src 'self' blob: data: http: https: ws: wss:; media-src 'self' blob: data: http: https:; font-src 'self' data: http: https:; object-src 'none'; base-uri 'self'; form-action 'self';" />
</head>
<body className="font-sans antialiased">
<template
data-design-contract="BRAND-CENTER-DARK-RAIL-OPS-V4"
dangerouslySetInnerHTML={{
__html: `<!--
THESIS: 品牌中心是一套固定导航、快速切换与逐层下钻的部门数据工作台,不是漂浮卡片式门户。
OWN-WORLD: 深海军蓝部门导航轨、白色操作顶栏、冷灰数据画布、矩形白色工作面板与高识别蓝色选中态组成同一套运营界面。
STORY: 用户从左侧五个职责域直接切换二级页面,在主画布中查看框架、真实指标或既有素材业务。
FIRST VIEWPORT: 272px 部门导航与 72px 操作顶栏建立稳定坐标,页面标题和第一块核心工作面板无需经过门户式英雄卡即可看到。
FORM: Operate 模式的固定侧栏数据工作台;用户参考图精确塑形;seed key BRAND-CENTER-DARK-RAIL-OPS-V4。
FINISH: unreviewed and undocumented is unfinished; this build ends with the finish review, the verdict, and DESIGN.md
-->`,
}}
/>
<Providers>
{children}
</Providers>
</body>
</html>
)
}