mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-15 17:31:18 +08:00
修复 api 示例无法显示问题
Change-Id: Idc55248ad7475e48749030350aed8c08cfe48b2c
This commit is contained in:
parent
177b417f99
commit
45e7a3b5bc
@ -85,34 +85,6 @@ export class CRUDPlugin extends BasePlugin {
|
||||
}
|
||||
];
|
||||
|
||||
sampleBuilder = (schema: any) => {
|
||||
const data: any = {
|
||||
items: [],
|
||||
total: 0
|
||||
};
|
||||
|
||||
if (Array.isArray(schema?.columns)) {
|
||||
const item = {};
|
||||
schema.columns.forEach((control: any) => {
|
||||
if (control?.name) {
|
||||
setVariable(item, control.name, 'sample');
|
||||
}
|
||||
});
|
||||
|
||||
data.items.push(item);
|
||||
}
|
||||
|
||||
return JSON.stringify(
|
||||
{
|
||||
status: 0,
|
||||
msg: '',
|
||||
data: data
|
||||
},
|
||||
null,
|
||||
2
|
||||
);
|
||||
};
|
||||
|
||||
btnSchemas = {
|
||||
create: {
|
||||
label: '新增',
|
||||
|
@ -10,10 +10,7 @@ import {
|
||||
import {defaultValue, getSchemaTpl} from 'amis-editor-core';
|
||||
import {jsonToJsonSchema} from 'amis-editor-core';
|
||||
import {EditorNodeType} from 'amis-editor-core';
|
||||
import {
|
||||
RendererPluginAction,
|
||||
RendererPluginEvent
|
||||
} from 'amis-editor-core';
|
||||
import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core';
|
||||
import {setVariable} from 'amis-core';
|
||||
import {getEventControlConfig} from '../../renderer/event-control/helper';
|
||||
|
||||
@ -540,7 +537,7 @@ export class FormPlugin extends BasePlugin {
|
||||
getSchemaTpl('api', {
|
||||
label: '保存接口',
|
||||
description: '用来保存表单数据',
|
||||
sampleBuilder: (schema: any) => `{
|
||||
sampleBuilder: () => `{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
|
||||
@ -582,10 +579,11 @@ export class FormPlugin extends BasePlugin {
|
||||
name: 'initApi',
|
||||
label: '初始化接口',
|
||||
description: '用来初始化表单数据',
|
||||
sampleBuilder: (schema: any) => {
|
||||
sampleBuilder: () => {
|
||||
const data = {};
|
||||
const schema = context?.schema;
|
||||
|
||||
if (Array.isArray(schema.body)) {
|
||||
if (Array.isArray(schema?.body)) {
|
||||
schema.body.forEach((control: any) => {
|
||||
if (
|
||||
control.name &&
|
||||
|
@ -279,7 +279,7 @@ export class TreeControlPlugin extends BasePlugin {
|
||||
name: 'options'
|
||||
},
|
||||
getSchemaTpl('source', {
|
||||
sampleBuilder: (schema: any) =>
|
||||
sampleBuilder: () =>
|
||||
JSON.stringify(
|
||||
{
|
||||
status: 0,
|
||||
|
@ -1,7 +1,4 @@
|
||||
import {
|
||||
RendererPluginAction,
|
||||
RendererPluginEvent
|
||||
} from 'amis-editor-core';
|
||||
import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core';
|
||||
import {defaultValue, getSchemaTpl} from 'amis-editor-core';
|
||||
import {registerEditorPlugin} from 'amis-editor-core';
|
||||
import {BaseEventContext, BasePlugin} from 'amis-editor-core';
|
||||
@ -280,7 +277,7 @@ export class TreeSelectControlPlugin extends BasePlugin {
|
||||
},
|
||||
|
||||
getSchemaTpl('source', {
|
||||
sampleBuilder: (schema: any) =>
|
||||
sampleBuilder: () =>
|
||||
JSON.stringify(
|
||||
{
|
||||
status: 0,
|
||||
|
@ -3,10 +3,7 @@ import {registerEditorPlugin} from 'amis-editor-core';
|
||||
import {BaseEventContext, BasePlugin} from 'amis-editor-core';
|
||||
import {getSchemaTpl} from 'amis-editor-core';
|
||||
import {getEventControlConfig} from '../renderer/event-control/helper';
|
||||
import {
|
||||
RendererPluginAction,
|
||||
RendererPluginEvent
|
||||
} from 'amis-editor-core';
|
||||
import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core';
|
||||
import type {SchemaObject} from 'amis/lib/Schema';
|
||||
|
||||
export class PagePlugin extends BasePlugin {
|
||||
@ -176,7 +173,7 @@ export class PagePlugin extends BasePlugin {
|
||||
getSchemaTpl('api', {
|
||||
label: '数据初始化接口',
|
||||
name: 'initApi',
|
||||
sampleBuilder: (schema: any) => `{
|
||||
sampleBuilder: () => `{
|
||||
"status": 0,
|
||||
"msg": "",
|
||||
|
||||
|
@ -17,7 +17,7 @@ setSchemaTpl('api', (patch: any = {}) => {
|
||||
label: '示例',
|
||||
title: '接口返回示例',
|
||||
tooltipClassName: 'ae-ApiSample-tooltip',
|
||||
render: (data: any) => (
|
||||
children: (data: any) => (
|
||||
<Html
|
||||
className="ae-ApiSample"
|
||||
inline={false}
|
||||
@ -314,7 +314,7 @@ setSchemaTpl('source', (patch: any = {}) => {
|
||||
name: 'source',
|
||||
label: '获取选项接口',
|
||||
description: '可以通过接口获取动态选项,一次拉取全部。',
|
||||
sampleBuilder: (schema: any) =>
|
||||
sampleBuilder: () =>
|
||||
JSON.stringify(
|
||||
{
|
||||
status: 0,
|
||||
@ -423,7 +423,7 @@ setSchemaTpl('apiControl', (patch: any = {}) => {
|
||||
label: '示例',
|
||||
title: '接口返回示例',
|
||||
tooltipClassName: 'ae-ApiSample-tooltip',
|
||||
render: (data: any) => (
|
||||
children: (data: any) => (
|
||||
<Html
|
||||
className="ae-ApiSample"
|
||||
inline={false}
|
||||
@ -460,7 +460,7 @@ setSchemaTpl('actionApiControl', (patch: any = {}) => {
|
||||
label: '示例',
|
||||
title: '接口返回示例',
|
||||
tooltipClassName: 'ae-ApiSample-tooltip',
|
||||
render: (data: any) => (
|
||||
children: (data: any) => (
|
||||
<Html
|
||||
className="ae-ApiSample"
|
||||
inline={false}
|
||||
|
Loading…
Reference in New Issue
Block a user