mirror of https://github.com/langgenius/dify.git
fix: hide favico if systemFeatures is still pending
This commit is contained in:
parent
8bc1512fa1
commit
85832702f6
|
|
@ -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<GlobalPublicStore>(set => ({
|
||||
isPending: true,
|
||||
setIsPending: (isPending: boolean) => set(() => ({ isPending })),
|
||||
systemFeatures: defaultSystemFeatures,
|
||||
setSystemFeatures: (systemFeatures: SystemFeatures) => set(() => ({ systemFeatures })),
|
||||
}))
|
||||
|
|
@ -25,11 +29,16 @@ const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
|
|||
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 <div className='flex h-screen w-screen items-center justify-center'><Loading /></div>
|
||||
return <>{children}</>
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue