mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-05-05 21:49:25 +08:00
fix: left menu title modify (#3956)
This commit is contained in:
parent
89b73ba389
commit
606ef55db8
@ -126,18 +126,6 @@ const MenuEditor = (props) => {
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
const match = useMatch('/admin/:name');
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
if (match) {
|
|
||||||
const schema = filterByACL(data?.data, ctx);
|
|
||||||
const s = findByUid(schema, defaultSelectedUid);
|
|
||||||
if (s) {
|
|
||||||
setTitle(s.title);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [data?.data, location.pathname, defaultSelectedUid]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const properties = Object.values(current?.root?.properties || {}).shift()?.['properties'] || data?.data?.properties;
|
const properties = Object.values(current?.root?.properties || {}).shift()?.['properties'] || data?.data?.properties;
|
||||||
if (sideMenuRef.current) {
|
if (sideMenuRef.current) {
|
||||||
|
@ -4,7 +4,7 @@ import { ISchema, Schema, useField, useFieldSchema } from '@formily/react';
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import { findByUid } from '.';
|
import { findByUid } from '.';
|
||||||
import { createDesignable } from '../..';
|
import { createDesignable, useCompile } from '../..';
|
||||||
import {
|
import {
|
||||||
GeneralSchemaDesigner,
|
GeneralSchemaDesigner,
|
||||||
SchemaSettingsDivider,
|
SchemaSettingsDivider,
|
||||||
@ -208,6 +208,8 @@ export const MenuDesigner = () => {
|
|||||||
const { dn, refresh } = useDesignable();
|
const { dn, refresh } = useDesignable();
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const menuSchema = findMenuSchema(fieldSchema);
|
const menuSchema = findMenuSchema(fieldSchema);
|
||||||
|
const compile = useCompile();
|
||||||
|
const onSelect = compile(menuSchema?.['x-component-props']?.['onSelect']);
|
||||||
const items = toItems(menuSchema?.properties);
|
const items = toItems(menuSchema?.properties);
|
||||||
const effects = (form) => {
|
const effects = (form) => {
|
||||||
onFieldChange('target', (field: Field) => {
|
onFieldChange('target', (field: Field) => {
|
||||||
@ -286,6 +288,7 @@ export const MenuDesigner = () => {
|
|||||||
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
fieldSchema['x-component-props'] = fieldSchema['x-component-props'] || {};
|
||||||
fieldSchema['x-component-props']['icon'] = icon;
|
fieldSchema['x-component-props']['icon'] = icon;
|
||||||
fieldSchema['x-component-props']['href'] = href;
|
fieldSchema['x-component-props']['href'] = href;
|
||||||
|
onSelect?.({ item: { props: { schema: fieldSchema } } });
|
||||||
dn.emit('patch', {
|
dn.emit('patch', {
|
||||||
schema,
|
schema,
|
||||||
});
|
});
|
||||||
|
@ -24,6 +24,7 @@ import { ErrorFallback } from '../error-fallback';
|
|||||||
import FixedBlock from './FixedBlock';
|
import FixedBlock from './FixedBlock';
|
||||||
import { PageDesigner, PageTabDesigner } from './PageTabDesigner';
|
import { PageDesigner, PageTabDesigner } from './PageTabDesigner';
|
||||||
import { useStyles } from './style';
|
import { useStyles } from './style';
|
||||||
|
import { useRequest } from '../../../api-client';
|
||||||
|
|
||||||
export const Page = (props) => {
|
export const Page = (props) => {
|
||||||
const { children, ...others } = props;
|
const { children, ...others } = props;
|
||||||
@ -62,11 +63,24 @@ export const Page = (props) => {
|
|||||||
const { wrapSSR, hashId, componentCls } = useStyles();
|
const { wrapSSR, hashId, componentCls } = useStyles();
|
||||||
const aclStyles = useAClStyles();
|
const aclStyles = useAClStyles();
|
||||||
|
|
||||||
|
const pageHeaderTitle = hidePageTitle ? undefined : fieldSchema.title || compile(title);
|
||||||
|
|
||||||
|
useRequest(
|
||||||
|
{
|
||||||
|
url: `/uiSchemas:getParentJsonSchema/${fieldSchema['x-uid']}`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
ready: !hidePageTitle && !pageHeaderTitle,
|
||||||
|
onSuccess(data) {
|
||||||
|
setTitle(data.data.title);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
const handleErrors = (error) => {
|
const handleErrors = (error) => {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
};
|
};
|
||||||
|
|
||||||
const pageHeaderTitle = hidePageTitle ? undefined : fieldSchema.title || compile(title);
|
|
||||||
return wrapSSR(
|
return wrapSSR(
|
||||||
<div className={`${componentCls} ${hashId} ${aclStyles.styles}`}>
|
<div className={`${componentCls} ${hashId} ${aclStyles.styles}`}>
|
||||||
<PageDesigner title={fieldSchema.title || title} />
|
<PageDesigner title={fieldSchema.title || title} />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user