From ff95dd8685edd7dc35cd9da449d6cdad756a6859 Mon Sep 17 00:00:00 2001 From: lhbxs <596850703@qq.com> Date: Wed, 28 Jun 2023 21:12:42 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20DataRender=20=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/data-render/package.json | 6 +++--- packages/data-render/src/models/resolver.tsx | 14 +++++++------- .../src/widgets/FButton/index.less | 4 ++-- .../data-render/src/widgets/FButton/index.tsx | 4 ++-- .../src/widgets/FButtonFold/index.less | 4 ++-- .../src/widgets/FButtonFold/index.tsx | 2 +- .../data-render/src/widgets/FCard/index.less | 5 +++-- .../data-render/src/widgets/FCard/index.tsx | 12 ++++++------ .../src/widgets/FDescriptions/index.tsx | 1 + .../src/widgets/FEncryption/index.tsx | 7 +++---- .../data-render/src/widgets/FImage/index.tsx | 8 +++----- .../data-render/src/widgets/FLabel/index.less | 2 +- .../data-render/src/widgets/FLabel/index.tsx | 2 +- .../data-render/src/widgets/FPanel/index.tsx | 2 +- .../src/widgets/FProgress/index.less | 2 +- .../src/widgets/FProgress/index.tsx | 2 +- .../src/widgets/FProgressBar/index.tsx | 2 +- .../src/widgets/FRadioGroup/index.tsx | 2 +- .../data-render/src/widgets/FRow/index.less | 2 +- .../data-render/src/widgets/FRow/index.tsx | 2 +- .../data-render/src/widgets/FSpace/index.tsx | 2 +- .../src/widgets/FStatistic/index.tsx | 2 +- .../data-render/src/widgets/FSteps/index.less | 2 +- .../data-render/src/widgets/FSteps/index.tsx | 2 +- .../data-render/src/widgets/FTags/index.tsx | 2 +- .../src/widgets/FTextEllipsis/index.tsx | 2 +- .../src/widgets/FTimeline/index.tsx | 2 +- .../data-render/src/widgets/FTitle/index.less | 2 +- .../data-render/src/widgets/FTitle/index.tsx | 2 +- .../src/widgets/FTooltip/index.less | 2 +- .../src/widgets/FTooltip/index.tsx | 2 +- .../components/BaseCollapse/index.less | 19 +++++++++++-------- .../widgets/components/BaseCollapse/index.tsx | 11 +++++------ .../widgets/components/Encryption/index.tsx | 7 ++++--- .../data-render/src/widgets/utils/common.ts | 12 ++++++++++-- 35 files changed, 83 insertions(+), 73 deletions(-) diff --git a/packages/data-render/package.json b/packages/data-render/package.json index 22fb813ea..16f6dc55b 100644 --- a/packages/data-render/package.json +++ b/packages/data-render/package.json @@ -1,6 +1,6 @@ { "name": "@xrenders/data-render", - "version": "1.0.0-alpha.1", + "version": "1.0.0-alpha.7", "description": "", "keywords": [ "DataView", @@ -25,8 +25,8 @@ "email": "tw93@qq.com" }, { - "name": "mankaiviky", - "email": "mankaiviky@163.com" + "name": "lhbxs", + "email": "596850703@qq.com" } ], "main": "lib/index.js", diff --git a/packages/data-render/src/models/resolver.tsx b/packages/data-render/src/models/resolver.tsx index 21d329556..2453c9ea6 100644 --- a/packages/data-render/src/models/resolver.tsx +++ b/packages/data-render/src/models/resolver.tsx @@ -20,12 +20,17 @@ const InnerHtml = (props: any) => { }; export default (props: any, parentData: any, addons: any) => { - const { dataKey, defaultValue, children, ...rest } = props; + const { data, dataKey, defaultValue, children, ...rest } = props; const { getDataFromKey, getSourceData, getMethod, getConfig, getWidget } = addons; const sourceData = getSourceData(); // 当组件配置 dataKey,根据 dataKey 获取服务端对应数据,否则继承父级数据 let value = dataKey ? getDataFromKey(dataKey, parentData, defaultValue) : defaultValue ?? parentData; + + // 如果有传人的数据,直接使用 + if (data !== undefined) { + value = data; + } // 解析函数表达式,替换值 const restProps = parseAllExpression(rest, { @@ -35,7 +40,7 @@ export default (props: any, parentData: any, addons: any) => { }); // console.log('before:', props, 'after:', restProps); - const { widget, data, showLevel: _showLevel, format, getCompProps, hidden, ...componentProps } = restProps; + const { widget, showLevel: _showLevel, format, getCompProps, hidden, ...componentProps } = restProps; if (hidden && typeof hidden === 'boolean') { return; @@ -57,11 +62,6 @@ export default (props: any, parentData: any, addons: any) => { return null; } - // 如果有传人的数据,直接使用 - if (data !== undefined) { - value = data; - } - // 数据进行格式化 if (['html'].includes(format?.type)) { value = ; diff --git a/packages/data-render/src/widgets/FButton/index.less b/packages/data-render/src/widgets/FButton/index.less index a0f17219a..709c2b24e 100644 --- a/packages/data-render/src/widgets/FButton/index.less +++ b/packages/data-render/src/widgets/FButton/index.less @@ -1,10 +1,10 @@ -.dtv-button { +.dr-button { height: 22px; padding: 0; line-height: 22px; } -.dtv-button-modal { +.dr-button-modal { .ant-modal-confirm-content { margin-left: 0 !important; overflow: auto; diff --git a/packages/data-render/src/widgets/FButton/index.tsx b/packages/data-render/src/widgets/FButton/index.tsx index 578153f06..c275435ea 100644 --- a/packages/data-render/src/widgets/FButton/index.tsx +++ b/packages/data-render/src/widgets/FButton/index.tsx @@ -106,7 +106,7 @@ const FButton: React.FC = (props) => { width: contentWidth, centered, okText, - className: 'dtv-button-modal', + className: 'dr-button-modal', ...modalProps, content: addons.renderer({ schema: children, data: modalData, addons }), }); @@ -203,7 +203,7 @@ const FButton: React.FC = (props) => { const text = content || data; const buttonProps: ButtonProps = { - className: combineClass('dtv-button', className), + className: combineClass('dr-button', className), type, target, href: eventType === 'iframe' ? undefined : href, diff --git a/packages/data-render/src/widgets/FButtonFold/index.less b/packages/data-render/src/widgets/FButtonFold/index.less index a0f17219a..709c2b24e 100644 --- a/packages/data-render/src/widgets/FButtonFold/index.less +++ b/packages/data-render/src/widgets/FButtonFold/index.less @@ -1,10 +1,10 @@ -.dtv-button { +.dr-button { height: 22px; padding: 0; line-height: 22px; } -.dtv-button-modal { +.dr-button-modal { .ant-modal-confirm-content { margin-left: 0 !important; overflow: auto; diff --git a/packages/data-render/src/widgets/FButtonFold/index.tsx b/packages/data-render/src/widgets/FButtonFold/index.tsx index caa861cff..c1581286f 100644 --- a/packages/data-render/src/widgets/FButtonFold/index.tsx +++ b/packages/data-render/src/widgets/FButtonFold/index.tsx @@ -36,7 +36,7 @@ const FButtonFold = (props: any) => { return ( <>