fix: document title error at studio page

This commit is contained in:
NFish 2025-05-13 13:44:52 +08:00
parent 74cc4c0ce8
commit 94c64b661e
4 changed files with 31 additions and 4 deletions

View File

@ -29,7 +29,6 @@ import { useStore as useTagStore } from '@/app/components/base/tag-management/st
import TagManagementModal from '@/app/components/base/tag-management'
import TagFilter from '@/app/components/base/tag-management/filter'
import CheckboxWithLabel from '@/app/components/datasets/create/website/base/checkbox-with-label'
import useDocumentTitle from '@/hooks/use-document-title'
const getKey = (
pageIndex: number,
@ -128,8 +127,6 @@ const Apps = () => {
return () => observer?.disconnect()
}, [isLoading, setSize, anchorRef, mutate, data, error])
useDocumentTitle(isLoading ? '' : t('common.menus.apps'))
const { run: handleSearch } = useDebounceFn(() => {
setSearchKeywords(keywords)
}, { wait: 500 })

View File

@ -0,0 +1,12 @@
'use client'
import useDocumentTitle from '@/hooks/use-document-title'
import { useTranslation } from 'react-i18next'
export default function DatasetsLayout({ children }: { children: React.ReactNode }) {
const { t } = useTranslation()
useDocumentTitle(t('common.menus.apps'))
return (<>
{children}
</>)
}

View File

@ -18,7 +18,6 @@ export const viewport: Viewport = {
userScalable: false,
}
export const metadata: Metadata = {
title: ' ',
icons: 'data:',
}

View File

@ -0,0 +1,19 @@
import { defaultSystemFeatures } from '@/types/feature'
import { renderHook } from '@testing-library/react'
import useDocumentTitle from './use-document-title'
jest.mock('@/context/global-public-context', () => ({
useGlobalPublicStore: jest.fn(() => ({ ...defaultSystemFeatures })),
}))
describe('branding.enabled is false', () => {
it('document title should be test-Dify if set title', () => {
renderHook(() => useDocumentTitle('test'))
expect(document.title).toBe('test - Dify')
})
it('document title should be Dify if not set title', () => {
renderHook(() => useDocumentTitle(''))
expect(document.title).toBe('Dify')
})
})