mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 02:56:22 +00:00
feat: 更新默认站点名称以更清晰地反映错误状态,优化合并逻辑以支持对象递归合并
This commit is contained in:
@ -72,8 +72,10 @@ export default async function RootLayout({
|
||||
const siteInfo = await getSiteInfo().then(res => res.data).catch(() => fallbackSiteInfo);
|
||||
const colorSchemes = siteInfo?.colorSchemes ? siteInfo.colorSchemes : fallbackSiteInfo.colorSchemes;
|
||||
|
||||
console.log(siteInfo)
|
||||
|
||||
return (
|
||||
<html lang={await getFirstLocale() || "en"} className="h-full" data-user-color={(colorSchemes).includes(user?.preferredColor || "") ? user?.preferredColor : "blue"}>
|
||||
<html lang={await getFirstLocale() || "en"} className="h-full" data-user-color={colorSchemes.includes(user?.preferredColor || "") ? user?.preferredColor : "blue"}>
|
||||
<body
|
||||
className={`${geistSans.variable} ${geistMono.variable} antialiased`}
|
||||
>
|
||||
|
@ -34,7 +34,7 @@ export type SiteInfo = {
|
||||
export const fallbackSiteInfo: SiteInfo = {
|
||||
colorSchemes: ["blue", "green", "orange", "red", "rose", "violet", "yellow"],
|
||||
metadata: {
|
||||
name: "Failed to Fetch Name",
|
||||
name: "Failed to Fetch",
|
||||
icon: "",
|
||||
description: "Failed to fetch site info from server.",
|
||||
},
|
||||
@ -87,8 +87,8 @@ function mergeWithFallback<T extends Record<string, unknown>>(initial: T, fallba
|
||||
typeof fallbackValue === 'object' &&
|
||||
!Array.isArray(fallbackValue)
|
||||
) {
|
||||
// 如果都是对象(非数组),也不要递归合并
|
||||
result[key] = { ...initialValue, ...fallbackValue };
|
||||
// 如果都是对象(非数组),递归合并
|
||||
result[key] = mergeWithFallback(initialValue as Record<string, unknown>, fallbackValue as Record<string, unknown>) as T[typeof key];
|
||||
}
|
||||
// 否则保持 initial 的值不变
|
||||
}
|
||||
|
Reference in New Issue
Block a user