From ef97dab580dc5b7fb986b9a86337e86412912a36 Mon Sep 17 00:00:00 2001 From: wutong <34541195+igrowp@users.noreply.github.com> Date: Wed, 27 Sep 2023 14:47:21 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dapi=E9=80=82=E9=85=8D?= =?UTF-8?q?=E5=99=A8=E5=9B=9E=E6=98=BE=E9=97=AE=E9=A2=98=20(#8261)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 默认值回调函数支持select选项配置 * fix: 修复api适配器回显问题 --------- Co-authored-by: wutong25 --- .../src/renderer/APIAdaptorControl.tsx | 1 + .../src/renderer/FunctionEditorControl.tsx | 4 ++-- packages/amis-editor/src/tpl/common.tsx | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/packages/amis-editor/src/renderer/APIAdaptorControl.tsx b/packages/amis-editor/src/renderer/APIAdaptorControl.tsx index 442c0511f..d7d23478d 100644 --- a/packages/amis-editor/src/renderer/APIAdaptorControl.tsx +++ b/packages/amis-editor/src/renderer/APIAdaptorControl.tsx @@ -115,6 +115,7 @@ export default class APIAdaptorControl extends React.Component< 'api-adaptor-control-editor', { type: 'ae-functionEditorControl', + name: 'functionEditorControl', placeholder: editorPlaceholder, desc: editorDesc, allowFullscreen, diff --git a/packages/amis-editor/src/renderer/FunctionEditorControl.tsx b/packages/amis-editor/src/renderer/FunctionEditorControl.tsx index 2447a0913..a057f5884 100644 --- a/packages/amis-editor/src/renderer/FunctionEditorControl.tsx +++ b/packages/amis-editor/src/renderer/FunctionEditorControl.tsx @@ -136,11 +136,11 @@ export default class FunctionEditorControl extends React.Component< body: '}', className: 'ae-FunctionEditorControl-func-footer' })} - {render('api-function-editor-control-editor/3', { + {/* {render('api-function-editor-control-editor/3', { type: 'container', className: 'cxd-Form-description', body: desc - })} + })} */} ); } diff --git a/packages/amis-editor/src/tpl/common.tsx b/packages/amis-editor/src/tpl/common.tsx index 30a1fe32e..e1d2ac36c 100644 --- a/packages/amis-editor/src/tpl/common.tsx +++ b/packages/amis-editor/src/tpl/common.tsx @@ -15,6 +15,7 @@ import reduce from 'lodash/reduce'; import map from 'lodash/map'; import omit from 'lodash/omit'; import keys from 'lodash/keys'; +import type {Schema} from 'amis'; import type {DSField} from '../builder'; @@ -451,11 +452,18 @@ setSchemaTpl( } = config || {}; let curRendererSchema = rendererSchema; - if (useSelectMode && curRendererSchema && curRendererSchema.options) { - curRendererSchema = { - ...curRendererSchema, - type: 'select' - }; + if (useSelectMode && curRendererSchema) { + if (typeof curRendererSchema === 'function') { + curRendererSchema = (schema: Schema) => ({ + ...rendererSchema(schema), + type: 'select' + }); + } else if (curRendererSchema.options) { + curRendererSchema = { + ...curRendererSchema, + type: 'select' + }; + } } return {