mirror of
https://github.com/langgenius/dify.git
synced 2026-04-29 04:26:30 +08:00
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'
|
import Loading from '@/app/components/base/loading'
|
||||||
|
|
||||||
type GlobalPublicStore = {
|
type GlobalPublicStore = {
|
||||||
|
isPending: boolean
|
||||||
|
setIsPending: (isPending: boolean) => void
|
||||||
systemFeatures: SystemFeatures
|
systemFeatures: SystemFeatures
|
||||||
setSystemFeatures: (systemFeatures: SystemFeatures) => void
|
setSystemFeatures: (systemFeatures: SystemFeatures) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
export const useGlobalPublicStore = create<GlobalPublicStore>(set => ({
|
export const useGlobalPublicStore = create<GlobalPublicStore>(set => ({
|
||||||
|
isPending: true,
|
||||||
|
setIsPending: (isPending: boolean) => set(() => ({ isPending })),
|
||||||
systemFeatures: defaultSystemFeatures,
|
systemFeatures: defaultSystemFeatures,
|
||||||
setSystemFeatures: (systemFeatures: SystemFeatures) => set(() => ({ systemFeatures })),
|
setSystemFeatures: (systemFeatures: SystemFeatures) => set(() => ({ systemFeatures })),
|
||||||
}))
|
}))
|
||||||
@ -25,11 +29,16 @@ const GlobalPublicStoreProvider: FC<PropsWithChildren> = ({
|
|||||||
queryKey: ['systemFeatures'],
|
queryKey: ['systemFeatures'],
|
||||||
queryFn: getSystemFeatures,
|
queryFn: getSystemFeatures,
|
||||||
})
|
})
|
||||||
const { setSystemFeatures } = useGlobalPublicStore()
|
const { setSystemFeatures, setIsPending } = useGlobalPublicStore()
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (data)
|
if (data)
|
||||||
setSystemFeatures({ ...defaultSystemFeatures, ...data })
|
setSystemFeatures({ ...defaultSystemFeatures, ...data })
|
||||||
}, [data, setSystemFeatures])
|
}, [data, setSystemFeatures])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setIsPending(isPending)
|
||||||
|
}, [isPending, setIsPending])
|
||||||
|
|
||||||
if (isPending)
|
if (isPending)
|
||||||
return <div className='flex h-screen w-screen items-center justify-center'><Loading /></div>
|
return <div className='flex h-screen w-screen items-center justify-center'><Loading /></div>
|
||||||
return <>{children}</>
|
return <>{children}</>
|
||||||
|
|||||||
@ -3,8 +3,21 @@ import { useGlobalPublicStore } from '@/context/global-public-context'
|
|||||||
import { useFavicon, useTitle } from 'ahooks'
|
import { useFavicon, useTitle } from 'ahooks'
|
||||||
|
|
||||||
export default function useDocumentTitle(title: string) {
|
export default function useDocumentTitle(title: string) {
|
||||||
|
const isPending = useGlobalPublicStore(s => s.isPending)
|
||||||
const systemFeatures = useGlobalPublicStore(s => s.systemFeatures)
|
const systemFeatures = useGlobalPublicStore(s => s.systemFeatures)
|
||||||
const prefix = title ? `${title} - ` : ''
|
const prefix = title ? `${title} - ` : ''
|
||||||
useTitle(systemFeatures.branding.enabled ? `${prefix}${systemFeatures.branding.application_title}` : `${prefix}Dify`)
|
let titleStr = ''
|
||||||
useFavicon(systemFeatures.branding.enabled ? systemFeatures.branding.favicon : '/favicon.ico')
|
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
Block a user