mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-16 17:25:56 +08:00
fix: show loading icon when fetching system features
This commit is contained in:
parent
e0232c67cc
commit
7da45ba589
@ -6,6 +6,7 @@ import { useEffect } from 'react'
|
|||||||
import type { SystemFeatures } from '@/types/feature'
|
import type { SystemFeatures } from '@/types/feature'
|
||||||
import { defaultSystemFeatures } from '@/types/feature'
|
import { defaultSystemFeatures } from '@/types/feature'
|
||||||
import { getSystemFeatures } from '@/service/common'
|
import { getSystemFeatures } from '@/service/common'
|
||||||
|
import Loading from '@/app/components/base/loading'
|
||||||
|
|
||||||
type GlobalPublicStore = {
|
type GlobalPublicStore = {
|
||||||
systemFeatures: SystemFeatures
|
systemFeatures: SystemFeatures
|
||||||
@ -20,7 +21,7 @@ export const useGlobalPublicStore = create<GlobalPublicStore>(set => ({
|
|||||||
const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
|
const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
|
||||||
children,
|
children,
|
||||||
}) => {
|
}) => {
|
||||||
const { data } = useQuery({
|
const { isPending, data } = useQuery({
|
||||||
queryKey: ['systemFeatures'],
|
queryKey: ['systemFeatures'],
|
||||||
queryFn: getSystemFeatures,
|
queryFn: getSystemFeatures,
|
||||||
})
|
})
|
||||||
@ -29,6 +30,8 @@ const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
|
|||||||
if (data)
|
if (data)
|
||||||
setSystemFeatures({ ...defaultSystemFeatures, ...data })
|
setSystemFeatures({ ...defaultSystemFeatures, ...data })
|
||||||
}, [data, setSystemFeatures])
|
}, [data, setSystemFeatures])
|
||||||
|
if (isPending)
|
||||||
|
return <div className='w-screen h-screen flex items-center justify-center'><Loading /></div>
|
||||||
return <>{children}</>
|
return <>{children}</>
|
||||||
}
|
}
|
||||||
export default GlobalPublicStoreProvider
|
export default GlobalPublicStoreProvider
|
||||||
|
Loading…
x
Reference in New Issue
Block a user