Merge branch 'develop' into release/1.0.11-beta.0

This commit is contained in:
liujuping 2022-06-24 15:19:30 +08:00
commit 1aa39b4269
6 changed files with 18 additions and 14 deletions

View File

@ -125,6 +125,8 @@ https://cdn.jsdelivr.net/npm/@alilc/lowcode-react-simulator-renderer@1.0.0/dist/
- [用户文档](https://lowcode-engine.cn/docV2)
- [API](https://lowcode-engine.cn/docV2/vlmeme)
[awesome-lowcode-engine](https://github.com/lowcode-workspace/awesome-lowcode-engine) 中包含了一系列围绕引擎建设的工具、解决方案等,如果你有类似的解决方案或者工具,欢迎提 PR 到该仓库,让更多人了解到
## 💻 本地调试
```bash

View File

@ -125,6 +125,8 @@ Pass the files under packages/engine/dist and packages/(react|rax)-simulator-ren
- [User Documentation](http://lowcode-engine.cn/docV2)
- [API](http://lowcode-engine.cn/docV2/vlmeme)
This [awesome-lowcode-engine](https://github.com/lowcode-workspace/awesome-lowcode-engine) page links to a repository which records all of the tools\materials\solutions that use or built for the lowcode-engine, PR is welcomed.
## 💻 Local debugging
```bash

View File

@ -141,6 +141,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
__debug,
__getComponentProps: getProps,
__getSchemaChildrenVirtualDom: getChildren,
__parseData,
} = baseRenderer;
const { engine } = baseRenderer.context;
const host = baseRenderer.props?.__host;
@ -225,7 +226,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
nodeChildren: null,
childrenInState: false,
visible: !hidden,
condition: parseData(condition, scope),
condition: __parseData(condition, scope),
nodeCacheProps: {},
nodeProps: {},
};
@ -395,7 +396,7 @@ export function leafWrapper(Comp: types.IBaseRenderComponent, {
if (key === '___condition___') {
const { condition = true } = this.leaf?.export(TransformStage.Render) || {};
const conditionValue = parseData(condition, scope);
const conditionValue = __parseData(condition, scope);
__debug(`key is ___condition___, change condition value to [${condition}]`);
// 条件表达式改变
this.setState({

View File

@ -245,8 +245,8 @@ export default function baseRendererFactory(): IBaseRenderComponent {
};
__parseData = (data: any, ctx?: Record<string, any>) => {
const { __ctx } = this.props;
return parseData(data, ctx || __ctx || this);
const { __ctx, thisRequiredInJSE } = this.props;
return parseData(data, ctx || __ctx || this, { thisRequiredInJSE });
};
__initDataSource = (props = this.props) => {
@ -260,7 +260,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
this.__dataHelper = {
updateConfig: (updateDataSource: any) => {
const { dataSourceMap, reloadDataSource } = createDataSourceEngine(
updateDataSource,
updateDataSource ?? {},
this,
props.__appHelper.requestHandlersMap ? { requestHandlersMap: props.__appHelper.requestHandlersMap } : undefined,
);
@ -479,7 +479,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
const displayInHook = engine?.props?.designMode === 'design';
if (schema.loop != null) {
const loop = parseData(schema.loop, scope);
const loop = this.__parseData(schema.loop, scope);
const useLoop = isUseLoop(loop, this._designModeIsDesign);
if (useLoop) {
return this.__createLoopVirtualDom(
@ -493,7 +493,7 @@ export default function baseRendererFactory(): IBaseRenderComponent {
);
}
}
const condition = schema.condition == null ? true : parseData(schema.condition, scope);
const condition = schema.condition == null ? true : this.__parseData(schema.condition, scope);
if (!condition && !displayInHook) return null;
let scopeKey = '';

View File

@ -1,5 +1,4 @@
import baseRendererFactory from './base';
import { parseData } from '../utils';
import { IBaseRendererProps, IBaseRenderComponent } from '../types';
export default function pageRendererFactory(): IBaseRenderComponent {
@ -21,8 +20,8 @@ export default function pageRendererFactory(): IBaseRenderComponent {
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
const { __ctx } = this.props;
const prevState = parseData(prevProps.__schema.state, __ctx);
const newState = parseData(this.props.__schema.state, __ctx);
const prevState = this.__parseData(prevProps.__schema.state, __ctx);
const newState = this.__parseData(this.props.__schema.state, __ctx);
// 当编排的时候修改schema.state值需要将最新schema.state值setState
if (JSON.stringify(newState) != JSON.stringify(prevState)) {
this.setState(newState);

View File

@ -330,15 +330,15 @@ export function forEach(targetObj: any, fn: any, context?: any) {
Object.keys(targetObj).forEach((key) => fn.call(context, targetObj[key], key));
}
export function parseData(schema: unknown, self: any): any {
export function parseData(schema: unknown, self: any, options: any): any {
if (isJSExpression(schema)) {
return parseExpression(schema, self);
return parseExpression(schema, self, options.thisRequiredInJSE);
} else if (isI18nData(schema)) {
return parseI18n(schema, self);
} else if (typeof schema === 'string') {
return schema.trim();
} else if (Array.isArray(schema)) {
return schema.map((item) => parseData(item, self));
return schema.map((item) => parseData(item, self, options));
} else if (typeof schema === 'function') {
return schema.bind(self);
} else if (typeof schema === 'object') {
@ -351,7 +351,7 @@ export function parseData(schema: unknown, self: any): any {
if (key.startsWith('__')) {
return;
}
res[key] = parseData(val, self);
res[key] = parseData(val, self, options);
});
return res;
}