duplicate layout

This commit is contained in:
tangly1024
2023-06-06 22:33:26 +08:00
parent 02320a822b
commit a0912d4767

View File

@@ -5,7 +5,8 @@ import { useGlobal } from '@/lib/global'
import { generateRss } from '@/lib/rss'
import { generateRobotsTxt } from '@/lib/robots.txt'
import dynamic from 'next/dynamic'
import { useEffect, useState } from 'react'
import { Suspense, useEffect, useState } from 'react'
import Loading from '@/components/Loading'
/**
* 懒加载默认主题
@@ -26,16 +27,26 @@ const Index = props => {
useEffect(() => {
const loadLayout = async () => {
const NewLayoutIndex = dynamic(() => import(`@/themes/${theme}`).then(async (m) => {
setOnReading(false)
return m.LayoutIndex
}), { ssr: true })
setLayoutIndex(NewLayoutIndex)
try {
const NewLayoutIndex = await dynamic(() => import(`@/themes/${theme}`).then(async (m) => {
setOnReading(false)
return m.LayoutIndex
}))
setLayoutIndex(NewLayoutIndex)
} catch (error) {
console.error('Error while loading layout:', error)
}
}
loadLayout()
}, [theme])
return <LayoutIndex {...props} />
return (
<Suspense fallback={<Loading/>}>
<LayoutIndex {...props} />
</Suspense>
)
}
/**