mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2025-12-16 15:01:15 +00:00
fix: fixed the issue that thisRequiredInJSE did not take effect in some scenarios
This commit is contained in:
parent
b216aa5d2b
commit
7e5a919f93
@ -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({
|
||||||
|
|||||||
@ -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) => {
|
||||||
@ -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 = '';
|
||||||
|
|||||||
@ -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);
|
||||||
|
|||||||
@ -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;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user