fix: 修复api适配器回显问题 (#8261)

* fix: 默认值回调函数支持select选项配置

* fix: 修复api适配器回显问题

---------

Co-authored-by: wutong25 <wutong25@baidu.com>
This commit is contained in:
wutong 2023-09-27 14:47:21 +08:00 committed by GitHub
parent 753ed430ca
commit ef97dab580
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 7 deletions

View File

@ -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,

View File

@ -136,11 +136,11 @@ export default class FunctionEditorControl extends React.Component<
body: '<span class="mtk1 bracket-highlighting-0">}</span>',
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
})}
})} */}
</>
);
}

View File

@ -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,12 +452,19 @@ setSchemaTpl(
} = config || {};
let curRendererSchema = rendererSchema;
if (useSelectMode && curRendererSchema && curRendererSchema.options) {
if (useSelectMode && curRendererSchema) {
if (typeof curRendererSchema === 'function') {
curRendererSchema = (schema: Schema) => ({
...rendererSchema(schema),
type: 'select'
});
} else if (curRendererSchema.options) {
curRendererSchema = {
...curRendererSchema,
type: 'select'
};
}
}
return {
type: 'group',