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) - [用户文档](https://lowcode-engine.cn/docV2)
- [API](https://lowcode-engine.cn/docV2/vlmeme) - [API](https://lowcode-engine.cn/docV2/vlmeme)
[awesome-lowcode-engine](https://github.com/lowcode-workspace/awesome-lowcode-engine) 中包含了一系列围绕引擎建设的工具、解决方案等,如果你有类似的解决方案或者工具,欢迎提 PR 到该仓库,让更多人了解到
## 💻 本地调试 ## 💻 本地调试
```bash ```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) - [User Documentation](http://lowcode-engine.cn/docV2)
- [API](http://lowcode-engine.cn/docV2/vlmeme) - [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 ## 💻 Local debugging
```bash ```bash

View File

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

View File

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

View File

@ -1,5 +1,4 @@
import baseRendererFactory from './base'; import baseRendererFactory from './base';
import { parseData } from '../utils';
import { IBaseRendererProps, IBaseRenderComponent } from '../types'; import { IBaseRendererProps, IBaseRenderComponent } from '../types';
export default function pageRendererFactory(): IBaseRenderComponent { export default function pageRendererFactory(): IBaseRenderComponent {
@ -21,8 +20,8 @@ export default function pageRendererFactory(): IBaseRenderComponent {
async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) { async componentDidUpdate(prevProps: IBaseRendererProps, _prevState: {}, snapshot: unknown) {
const { __ctx } = this.props; const { __ctx } = this.props;
const prevState = parseData(prevProps.__schema.state, __ctx); const prevState = this.__parseData(prevProps.__schema.state, __ctx);
const newState = parseData(this.props.__schema.state, __ctx); const newState = this.__parseData(this.props.__schema.state, __ctx);
// 当编排的时候修改schema.state值需要将最新schema.state值setState // 当编排的时候修改schema.state值需要将最新schema.state值setState
if (JSON.stringify(newState) != JSON.stringify(prevState)) { if (JSON.stringify(newState) != JSON.stringify(prevState)) {
this.setState(newState); 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)); 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)) { if (isJSExpression(schema)) {
return parseExpression(schema, self); return parseExpression(schema, self, options.thisRequiredInJSE);
} else if (isI18nData(schema)) { } else if (isI18nData(schema)) {
return parseI18n(schema, self); return parseI18n(schema, self);
} else if (typeof schema === 'string') { } else if (typeof schema === 'string') {
return schema.trim(); return schema.trim();
} else if (Array.isArray(schema)) { } 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') { } else if (typeof schema === 'function') {
return schema.bind(self); return schema.bind(self);
} else if (typeof schema === 'object') { } else if (typeof schema === 'object') {
@ -351,7 +351,7 @@ export function parseData(schema: unknown, self: any): any {
if (key.startsWith('__')) { if (key.startsWith('__')) {
return; return;
} }
res[key] = parseData(val, self); res[key] = parseData(val, self, options);
}); });
return res; return res;
} }