fix(client): page title translation doesn't work

resolve #838
This commit is contained in:
chenos 2022-11-13 17:17:06 +08:00
parent dcb5a71b92
commit b7113b658a

View File

@ -1,11 +1,13 @@
import React, { useEffect } from 'react'; import { useField } from '@formily/react';
import { PageHeader as AntdPageHeader } from 'antd'; import { PageHeader as AntdPageHeader } from 'antd';
import { observer, useField } from '@formily/react'; import React, { useEffect } from 'react';
import { useDocumentTitle } from '../../../document-title'; import { useDocumentTitle } from '../../../document-title';
import { useCompile } from '../../hooks';
export const Page = (props) => { export const Page = (props) => {
const { children, ...others } = props; const { children, ...others } = props;
const field = useField(); const field = useField();
const compile = useCompile();
const { title, setTitle } = useDocumentTitle(); const { title, setTitle } = useDocumentTitle();
useEffect(() => { useEffect(() => {
if (!title) { if (!title) {
@ -14,7 +16,7 @@ export const Page = (props) => {
}, [field.title, title]); }, [field.title, title]);
return ( return (
<> <>
<AntdPageHeader ghost={false} title={title} {...others} /> <AntdPageHeader ghost={false} title={compile(title)} {...others} />
<div style={{ margin: 24 }}>{children}</div> <div style={{ margin: 24 }}>{children}</div>
</> </>
); );