From 7da45ba5898c625afb3fb79cf3bc956069811a57 Mon Sep 17 00:00:00 2001 From: NFish Date: Sat, 15 Mar 2025 11:59:58 +0800 Subject: [PATCH] fix: show loading icon when fetching system features --- web/context/global-public-context.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/web/context/global-public-context.tsx b/web/context/global-public-context.tsx index 17a7441642..71a2e37d07 100644 --- a/web/context/global-public-context.tsx +++ b/web/context/global-public-context.tsx @@ -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(set => ({ const GlobalPublicStoreProvider: FC = ({ children, }) => { - const { data } = useQuery({ + const { isPending, data } = useQuery({ queryKey: ['systemFeatures'], queryFn: getSystemFeatures, }) @@ -29,6 +30,8 @@ const GlobalPublicStoreProvider: FC = ({ if (data) setSystemFeatures({ ...defaultSystemFeatures, ...data }) }, [data, setSystemFeatures]) + if (isPending) + return
return <>{children} } export default GlobalPublicStoreProvider