reading resources

This commit is contained in:
tangly1024
2023-06-04 21:37:45 +08:00
parent b492515eb9
commit 8ace4b2f64
5 changed files with 57 additions and 33 deletions

View File

@@ -1,15 +1,22 @@
import { useGlobal } from '@/lib/global'
import { useEffect } from 'react'
/**
* 主题文件被加载出之前的占位符
* @returns
*/
const Loading = (props) => {
const { current } = props
const { theme, setOnReading } = useGlobal()
return <>
{current || <div className="w-screen h-screen flex justify-center items-center bg-white dark:bg-black">
<h1>Loading... <i className='ml-2 fas fa-spinner animate-spin' /></h1>
</div>}
</>
useEffect(() => {
// 返回一个函数,在组件销毁时设置 onReading 为 false
return () => {
setOnReading(false)
}
}, [theme])
return <div className="w-screen h-screen flex justify-center items-center dark:bg-black text-black dark:text-white">
<h1 className="text-2xl"><i className='mr-5 fas fa-spinner animate-spin' />Loading...</h1>
</div>
}
export default Loading