mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-07 19:17:07 +00:00
fix: 修复 preset-vision 版本 lifeCycles 丢失以及 slot 初始化问题
This commit is contained in:
parent
58790c547c
commit
7cf6d24601
@ -71,6 +71,10 @@ export class Prop implements IPropParent {
|
||||
}
|
||||
|
||||
if (type === 'literal' || type === 'expression') {
|
||||
// TODO 后端改造之后删除此逻辑
|
||||
if (this._value === null && stage === TransformStage.Save) {
|
||||
return '';
|
||||
}
|
||||
return this._value;
|
||||
}
|
||||
|
||||
@ -181,7 +185,7 @@ export class Prop implements IPropParent {
|
||||
this._code = null;
|
||||
const t = typeof val;
|
||||
if (val == null) {
|
||||
this._value = undefined;
|
||||
// this._value = undefined;
|
||||
this._type = 'literal';
|
||||
} else if (t === 'string' || t === 'number' || t === 'boolean') {
|
||||
this._type = 'literal';
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { isJSBlock, isJSExpression, isJSSlot, isI18nData } from '@ali/lowcode-types';
|
||||
import { isPlainObject, hasOwnProperty } from '@ali/lowcode-utils';
|
||||
import { globalContext, Editor } from '@ali/lowcode-editor-core';
|
||||
import { Designer, LiveEditing, TransformStage, Node } from '@ali/lowcode-designer';
|
||||
import { Designer, LiveEditing, TransformStage, Node, getConvertedExtraKey } from '@ali/lowcode-designer';
|
||||
import Outline, { OutlineBackupPane, getTreeMaster } from '@ali/lowcode-plugin-outline-pane';
|
||||
import { toCss } from '@ali/vu-css-style';
|
||||
import logger from '@ali/vu-logger';
|
||||
@ -100,20 +100,8 @@ designer.addPropsReducer((props, node) => {
|
||||
// FIXME! item.name could be 'xxx.xxx'
|
||||
const ov = props[item.name];
|
||||
const v = item.initial(node as any, getRealValue(ov));
|
||||
if (!ov && v !== undefined) {
|
||||
if (isVariable(ov)) {
|
||||
newProps[item.name] = {
|
||||
...ov,
|
||||
value: v,
|
||||
};
|
||||
} else if (isJSExpression(ov)) {
|
||||
newProps[item.name] = {
|
||||
...ov,
|
||||
mock: v,
|
||||
};
|
||||
} else {
|
||||
newProps[item.name] = v;
|
||||
}
|
||||
if (ov === undefined && v !== undefined) {
|
||||
newProps[item.name] = v;
|
||||
}
|
||||
} catch (e) {
|
||||
if (hasOwnProperty(props, item.name)) {
|
||||
@ -130,6 +118,16 @@ designer.addPropsReducer((props, node) => {
|
||||
return props;
|
||||
}, TransformStage.Init);
|
||||
|
||||
designer.addPropsReducer((props: any, node: Node) => {
|
||||
if (node.isRoot() && props && props.lifeCycles) {
|
||||
return {
|
||||
...props,
|
||||
lifeCycles: {},
|
||||
}
|
||||
}
|
||||
return props;
|
||||
}, TransformStage.Render);
|
||||
|
||||
function filterReducer(props: any, node: Node): any {
|
||||
const filters = node.componentMeta.getMetadata().experimental?.filters;
|
||||
if (filters && filters.length) {
|
||||
@ -188,6 +186,20 @@ function compatiableReducer(props: any) {
|
||||
}
|
||||
// FIXME: Dirty fix, will remove this reducer
|
||||
designer.addPropsReducer(compatiableReducer, TransformStage.Save);
|
||||
// 兼容历史版本的 Page 组件
|
||||
designer.addPropsReducer((props: any, node: Node) => {
|
||||
const lifeCycleNames = ['didMount', 'willUnmount'];
|
||||
if (node.isRoot()) {
|
||||
lifeCycleNames.forEach(key => {
|
||||
if (props[key]) {
|
||||
const lifeCycles = node.props.getPropValue(getConvertedExtraKey('lifeCycles')) || {};
|
||||
lifeCycles[key] = props[key];
|
||||
node.props.setPropValue(getConvertedExtraKey('lifeCycles'), lifeCycles);
|
||||
}
|
||||
});
|
||||
}
|
||||
return props;
|
||||
}, TransformStage.Save);
|
||||
|
||||
// 设计器组件样式处理
|
||||
function stylePropsReducer(props: any, node: any) {
|
||||
|
||||
@ -43,7 +43,6 @@ const pages = Object.assign(project, {
|
||||
// FIXME
|
||||
if (componentsTree[0].componentName === 'Page' ||
|
||||
componentsTree[0].componentName === 'Component') {
|
||||
componentsTree[0].lifeCycles = {};
|
||||
componentsTree[0].methods = {};
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,5 +53,5 @@
|
||||
"ts-node/register"
|
||||
]
|
||||
},
|
||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@0.8.39/build/index.html"
|
||||
"homepage": "https://unpkg.alibaba-inc.com/@ali/lowcode-rax-simulator-renderer@0.8.40/build/index.html"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user