mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-03-17 11:13:50 +00:00
feat: JSexpression props
This commit is contained in:
parent
b9103a225b
commit
26f4fb132e
@ -2,6 +2,7 @@ import Env from './env';
|
|||||||
import { isJSSlot, isI18nData, isJSExpression } from '@ali/lowcode-types';
|
import { isJSSlot, isI18nData, isJSExpression } from '@ali/lowcode-types';
|
||||||
import { isPlainObject } from '@ali/lowcode-utils';
|
import { isPlainObject } from '@ali/lowcode-utils';
|
||||||
import i18nUtil from './i18n-util';
|
import i18nUtil from './i18n-util';
|
||||||
|
import { editor } from './editor';
|
||||||
|
|
||||||
function isVariable(obj: any) {
|
function isVariable(obj: any) {
|
||||||
return obj && obj.type === 'variable';
|
return obj && obj.type === 'variable';
|
||||||
@ -9,6 +10,10 @@ function isVariable(obj: any) {
|
|||||||
|
|
||||||
// FIXME: 表达式使用 mock 值,未来live 模式直接使用原始值
|
// FIXME: 表达式使用 mock 值,未来live 模式直接使用原始值
|
||||||
export function deepValueParser(obj?: any): any {
|
export function deepValueParser(obj?: any): any {
|
||||||
|
// live
|
||||||
|
if (editor.get('designMode') === 'live') {
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
if (isJSExpression(obj)) {
|
if (isJSExpression(obj)) {
|
||||||
obj = obj.mock;
|
obj = obj.mock;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -87,6 +87,7 @@ designer.addPropsReducer(upgradePropsReducer, TransformStage.Upgrade);
|
|||||||
|
|
||||||
// 节点 props 初始化
|
// 节点 props 初始化
|
||||||
designer.addPropsReducer((props, node) => {
|
designer.addPropsReducer((props, node) => {
|
||||||
|
// debugger;
|
||||||
// run initials
|
// run initials
|
||||||
const newProps: any = {
|
const newProps: any = {
|
||||||
...props,
|
...props,
|
||||||
|
|||||||
@ -47,7 +47,6 @@ const pages = Object.assign(project, {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
debugger;
|
|
||||||
project.load({
|
project.load({
|
||||||
version: '1.0.0',
|
version: '1.0.0',
|
||||||
componentsMap: [],
|
componentsMap: [],
|
||||||
|
|||||||
@ -205,7 +205,6 @@ export default class BaseEngine extends Component {
|
|||||||
// parentInfo 父组件的信息,包含schema和Comp
|
// parentInfo 父组件的信息,包含schema和Comp
|
||||||
// idx 若为循环渲染的循环Index
|
// idx 若为循环渲染的循环Index
|
||||||
__createVirtualDom = (schema, self, parentInfo, idx) => {
|
__createVirtualDom = (schema, self, parentInfo, idx) => {
|
||||||
|
|
||||||
if (!schema) return null;
|
if (!schema) return null;
|
||||||
// rax text prop 兼容处理
|
// rax text prop 兼容处理
|
||||||
if (schema.componentName === 'Text') {
|
if (schema.componentName === 'Text') {
|
||||||
|
|||||||
@ -22,6 +22,7 @@ export default class PageEngine extends BaseEngine {
|
|||||||
static contextType = AppContext;
|
static contextType = AppContext;
|
||||||
|
|
||||||
static getDerivedStateFromProps(props, state) {
|
static getDerivedStateFromProps(props, state) {
|
||||||
|
debugger;
|
||||||
debug('page.getDerivedStateFromProps');
|
debug('page.getDerivedStateFromProps');
|
||||||
const func = props.__schema.lifeCycles && props.__schema.lifeCycles.getDerivedStateFromProps;
|
const func = props.__schema.lifeCycles && props.__schema.lifeCycles.getDerivedStateFromProps;
|
||||||
if (func) {
|
if (func) {
|
||||||
|
|||||||
@ -165,7 +165,7 @@ class Renderer extends Component<{
|
|||||||
<RaxEngine
|
<RaxEngine
|
||||||
schema={documentInstance.schema}
|
schema={documentInstance.schema}
|
||||||
components={renderer.components}
|
components={renderer.components}
|
||||||
context={renderer.context}
|
appHelper={renderer.context}
|
||||||
designMode={renderer.designMode}
|
designMode={renderer.designMode}
|
||||||
suspended={documentInstance.suspended}
|
suspended={documentInstance.suspended}
|
||||||
self={documentInstance.scope}
|
self={documentInstance.scope}
|
||||||
|
|||||||
@ -303,8 +303,8 @@ export class SimulatorRendererContainer implements BuiltinSimulatorRenderer {
|
|||||||
getUrlParams() {
|
getUrlParams() {
|
||||||
const search = history.location.search;
|
const search = history.location.search;
|
||||||
return parseQuery(search);
|
return parseQuery(search);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
constants: {},
|
constants: {},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user