mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 05:29:26 +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,
|
||||
ApplicationContext,
|
||||
useGlobalVariable,
|
||||
useCompile,
|
||||
} from '@nocobase/client';
|
||||
import {
|
||||
Breadcrumb,
|
||||
@ -71,6 +72,7 @@ export function AdminPublicFormPage() {
|
||||
const { t } = usePublicFormTranslation();
|
||||
const { theme } = useGlobalTheme();
|
||||
const apiClient = useAPIClient();
|
||||
const compile = useCompile();
|
||||
const { token } = AntdTheme.useToken();
|
||||
const app = useApp();
|
||||
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: title,
|
||||
title: compile(title),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
@ -28,6 +28,7 @@ import {
|
||||
useApp,
|
||||
useRequest,
|
||||
VariablesProvider,
|
||||
useCompile,
|
||||
} from '@nocobase/client';
|
||||
import { Input, Modal, Spin } from 'antd';
|
||||
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 { usePublicSubmitActionProps } from '../hooks';
|
||||
import { UnEnabledFormPlaceholder, UnFoundFormPlaceholder } from './UnEnabledFormPlaceholder';
|
||||
|
||||
import { Button as MobileButton, Dialog as MobileDialog } from 'antd-mobile';
|
||||
import { MobileDateTimePicker } from './components/MobileDatePicker';
|
||||
import { MobilePicker } from './components/MobilePicker';
|
||||
@ -83,6 +83,14 @@ function PublicAPIClientProvider({ children }) {
|
||||
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 PageBackgroundColor = '#f5f5f5';
|
||||
|
||||
@ -174,6 +182,7 @@ function InternalPublicForm() {
|
||||
);
|
||||
const [pwd, setPwd] = useState('');
|
||||
const ctx = useContext(SchemaComponentContext);
|
||||
useTitle(data);
|
||||
// 设置的移动端 meta
|
||||
useEffect(() => {
|
||||
if (!isDesktop) {
|
||||
|
@ -73,6 +73,7 @@ export class PluginPublicFormsServer extends Plugin {
|
||||
const keys = instance.collection.split(':');
|
||||
const collectionName = keys.pop();
|
||||
const dataSourceKey = keys.pop() || 'main';
|
||||
const title = instance.get('title');
|
||||
const schema = await uiSchema.getJsonSchema(filterByTk);
|
||||
const { getAssociationAppends } = parseAssociationNames(dataSourceKey, collectionName, this.app, schema);
|
||||
const { appends } = getAssociationAppends();
|
||||
@ -94,6 +95,7 @@ export class PluginPublicFormsServer extends Plugin {
|
||||
},
|
||||
),
|
||||
schema,
|
||||
title,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user