From 73dfe074d79bf93ac46daf02248c9776025291ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=AB=E9=9B=A8=E6=B0=B4=E8=BF=87=E6=BB=A4=E7=9A=84?= =?UTF-8?q?=E7=A9=BA=E6=B0=94-Rairn?= <958414905@qq.com> Date: Tue, 27 Jun 2023 18:42:33 +0800 Subject: [PATCH] refactor: should use useDocumentTitle to change document title (#2137) --- packages/core/client/src/pm/index.tsx | 2 -- .../src/client/core/schema/components/header/Header.tsx | 9 +++++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/core/client/src/pm/index.tsx b/packages/core/client/src/pm/index.tsx index 1ee0ba0cd..00db02c89 100644 --- a/packages/core/client/src/pm/index.tsx +++ b/packages/core/client/src/pm/index.tsx @@ -9,7 +9,6 @@ import { useACLRoleContext } from '../acl/ACLProvider'; import { ACLPane } from '../acl/ACLShortcut'; import { useRequest } from '../api-client'; import { CollectionManagerPane } from '../collection-manager'; -import { useDocumentTitle } from '../document-title'; import { Icon } from '../icon'; import { RouteSwitchContext } from '../route-switch'; import { useCompile } from '../schema-component'; @@ -113,7 +112,6 @@ const PluginList = (props) => { const params = useParams(); const navigate = useNavigate(); const { tabName = 'local' } = params; - const { setTitle } = useDocumentTitle(); const { t } = useTranslation(); const { snippets = [] } = useACLRoleContext(); diff --git a/packages/plugins/mobile-client/src/client/core/schema/components/header/Header.tsx b/packages/plugins/mobile-client/src/client/core/schema/components/header/Header.tsx index 3d6c145c3..cc0cb3039 100644 --- a/packages/plugins/mobile-client/src/client/core/schema/components/header/Header.tsx +++ b/packages/plugins/mobile-client/src/client/core/schema/components/header/Header.tsx @@ -1,11 +1,11 @@ import { css, cx } from '@emotion/css'; -import { SortableItem, useCompile, useDesigner } from '@nocobase/client'; +import { useField } from '@formily/react'; +import { SortableItem, useCompile, useDesigner, useDocumentTitle } from '@nocobase/client'; import { NavBar, NavBarProps } from 'antd-mobile'; import React, { useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import { HeaderDesigner } from './Header.Designer'; -import { useField } from '@formily/react'; import { generateNTemplate } from '../../../../locale'; +import { HeaderDesigner } from './Header.Designer'; export interface HeaderProps extends NavBarProps { title?: string; @@ -18,10 +18,11 @@ const InternalHeader = (props: HeaderProps) => { const compile = useCompile(); const compiledTitle = compile(title); const navigate = useNavigate(); + const { setTitle } = useDocumentTitle(); useEffect(() => { // sync title - document.title = `${compiledTitle} - NocoBase`; + setTitle(compiledTitle); }, [compiledTitle]); return (