mirror of
https://gitee.com/nocobase/nocobase.git
synced 2025-07-02 11:12:20 +08:00
refactor: code improve
This commit is contained in:
parent
7561db0fa0
commit
5f997963a0
@ -103,8 +103,7 @@ BlockModel.registerFlow({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
handler(ctx, params) {
|
handler(ctx, params) {
|
||||||
ctx.model.setProps('heightMode', params.heightMode);
|
ctx.model.setDecoratorProps({ heightMode: params.heightMode, height: params.height });
|
||||||
ctx.model.setProps('height', params.height);
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -14,10 +14,18 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { NAMESPACE_UI_SCHEMA } from '../../../i18n/constant';
|
import { NAMESPACE_UI_SCHEMA } from '../../../i18n/constant';
|
||||||
import { MarkdownReadPretty } from '../fields/EditableField/MarkdownEditableFieldModel';
|
import { MarkdownReadPretty } from '../fields/EditableField/MarkdownEditableFieldModel';
|
||||||
|
|
||||||
|
const useBlockHeight = ({ height, heightMode }) => {
|
||||||
|
if (heightMode !== 'specifyValue') {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return height;
|
||||||
|
};
|
||||||
|
|
||||||
export const BlockItemCard = (props) => {
|
export const BlockItemCard = (props) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { token } = theme.useToken();
|
const { token } = theme.useToken();
|
||||||
const { title: blockTitle, description, children } = props;
|
const { title: blockTitle, description, children } = props;
|
||||||
|
const height = useBlockHeight(props);
|
||||||
const title = (blockTitle || description) && (
|
const title = (blockTitle || description) && (
|
||||||
<div style={{ padding: '8px 0px 8px' }}>
|
<div style={{ padding: '8px 0px 8px' }}>
|
||||||
<span> {t(blockTitle, { ns: NAMESPACE_UI_SCHEMA })}</span>
|
<span> {t(blockTitle, { ns: NAMESPACE_UI_SCHEMA })}</span>
|
||||||
@ -38,7 +46,7 @@ export const BlockItemCard = (props) => {
|
|||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
title={title}
|
title={title}
|
||||||
style={{ display: 'flex', flexDirection: 'column', height: '100%' }}
|
style={{ display: 'flex', flexDirection: 'column', height: height }}
|
||||||
styles={{
|
styles={{
|
||||||
body: { flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' },
|
body: { flex: 1, display: 'flex', flexDirection: 'column', overflow: 'hidden' },
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user