fix: show loading icon when fetching system features

This commit is contained in:
NFish 2025-03-15 11:59:58 +08:00
parent e0232c67cc
commit 7da45ba589
1 changed files with 4 additions and 1 deletions

View File

@ -6,6 +6,7 @@ import { useEffect } from 'react'
import type { SystemFeatures } from '@/types/feature'
import { defaultSystemFeatures } from '@/types/feature'
import { getSystemFeatures } from '@/service/common'
import Loading from '@/app/components/base/loading'
type GlobalPublicStore = {
systemFeatures: SystemFeatures
@ -20,7 +21,7 @@ export const useGlobalPublicStore = create<GlobalPublicStore>(set => ({
const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
children,
}) => {
const { data } = useQuery({
const { isPending, data } = useQuery({
queryKey: ['systemFeatures'],
queryFn: getSystemFeatures,
})
@ -29,6 +30,8 @@ const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
if (data)
setSystemFeatures({ ...defaultSystemFeatures, ...data })
}, [data, setSystemFeatures])
if (isPending)
return <div className='w-screen h-screen flex items-center justify-center'><Loading /></div>
return <>{children}</>
}
export default GlobalPublicStoreProvider