diff --git a/web/app/(commonLayout)/apps/Apps.tsx b/web/app/(commonLayout)/apps/Apps.tsx index 8560787e95..1b7ff39383 100644 --- a/web/app/(commonLayout)/apps/Apps.tsx +++ b/web/app/(commonLayout)/apps/Apps.tsx @@ -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 }) diff --git a/web/app/(commonLayout)/apps/layout.tsx b/web/app/(commonLayout)/apps/layout.tsx new file mode 100644 index 0000000000..10d04a4188 --- /dev/null +++ b/web/app/(commonLayout)/apps/layout.tsx @@ -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} + ) +} diff --git a/web/app/layout.tsx b/web/app/layout.tsx index f6c988a979..138c79b6a6 100644 --- a/web/app/layout.tsx +++ b/web/app/layout.tsx @@ -18,7 +18,6 @@ export const viewport: Viewport = { userScalable: false, } export const metadata: Metadata = { - title: ' ', icons: 'data:', } diff --git a/web/hooks/use-document-title.spec.ts b/web/hooks/use-document-title.spec.ts new file mode 100644 index 0000000000..0316c3a3e7 --- /dev/null +++ b/web/hooks/use-document-title.spec.ts @@ -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') + }) +})