重构优化主题异步加载

This commit is contained in:
tangly1024.com
2023-06-07 15:39:41 +08:00
parent 9247c4d308
commit 00d32c81e0
107 changed files with 467 additions and 338 deletions

View File

@@ -1,21 +1,22 @@
import { useGlobal } from '@/lib/global'
import { useEffect } from 'react'
/**
* 主题文件被加载出之前的占位符
* @returns
*/
const Loading = (props) => {
const { theme, setOnReading } = useGlobal()
// const { theme, setOnReading } = useGlobal()
// console.log('开启遮罩')
// setOnReading(true)
useEffect(() => {
// 返回一个函数,在组件销毁时设置 onReading 为 false
return () => {
setTimeout(() => {
setOnReading(false)
}, 500)
}
}, [theme])
// useEffect(() => {
// // 返回一个函数,在组件销毁时设置 onReading 为 false
// return () => {
// setTimeout(() => {
// console.log('关闭遮罩')
// setOnReading(false)
// }, 500)
// }
// })
return <div className="w-screen h-screen flex justify-center items-center bg-black">
<i className='mr-5 fas fa-spinner animate-spin text-2xl' />