mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-01 03:28:20 +08:00
merge:master
Change-Id: Id225d7db340ae1f542dab684aed594f2e61e3dba
This commit is contained in:
commit
8298dd2cd3
@ -39,12 +39,12 @@ export class AudioPlugin extends BasePlugin {
|
||||
tpl: '<p>当前为字段内容节点配置,选择上层还有更多的配置。</p>'
|
||||
}
|
||||
: null,
|
||||
{
|
||||
getSchemaTpl('audioUrl',{
|
||||
name: 'src',
|
||||
type: 'input-text',
|
||||
label: '音频地址',
|
||||
description: '支持获取变量如:<code>\\${audioSrc}</code>'
|
||||
},
|
||||
}),
|
||||
{
|
||||
type: 'select',
|
||||
name: 'rates',
|
||||
|
@ -901,8 +901,8 @@ export class FormPlugin extends BasePlugin {
|
||||
...jsonToJsonSchema(data)
|
||||
};
|
||||
|
||||
scope.removeSchema(jsonschema.$id);
|
||||
scope.addSchema(jsonschema);
|
||||
scope?.removeSchema(jsonschema.$id);
|
||||
scope?.addSchema(jsonschema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ import {getEventControlConfig} from '../renderer/event-control/helper';
|
||||
import {RendererPluginAction, RendererPluginEvent} from 'amis-editor-core';
|
||||
import type {SchemaObject} from 'amis/lib/Schema';
|
||||
import { tipedLabel } from '../component/BaseControl';
|
||||
import {jsonToJsonSchema, EditorNodeType} from 'amis-editor-core';
|
||||
|
||||
export class PagePlugin extends BasePlugin {
|
||||
// 关联渲染器名字
|
||||
@ -353,6 +354,19 @@ export class PagePlugin extends BasePlugin {
|
||||
])
|
||||
];
|
||||
};
|
||||
|
||||
rendererBeforeDispatchEvent(node: EditorNodeType, e: any, data: any) {
|
||||
if (e === 'inited') {
|
||||
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
|
||||
const jsonschema: any = {
|
||||
$id: 'pageInitedData',
|
||||
...jsonToJsonSchema(data)
|
||||
};
|
||||
|
||||
scope?.removeSchema(jsonschema.$id);
|
||||
scope?.addSchema(jsonschema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorPlugin(PagePlugin);
|
||||
|
@ -1,6 +1,6 @@
|
||||
import {Button} from 'amis';
|
||||
import React from 'react';
|
||||
import {registerEditorPlugin} from 'amis-editor-core';
|
||||
import {EditorNodeType, jsonToJsonSchema, registerEditorPlugin} from 'amis-editor-core';
|
||||
import {BaseEventContext, BasePlugin, RegionConfig} from 'amis-editor-core';
|
||||
import {getSchemaTpl} from 'amis-editor-core';
|
||||
import {getEventControlConfig} from '../renderer/event-control/helper';
|
||||
@ -222,6 +222,19 @@ export class ServicePlugin extends BasePlugin {
|
||||
}
|
||||
]);
|
||||
};
|
||||
|
||||
rendererBeforeDispatchEvent(node: EditorNodeType, e: any, data: any) {
|
||||
if (e === 'fetchInited') {
|
||||
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
|
||||
const jsonschema: any = {
|
||||
$id: 'serviceFetchInitedData',
|
||||
...jsonToJsonSchema(data)
|
||||
};
|
||||
|
||||
scope?.removeSchema(jsonschema.$id);
|
||||
scope?.addSchema(jsonschema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorPlugin(ServicePlugin);
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {registerEditorPlugin} from 'amis-editor-core';
|
||||
import {EditorNodeType, jsonToJsonSchema, registerEditorPlugin} from 'amis-editor-core';
|
||||
import {
|
||||
BaseEventContext,
|
||||
BasePlugin,
|
||||
@ -939,6 +939,19 @@ export class WizardPlugin extends BasePlugin {
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
rendererBeforeDispatchEvent(node: EditorNodeType, e: any, data: any) {
|
||||
if (e === 'inited') {
|
||||
const scope = this.manager.dataSchema.getScope(`${node.id}-${node.type}`);
|
||||
const jsonschema: any = {
|
||||
$id: 'wizardInitedData',
|
||||
...jsonToJsonSchema(data)
|
||||
};
|
||||
|
||||
scope?.removeSchema(jsonschema.$id);
|
||||
scope?.addSchema(jsonschema);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
registerEditorPlugin(WizardPlugin);
|
||||
|
@ -1149,7 +1149,7 @@ export const getEventControlConfig = (
|
||||
'id'
|
||||
);
|
||||
const dataSchema: any = await manager.getContextSchemas(
|
||||
schema.$$id,
|
||||
schema?.$$id,
|
||||
true
|
||||
);
|
||||
const dataSchemaIns = new DataSchema(dataSchema || []);
|
||||
|
@ -83,7 +83,6 @@ interface EventControlState {
|
||||
}
|
||||
| undefined;
|
||||
type: 'update' | 'add';
|
||||
rawVariables: ContextVariables[]; // 外部获取的上下文变量
|
||||
}
|
||||
|
||||
export class EventControl extends React.Component<
|
||||
@ -95,7 +94,6 @@ export class EventControl extends React.Component<
|
||||
[prop: string]: Sortable;
|
||||
} = {};
|
||||
drag?: HTMLElement | null;
|
||||
isUnmount: boolean;
|
||||
|
||||
constructor(props: EventControlProps) {
|
||||
super(props);
|
||||
@ -110,23 +108,16 @@ export class EventControl extends React.Component<
|
||||
eventPanelActive[event.eventName] = true;
|
||||
});
|
||||
|
||||
this.isUnmount = false;
|
||||
|
||||
this.state = {
|
||||
onEvent: value ?? this.generateEmptyDefault(pluginEvents),
|
||||
events: pluginEvents,
|
||||
eventPanelActive,
|
||||
showAcionDialog: false,
|
||||
actionData: undefined,
|
||||
rawVariables: [],
|
||||
type: 'add'
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.loadContextVariables();
|
||||
}
|
||||
|
||||
componentDidUpdate(
|
||||
prevProps: EventControlProps,
|
||||
prevState: EventControlState
|
||||
@ -142,26 +133,6 @@ export class EventControl extends React.Component<
|
||||
}
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.isUnmount = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上下文变量
|
||||
*/
|
||||
async loadContextVariables() {
|
||||
const {getContextSchemas} = this.props;
|
||||
|
||||
// 获取上下文变量
|
||||
if (getContextSchemas) {
|
||||
const dataSchemaIns = await getContextSchemas();
|
||||
const variables = dataSchemaIns?.getDataPropsAsOptions();
|
||||
if (!this.isUnmount) {
|
||||
this.setState({rawVariables: variables});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
generateEmptyDefault(events: RendererPluginEvent[]) {
|
||||
const onEvent: ActionEventConfig = {};
|
||||
events.forEach((event: RendererPluginEvent) => {
|
||||
@ -510,7 +481,14 @@ export class EventControl extends React.Component<
|
||||
actionTree,
|
||||
allComponents
|
||||
} = this.props;
|
||||
const {rawVariables} = this.state;
|
||||
|
||||
let rawVariables = [];
|
||||
// 获取绑定事件的组件上下文变量
|
||||
if (getContextSchemas) {
|
||||
const dataSchemaIns = await getContextSchemas();
|
||||
rawVariables = dataSchemaIns?.getDataPropsAsOptions();
|
||||
}
|
||||
|
||||
// 收集事件变量
|
||||
const eventVariables = this.getEventVariables(data);
|
||||
const variables = [...eventVariables, ...rawVariables];
|
||||
@ -533,7 +511,7 @@ export class EventControl extends React.Component<
|
||||
item => item.label === `${rendererName}变量`
|
||||
);
|
||||
setValueDs = curVariable?.children?.filter(
|
||||
item => item.value !== '$$id'
|
||||
(item: ContextVariables) => item.value !== '$$id'
|
||||
);
|
||||
}
|
||||
};
|
||||
|
@ -148,7 +148,7 @@ setSchemaTpl('labelHide', () =>
|
||||
pipeIn: (value: any) => value === false,
|
||||
pipeOut: (value: any) => (value === true ? false : ''),
|
||||
visibleOn:
|
||||
'__props__.formMode === "horizontal" || data.mode === "horizontal" || data.label === false'
|
||||
'this.__props__ && this.__props__.formMode === "horizontal" || data.mode === "horizontal" || data.label === false'
|
||||
})
|
||||
);
|
||||
|
||||
@ -717,6 +717,13 @@ setSchemaTpl('backgroundImageUrl', {
|
||||
label: '图片路径'
|
||||
});
|
||||
|
||||
setSchemaTpl('audioUrl', {
|
||||
type: 'input-text',
|
||||
label: '音频地址',
|
||||
name: 'src',
|
||||
description: '支持获取变量如:<code>\\${audioSrc}</code>'
|
||||
});
|
||||
|
||||
setSchemaTpl('fileUrl', {
|
||||
type: 'input-text',
|
||||
label: '文件'
|
||||
|
Loading…
Reference in New Issue
Block a user