2025-03-14 18:54:17 +08:00
|
|
|
'use client'
|
|
|
|
import { useLayoutEffect } from 'react'
|
|
|
|
import { useGlobalPublicStore } from '@/context/global-public-context'
|
|
|
|
|
|
|
|
export default function useDocumentTitle(title: string) {
|
|
|
|
const { systemFeatures } = useGlobalPublicStore()
|
|
|
|
useLayoutEffect(() => {
|
2025-03-15 01:25:04 +08:00
|
|
|
const prefix = title ? `${title} - ` : ''
|
|
|
|
if (systemFeatures.branding.enabled) {
|
|
|
|
document.title = `${prefix}${systemFeatures.branding.application_title}`
|
|
|
|
const faviconEle = document.querySelector('link[rel*=\'icon\']') as HTMLLinkElement
|
|
|
|
faviconEle.href = systemFeatures.branding.favicon
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
document.title = `${prefix}Dify`
|
|
|
|
}
|
2025-03-14 18:54:17 +08:00
|
|
|
}, [systemFeatures, title])
|
|
|
|
}
|