diff --git a/web/context/global-public-context.tsx b/web/context/global-public-context.tsx index da3f520906..5aa5e7a302 100644 --- a/web/context/global-public-context.tsx +++ b/web/context/global-public-context.tsx @@ -9,11 +9,15 @@ import { getSystemFeatures } from '@/service/common' import Loading from '@/app/components/base/loading' type GlobalPublicStore = { + isPending: boolean + setIsPending: (isPending: boolean) => void systemFeatures: SystemFeatures setSystemFeatures: (systemFeatures: SystemFeatures) => void } export const useGlobalPublicStore = create(set => ({ + isPending: true, + setIsPending: (isPending: boolean) => set(() => ({ isPending })), systemFeatures: defaultSystemFeatures, setSystemFeatures: (systemFeatures: SystemFeatures) => set(() => ({ systemFeatures })), })) @@ -25,11 +29,16 @@ const GlobalPublicStoreProvider: FC = ({ queryKey: ['systemFeatures'], queryFn: getSystemFeatures, }) - const { setSystemFeatures } = useGlobalPublicStore() + const { setSystemFeatures, setIsPending } = useGlobalPublicStore() useEffect(() => { if (data) setSystemFeatures({ ...defaultSystemFeatures, ...data }) }, [data, setSystemFeatures]) + + useEffect(() => { + setIsPending(isPending) + }, [isPending, setIsPending]) + if (isPending) return
return <>{children} diff --git a/web/hooks/use-document-title.ts b/web/hooks/use-document-title.ts index 9ad71e77c6..10275a196f 100644 --- a/web/hooks/use-document-title.ts +++ b/web/hooks/use-document-title.ts @@ -3,8 +3,21 @@ import { useGlobalPublicStore } from '@/context/global-public-context' import { useFavicon, useTitle } from 'ahooks' export default function useDocumentTitle(title: string) { + const isPending = useGlobalPublicStore(s => s.isPending) const systemFeatures = useGlobalPublicStore(s => s.systemFeatures) const prefix = title ? `${title} - ` : '' - useTitle(systemFeatures.branding.enabled ? `${prefix}${systemFeatures.branding.application_title}` : `${prefix}Dify`) - useFavicon(systemFeatures.branding.enabled ? systemFeatures.branding.favicon : '/favicon.ico') + let titleStr = '' + let favicon = '' + if (isPending === false) { + if (systemFeatures.branding.enabled) { + titleStr = `${prefix}${systemFeatures.branding.application_title}` + favicon = systemFeatures.branding.favicon + } + else { + titleStr = `${prefix}Dify` + favicon = '/favicon.ico' + } + } + useTitle(titleStr) + useFavicon(favicon) }