mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 01:21:58 +00:00
fix: 升级和降级 schema 的操作都跳过数组, 因为 dataSource 和 ListSetter 都依赖了乐高的 schema 结构
This commit is contained in:
parent
fa35fa4a81
commit
1c430a2e66
@ -9,12 +9,9 @@ export function compatibleReducer(props: any, node: Node): any {
|
||||
if (!node.componentMeta.prototype) {
|
||||
return props;
|
||||
}
|
||||
if (!props || !(isPlainObject(props) || Array.isArray(props))) {
|
||||
if (!props || !isPlainObject(props)) {
|
||||
return props;
|
||||
}
|
||||
if (Array.isArray(props)) {
|
||||
return props.map(k => compatibleReducer(k, node));
|
||||
}
|
||||
// 为了能降级到老版本,建议在后期版本去掉以下代码
|
||||
if (isJSSlot(props)) {
|
||||
return {
|
||||
|
||||
@ -1,10 +1,43 @@
|
||||
import { Node } from '@ali/lowcode-designer';
|
||||
import { compatibleLegaoSchema } from '@ali/lowcode-utils';
|
||||
import { isPlainObject, isVariable } from '@ali/lowcode-utils';
|
||||
import { isJSBlock } from '@ali/lowcode-types';
|
||||
import { designerCabin } from '@ali/lowcode-engine';
|
||||
|
||||
const { getConvertedExtraKey } = designerCabin;
|
||||
|
||||
export const upgradePropsReducer = compatibleLegaoSchema;
|
||||
export function upgradePropsReducer(props: any): any {
|
||||
if (!props || !isPlainObject(props)) {
|
||||
return props;
|
||||
}
|
||||
|
||||
if (isJSBlock(props)) {
|
||||
if (props.value.componentName === 'Slot') {
|
||||
return {
|
||||
type: 'JSSlot',
|
||||
title: (props.value.props as any)?.slotTitle,
|
||||
name: (props.value.props as any)?.slotName,
|
||||
value: props.value.children,
|
||||
};
|
||||
} else {
|
||||
return props.value;
|
||||
}
|
||||
}
|
||||
if (isVariable(props)) {
|
||||
return {
|
||||
type: 'JSExpression',
|
||||
value: props.variable,
|
||||
mock: props.value,
|
||||
};
|
||||
}
|
||||
const newProps: any = {};
|
||||
Object.keys(props).forEach((key) => {
|
||||
if (/^__slot__/.test(key) && props[key] === true) {
|
||||
return;
|
||||
}
|
||||
newProps[key] = upgradePropsReducer(props[key]);
|
||||
});
|
||||
return newProps;
|
||||
}
|
||||
|
||||
export function upgradePageLifeCyclesReducer(props: any, node: Node) {
|
||||
const lifeCycleNames = ['didMount', 'willUnmount'];
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user