mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-09 01:18:50 +00:00
fix(vision): 兼容原 vision proto transducers 功能
This commit is contained in:
parent
cec923b8ff
commit
2ba28f928a
@ -107,6 +107,7 @@ export class Props implements IPropParent {
|
|||||||
if (this.items.length < 1) {
|
if (this.items.length < 1) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
let allProps = {} as any;
|
||||||
let props: any = {};
|
let props: any = {};
|
||||||
const extras: any = {};
|
const extras: any = {};
|
||||||
if (this.type === 'list') {
|
if (this.type === 'list') {
|
||||||
@ -139,6 +140,12 @@ export class Props implements IPropParent {
|
|||||||
if (value === UNSET) {
|
if (value === UNSET) {
|
||||||
value = undefined;
|
value = undefined;
|
||||||
}
|
}
|
||||||
|
allProps[name] = value;
|
||||||
|
});
|
||||||
|
// compatible vision
|
||||||
|
const transformedProps = this.transformToStatic(allProps);
|
||||||
|
Object.keys(transformedProps).forEach((name) => {
|
||||||
|
const value = transformedProps[name];
|
||||||
if (typeof name === 'string' && name.startsWith(EXTRA_KEY_PREFIX)) {
|
if (typeof name === 'string' && name.startsWith(EXTRA_KEY_PREFIX)) {
|
||||||
name = getOriginalExtraKey(name);
|
name = getOriginalExtraKey(name);
|
||||||
extras[name] = value;
|
extras[name] = value;
|
||||||
@ -151,6 +158,26 @@ export class Props implements IPropParent {
|
|||||||
return { props, extras };
|
return { props, extras };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
|
private transformToStatic(props: any) {
|
||||||
|
let transducers = this.owner.componentMeta.prototype?.options?.transducers;
|
||||||
|
if (!transducers) {
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
if (!Array.isArray(transducers)) {
|
||||||
|
transducers = [transducers];
|
||||||
|
}
|
||||||
|
props = transducers.reduce((xprops: any, transducer: any) => {
|
||||||
|
if (transducer && typeof transducer.toStatic === 'function') {
|
||||||
|
return transducer.toStatic(xprops);
|
||||||
|
}
|
||||||
|
return xprops;
|
||||||
|
}, props);
|
||||||
|
return props;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据 path 路径查询属性
|
* 根据 path 路径查询属性
|
||||||
*
|
*
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user