- 创建统一的下载错误处理模块 (lib/download-errors.ts) - 实现13种错误类型分类和中文错误消息 - 后端统一使用 createDownloadError 创建标准化错误响应 - 前端统一使用 parseDownloadError 解析错误并显示 - 修复正式系统数据库Schema,添加产品全案相关字段和表 - 执行数据库迁移:添加 task_no, task_status, task_fetched_at 字段 - 创建 material_assets, api_keys, api_call_logs 表
60 lines
2.0 KiB
TypeScript
60 lines
2.0 KiB
TypeScript
import type { Metadata } from 'next'
|
||
import './globals.css'
|
||
import Providers from './providers'
|
||
import { prisma } from '@/lib/prisma'
|
||
|
||
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: '/favicon.ico',
|
||
shortcut: '/favicon.ico',
|
||
apple: '/favicon.ico',
|
||
},
|
||
}
|
||
}
|
||
|
||
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:; 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">
|
||
<Providers>
|
||
{children}
|
||
</Providers>
|
||
</body>
|
||
</html>
|
||
)
|
||
}
|
||
|