mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-24 02:28:12 +00:00
Merge branch 'feat/rax-simulator' into release/0.9.0
This commit is contained in:
commit
f7c90584fd
@ -24,7 +24,7 @@ import {
|
||||
import VisualDom from '../comp/visualDom';
|
||||
import AppContext from '../context/appContext';
|
||||
|
||||
// import CompWrapper from '../hoc/compWrapper';
|
||||
import CompWrapper from '../hoc/compWrapper';
|
||||
|
||||
const debug = Debug('engine:base');
|
||||
const DESIGN_MODE = {
|
||||
@ -85,8 +85,7 @@ export default class BaseEngine extends Component {
|
||||
console.warn(e);
|
||||
}
|
||||
|
||||
reloadDataSource = () =>
|
||||
new Promise((resolve, reject) => {
|
||||
reloadDataSource = () => new Promise((resolve, reject) => {
|
||||
debug('reload data source');
|
||||
if (!this.__dataHelper) {
|
||||
this.__showPlaceholder = false;
|
||||
@ -125,8 +124,8 @@ export default class BaseEngine extends Component {
|
||||
__bindCustomMethods = (props = this.props) => {
|
||||
const { __schema } = props;
|
||||
const customMethodsList = Object.keys(__schema.methods || {}) || [];
|
||||
this.__customMethodsList &&
|
||||
this.__customMethodsList.forEach((item) => {
|
||||
this.__customMethodsList
|
||||
&& this.__customMethodsList.forEach((item) => {
|
||||
if (!customMethodsList.includes(item)) {
|
||||
delete this[item];
|
||||
}
|
||||
@ -216,8 +215,7 @@ export default class BaseEngine extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
const { __appHelper: appHelper, __components: components = {}, __componentsMap: componentsMap = {} } =
|
||||
this.props || {};
|
||||
const { __appHelper: appHelper, __components: components = {}, __componentsMap: componentsMap = {} } = this.props || {};
|
||||
const { engine } = this.context || {};
|
||||
if (isJSExpression(schema)) {
|
||||
return parseExpression(schema, self);
|
||||
@ -228,9 +226,7 @@ export default class BaseEngine extends Component {
|
||||
}
|
||||
if (Array.isArray(schema)) {
|
||||
if (schema.length === 1) return this.__createVirtualDom(schema[0], self, parentInfo);
|
||||
return schema.map((item, idx) =>
|
||||
this.__createVirtualDom(item, self, parentInfo, item && item.__ctx && item.__ctx.lunaKey ? '' : idx),
|
||||
);
|
||||
return schema.map((item, idx) => this.__createVirtualDom(item, self, parentInfo, item && item.__ctx && item.__ctx.lunaKey ? '' : idx),);
|
||||
}
|
||||
|
||||
// 解析占位组件
|
||||
@ -309,7 +305,9 @@ export default class BaseEngine extends Component {
|
||||
},
|
||||
});
|
||||
// 对于可以获取到ref的组件做特殊处理
|
||||
if (acceptsRef(Comp)) {
|
||||
if (!acceptsRef(Comp)) {
|
||||
Comp = CompWrapper(Comp);
|
||||
}
|
||||
otherProps.ref = (ref) => {
|
||||
const refProps = props.ref;
|
||||
if (refProps && typeof refProps === 'string') {
|
||||
@ -317,7 +315,6 @@ export default class BaseEngine extends Component {
|
||||
}
|
||||
engine && engine.props.onCompGetRef(schema, ref);
|
||||
};
|
||||
}
|
||||
|
||||
// scope需要传入到组件上
|
||||
if (scopeKey && this.__compScopes[scopeKey]) {
|
||||
@ -345,12 +342,12 @@ export default class BaseEngine extends Component {
|
||||
);
|
||||
}
|
||||
|
||||
const renderComp = (props) => engine.createElement(
|
||||
const renderComp = (props) =>
|
||||
engine.createElement(
|
||||
Comp,
|
||||
props,
|
||||
(!isFileSchema(schema)
|
||||
&& !!schema.children
|
||||
&&
|
||||
(!isFileSchema(schema) &&
|
||||
!!schema.children &&
|
||||
this.__createVirtualDom(
|
||||
isJSExpression(schema.children) ? parseExpression(schema.children, self) : schema.children,
|
||||
self,
|
||||
@ -358,8 +355,8 @@ export default class BaseEngine extends Component {
|
||||
schema,
|
||||
Comp,
|
||||
},
|
||||
)) ||
|
||||
null,
|
||||
))
|
||||
|| null,
|
||||
);
|
||||
// 设计模式下的特殊处理
|
||||
if (engine && [DESIGN_MODE.EXTEND, DESIGN_MODE.BORDER].includes(engine.props.designMode)) {
|
||||
|
||||
@ -268,7 +268,7 @@ export function generateI18n(locale = 'zh-CN', messages = {}) {
|
||||
* @param {*} Comp 需要判断的组件
|
||||
*/
|
||||
export function acceptsRef(Comp) {
|
||||
return !!Comp;
|
||||
return Comp && Comp.prototype && Comp.prototype.setState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user