diff --git a/packages/api/src/migrations/ui-schema/login.ts b/packages/api/src/migrations/ui-schema/login.ts index d6eaf0c40..2ccf1da4d 100644 --- a/packages/api/src/migrations/ui-schema/login.ts +++ b/packages/api/src/migrations/ui-schema/login.ts @@ -1,6 +1,7 @@ export const login = { key: 'dtf9j0b8p9u', type: 'object', + title: '登录', properties: { email: { type: 'string', diff --git a/packages/api/src/migrations/ui-schema/register.ts b/packages/api/src/migrations/ui-schema/register.ts index 39dbb2e31..1c183a376 100644 --- a/packages/api/src/migrations/ui-schema/register.ts +++ b/packages/api/src/migrations/ui-schema/register.ts @@ -1,6 +1,7 @@ export const register = { key: '46qlxqam3xk', type: 'object', + title: '注册', properties: { email: { type: 'string', diff --git a/packages/client/src/components/admin-layout/SiteTitle.tsx b/packages/client/src/components/admin-layout/SiteTitle.tsx index 324bc895d..4c0024bdc 100644 --- a/packages/client/src/components/admin-layout/SiteTitle.tsx +++ b/packages/client/src/components/admin-layout/SiteTitle.tsx @@ -30,6 +30,11 @@ export function SystemSettingsProvider(props) { ); } +export const useSystemSettings = () => { + const ctx = useContext(SystemSettingsContext); + return ctx?.service?.data || {}; +}; + export const SiteTitle = () => { const { service = {} } = useContext(SystemSettingsContext); const { loading, data } = service; diff --git a/packages/client/src/components/admin-layout/index.tsx b/packages/client/src/components/admin-layout/index.tsx index 7f9a65741..e6ee0cca6 100644 --- a/packages/client/src/components/admin-layout/index.tsx +++ b/packages/client/src/components/admin-layout/index.tsx @@ -38,8 +38,13 @@ import { uid } from '@formily/shared'; import { Permissions } from './Permissions'; import { More } from './More'; import { UserInfo } from './UserInfo'; -import { SiteTitle, SystemSettingsProvider } from './SiteTitle'; +import { + SiteTitle, + SystemSettingsProvider, + useSystemSettings, +} from './SiteTitle'; import { AuthProvider } from './Auth'; +import { Helmet } from 'react-helmet'; function DesignableToggle() { const { designable, setDesignable } = useDesignableSwitchContext(); @@ -69,6 +74,7 @@ function LayoutWithMenu(props: LayoutWithMenuProps) { const match = useRouteMatch(); const sideMenuRef = useRef(); const history = useHistory(); + const { title } = useSystemSettings(); const [activeKey, setActiveKey] = useState(match.params.name); const [, setPageTitle] = usePageTitleContext(); const onSelect = (info) => { @@ -91,6 +97,7 @@ function LayoutWithMenu(props: LayoutWithMenuProps) { const onMenuItemRemove = () => { history.push(`/admin`); }; + console.log({ activeKey }); return ( @@ -117,7 +124,13 @@ function LayoutWithMenu(props: LayoutWithMenuProps) { width={200} > - {activeKey && } + {activeKey ? ( + + ) : ( + + {title} + + )} diff --git a/packages/client/src/components/auth-layout/index.tsx b/packages/client/src/components/auth-layout/index.tsx index ddd8a8ba3..ee656bd79 100644 --- a/packages/client/src/components/auth-layout/index.tsx +++ b/packages/client/src/components/auth-layout/index.tsx @@ -1,6 +1,7 @@ import { Card } from 'antd'; import React from 'react'; import { useLocation, useHistory } from 'react-router-dom'; +import { SystemSettingsProvider } from '../admin-layout/SiteTitle'; export function AuthLayout({ children, route }: any) { const location = useLocation(); @@ -8,7 +9,7 @@ export function AuthLayout({ children, route }: any) { return (

NocoBase

- {children} + {children}
); } diff --git a/packages/client/src/components/route-schema-renderer/index.tsx b/packages/client/src/components/route-schema-renderer/index.tsx index 2bb5ee4b0..cc1fe03bf 100644 --- a/packages/client/src/components/route-schema-renderer/index.tsx +++ b/packages/client/src/components/route-schema-renderer/index.tsx @@ -5,6 +5,7 @@ import { useRequest } from 'ahooks'; import { request, SchemaRenderer } from '../../schemas'; import { useForm } from '@formily/react'; import { useHistory, useLocation } from 'react-router-dom'; +import { useSystemSettings } from '../admin-layout/SiteTitle'; function Div(props) { return
; @@ -56,11 +57,15 @@ export function RouteSchemaRenderer({ route }) { formatResult: (result) => result?.data, }, ); + const { title } = useSystemSettings(); if (loading) { return ; } return (
+ + {title ? `${data.title} - ${title}` : data.title} + { - return useState(defaultPageTitle); + const { title } = useSystemSettings(); + const [pageTitle, setPageTitle] = useState(defaultPageTitle); + return [title ? `${pageTitle} - ${title}` : pageTitle, setPageTitle]; }); export { PageTitleProvider, usePageTitleContext }; diff --git a/packages/client/src/schemas/page/index.tsx b/packages/client/src/schemas/page/index.tsx index b482a0198..86859f29c 100644 --- a/packages/client/src/schemas/page/index.tsx +++ b/packages/client/src/schemas/page/index.tsx @@ -2,13 +2,16 @@ import React from 'react'; import { PageHeader as AntdPageHeader } from 'antd'; import { observer } from '@formily/react'; import { usePageTitleContext } from '../../constate/PageTitle'; +import { Helmet } from 'react-helmet'; export const Page = observer((props) => { const { children, ...others } = props; const [pageTitle] = usePageTitleContext(); - return ( <> + + {pageTitle} +
{children}