1
0
mirror of synced 2026-04-03 06:28:35 +08:00

feat(editor, core): 支持直接绑定整个数据源对象

This commit is contained in:
roymondchen
2023-06-28 16:39:47 +08:00
parent 649720079a
commit 74c9deaa29
11 changed files with 185 additions and 30 deletions

View File

@@ -243,7 +243,7 @@ export const replaceChildNode = (newNode: MNode, data?: MNode[], parentId?: Id)
};
export const compiledNode = (
compile: (template: string) => string,
compile: (value: any) => any,
node: MNode,
dataSourceDeps: DataSourceDeps = {},
sourceId?: Id,
@@ -263,12 +263,14 @@ export const compiledNode = (
const keyPathLength = keyPath.length;
keyPath.reduce((accumulator, currentValue: any, currentIndex) => {
if (keyPathLength - 1 === currentIndex) {
if (typeof accumulator[`${keyPrefix}${currentValue}`] === 'undefined') {
accumulator[`${keyPrefix}${currentValue}`] = accumulator[currentValue];
const cacheKey = `${keyPrefix}${currentValue}`;
if (typeof accumulator[cacheKey] === 'undefined') {
accumulator[cacheKey] = accumulator[currentValue];
}
try {
accumulator[currentValue] = compile(accumulator[`${keyPrefix}${currentValue}`]);
accumulator[currentValue] = compile(accumulator[cacheKey]);
} catch (e) {
console.error(e);
accumulator[currentValue] = '';