dify改造升级适配
This commit is contained in:
@@ -63,18 +63,18 @@ describe('use default branding', () => {
|
||||
* Test title format with page title and default branding
|
||||
* Format: "[page] - Dify"
|
||||
*/
|
||||
it('document title should be test-Dify if set title', () => {
|
||||
it('document title should be test-智能体平台 if set title', () => {
|
||||
renderHook(() => useDocumentTitle('test'))
|
||||
expect(document.title).toBe('test - Dify')
|
||||
expect(document.title).toBe('test - 智能体平台')
|
||||
})
|
||||
|
||||
/**
|
||||
* Test title with only default branding (no page title)
|
||||
* Format: "Dify"
|
||||
*/
|
||||
it('document title should be Dify if not set title', () => {
|
||||
it('document title should be 智能体平台 if not set title', () => {
|
||||
renderHook(() => useDocumentTitle(''))
|
||||
expect(document.title).toBe('Dify')
|
||||
expect(document.title).toBe('智能体平台')
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
@@ -4,20 +4,25 @@ import { useFavicon, useTitle } from 'ahooks'
|
||||
import { basePath } from '@/utils/var'
|
||||
import { useEffect } from 'react'
|
||||
|
||||
export default function useDocumentTitle(title: string) {
|
||||
export default function useDocumentTitle(title: string, brandOverride?: string) {
|
||||
const isPending = useGlobalPublicStore(s => s.isGlobalPending)
|
||||
const systemFeatures = useGlobalPublicStore(s => s.systemFeatures)
|
||||
const prefix = title ? `${title} - ` : ''
|
||||
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 = `${basePath}/favicon.ico`
|
||||
if (brandOverride) {
|
||||
titleStr = `${prefix}${brandOverride}`
|
||||
favicon = systemFeatures.branding.enabled ? systemFeatures.branding.favicon : `${basePath}/favicon.ico`
|
||||
} else {
|
||||
if (systemFeatures.branding.enabled) {
|
||||
titleStr = `${prefix}${systemFeatures.branding.application_title}`
|
||||
favicon = systemFeatures.branding.favicon
|
||||
}
|
||||
else {
|
||||
titleStr = `${prefix}智能体平台`
|
||||
favicon = `${basePath}/favicon.ico`
|
||||
}
|
||||
}
|
||||
}
|
||||
useTitle(titleStr)
|
||||
|
||||
Reference in New Issue
Block a user