mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-01-13 09:41:57 +00:00
fix: deep-parser 也只能应用在 vc 组件上
This commit is contained in:
parent
93b0bfd96f
commit
faac8293bf
@ -1,13 +1,18 @@
|
||||
import Env from './env';
|
||||
import Env from '../env';
|
||||
import { Node } from '@ali/lowcode-designer';
|
||||
import { isJSSlot, isI18nData, isJSExpression } from '@ali/lowcode-types';
|
||||
import { isPlainObject } from '@ali/lowcode-utils';
|
||||
import i18nUtil from './i18n-util';
|
||||
import i18nUtil from '../i18n-util';
|
||||
import { editor } from '@ali/lowcode-engine';
|
||||
import { isVariable } from './utils';
|
||||
import { isVariable } from '../utils';
|
||||
|
||||
// FIXME: 表达式使用 mock 值,未来live 模式直接使用原始值
|
||||
// TODO: designType
|
||||
export function deepValueParser(obj?: any): any {
|
||||
export function deepValueParser(obj: any, node: Node): any {
|
||||
// 如果不是 vc 体系,不做这个兼容处理
|
||||
if (!node.componentMeta.prototype) {
|
||||
return obj;
|
||||
}
|
||||
if (isJSExpression(obj)) {
|
||||
if (editor.get('designMode') === 'live') {
|
||||
return obj;
|
||||
@ -29,7 +34,7 @@ export function deepValueParser(obj?: any): any {
|
||||
return obj;
|
||||
}
|
||||
if (Array.isArray(obj)) {
|
||||
return obj.map((item) => deepValueParser(item));
|
||||
return obj.map((item) => deepValueParser(item, node));
|
||||
}
|
||||
if (isPlainObject(obj)) {
|
||||
if (isI18nData(obj)) {
|
||||
@ -50,7 +55,7 @@ export function deepValueParser(obj?: any): any {
|
||||
}
|
||||
const out: any = {};
|
||||
Object.keys(obj).forEach((key) => {
|
||||
out[key] = deepValueParser(obj[key]);
|
||||
out[key] = deepValueParser(obj[key], node);
|
||||
});
|
||||
return out;
|
||||
}
|
||||
@ -4,7 +4,7 @@ import { editor, designer, designerCabin } from '@ali/lowcode-engine';
|
||||
import bus from './bus';
|
||||
import { VE_EVENTS } from './base/const';
|
||||
|
||||
import { deepValueParser } from './deep-value-parser';
|
||||
import { deepValueParser } from './props-reducers/deep-value-reducer';
|
||||
import { liveEditingRule, liveEditingSaveHander } from './vc-live-editing';
|
||||
import {
|
||||
compatibleReducer,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import '../fixtures/window';
|
||||
import { deepValueParser } from '../../src/deep-value-parser';
|
||||
import { deepValueParser } from '../../src/props-reducers/deep-value-reducer';
|
||||
import { editor } from '../../src/reducers';
|
||||
|
||||
describe('deepValueParser 测试', () => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user