feat: JSexpression props

This commit is contained in:
wanying.jwy 2020-08-19 16:24:02 +08:00
parent b9103a225b
commit 26f4fb132e
7 changed files with 10 additions and 5 deletions

View File

@ -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;
} }

View File

@ -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,

View File

@ -47,7 +47,6 @@ const pages = Object.assign(project, {
} }
} }
} }
debugger;
project.load({ project.load({
version: '1.0.0', version: '1.0.0',
componentsMap: [], componentsMap: [],

View File

@ -205,7 +205,6 @@ export default class BaseEngine extends Component {
// parentInfo schemaComp // parentInfo schemaComp
// 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') {

View File

@ -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) {

View File

@ -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}

View File

@ -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: {},
}; };