mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 13:39:24 +08:00
fix: issue with public form page title displaying 'Loading...' (#6569)
This commit is contained in:
parent
ec9dbe865a
commit
ce4794bd27
@ -24,6 +24,7 @@ import {
|
|||||||
TextAreaWithGlobalScope,
|
TextAreaWithGlobalScope,
|
||||||
ApplicationContext,
|
ApplicationContext,
|
||||||
useGlobalVariable,
|
useGlobalVariable,
|
||||||
|
useCompile,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import {
|
import {
|
||||||
Breadcrumb,
|
Breadcrumb,
|
||||||
@ -71,6 +72,7 @@ export function AdminPublicFormPage() {
|
|||||||
const { t } = usePublicFormTranslation();
|
const { t } = usePublicFormTranslation();
|
||||||
const { theme } = useGlobalTheme();
|
const { theme } = useGlobalTheme();
|
||||||
const apiClient = useAPIClient();
|
const apiClient = useAPIClient();
|
||||||
|
const compile = useCompile();
|
||||||
const { token } = AntdTheme.useToken();
|
const { token } = AntdTheme.useToken();
|
||||||
const app = useApp();
|
const app = useApp();
|
||||||
const environmentCtx = useGlobalVariable('$env');
|
const environmentCtx = useGlobalVariable('$env');
|
||||||
@ -150,7 +152,7 @@ export function AdminPublicFormPage() {
|
|||||||
title: <Link to={`/admin/settings/public-forms`}>{t('Public forms', { ns: NAMESPACE })}</Link>,
|
title: <Link to={`/admin/settings/public-forms`}>{t('Public forms', { ns: NAMESPACE })}</Link>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: title,
|
title: compile(title),
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
@ -28,6 +28,7 @@ import {
|
|||||||
useApp,
|
useApp,
|
||||||
useRequest,
|
useRequest,
|
||||||
VariablesProvider,
|
VariablesProvider,
|
||||||
|
useCompile,
|
||||||
} from '@nocobase/client';
|
} from '@nocobase/client';
|
||||||
import { Input, Modal, Spin } from 'antd';
|
import { Input, Modal, Spin } from 'antd';
|
||||||
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
import React, { createContext, useContext, useEffect, useMemo, useState } from 'react';
|
||||||
@ -35,7 +36,6 @@ import { isDesktop } from 'react-device-detect';
|
|||||||
import { useParams } from 'react-router';
|
import { useParams } from 'react-router';
|
||||||
import { usePublicSubmitActionProps } from '../hooks';
|
import { usePublicSubmitActionProps } from '../hooks';
|
||||||
import { UnEnabledFormPlaceholder, UnFoundFormPlaceholder } from './UnEnabledFormPlaceholder';
|
import { UnEnabledFormPlaceholder, UnFoundFormPlaceholder } from './UnEnabledFormPlaceholder';
|
||||||
|
|
||||||
import { Button as MobileButton, Dialog as MobileDialog } from 'antd-mobile';
|
import { Button as MobileButton, Dialog as MobileDialog } from 'antd-mobile';
|
||||||
import { MobileDateTimePicker } from './components/MobileDatePicker';
|
import { MobileDateTimePicker } from './components/MobileDatePicker';
|
||||||
import { MobilePicker } from './components/MobilePicker';
|
import { MobilePicker } from './components/MobilePicker';
|
||||||
@ -83,6 +83,14 @@ function PublicAPIClientProvider({ children }) {
|
|||||||
return <APIClientProvider apiClient={apiClient}>{children}</APIClientProvider>;
|
return <APIClientProvider apiClient={apiClient}>{children}</APIClientProvider>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function useTitle(data) {
|
||||||
|
const compile = useCompile();
|
||||||
|
useEffect(() => {
|
||||||
|
if (!data) return;
|
||||||
|
document.title = compile(data?.data?.title);
|
||||||
|
}, [data]);
|
||||||
|
}
|
||||||
|
|
||||||
export const PublicFormMessageContext = createContext<any>({});
|
export const PublicFormMessageContext = createContext<any>({});
|
||||||
export const PageBackgroundColor = '#f5f5f5';
|
export const PageBackgroundColor = '#f5f5f5';
|
||||||
|
|
||||||
@ -174,6 +182,7 @@ function InternalPublicForm() {
|
|||||||
);
|
);
|
||||||
const [pwd, setPwd] = useState('');
|
const [pwd, setPwd] = useState('');
|
||||||
const ctx = useContext(SchemaComponentContext);
|
const ctx = useContext(SchemaComponentContext);
|
||||||
|
useTitle(data);
|
||||||
// 设置的移动端 meta
|
// 设置的移动端 meta
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!isDesktop) {
|
if (!isDesktop) {
|
||||||
|
@ -73,6 +73,7 @@ export class PluginPublicFormsServer extends Plugin {
|
|||||||
const keys = instance.collection.split(':');
|
const keys = instance.collection.split(':');
|
||||||
const collectionName = keys.pop();
|
const collectionName = keys.pop();
|
||||||
const dataSourceKey = keys.pop() || 'main';
|
const dataSourceKey = keys.pop() || 'main';
|
||||||
|
const title = instance.get('title');
|
||||||
const schema = await uiSchema.getJsonSchema(filterByTk);
|
const schema = await uiSchema.getJsonSchema(filterByTk);
|
||||||
const { getAssociationAppends } = parseAssociationNames(dataSourceKey, collectionName, this.app, schema);
|
const { getAssociationAppends } = parseAssociationNames(dataSourceKey, collectionName, this.app, schema);
|
||||||
const { appends } = getAssociationAppends();
|
const { appends } = getAssociationAppends();
|
||||||
@ -94,6 +95,7 @@ export class PluginPublicFormsServer extends Plugin {
|
|||||||
},
|
},
|
||||||
),
|
),
|
||||||
schema,
|
schema,
|
||||||
|
title,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user