Skip to content

Commit

Permalink
fix(data-source): 迭代内容多层嵌套下子组件条件配置不生效
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Aug 22, 2024
1 parent 162b2e0 commit e6f298a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 11 deletions.
17 changes: 7 additions & 10 deletions packages/data-source/src/DataSourceManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,20 +250,17 @@ class DataSourceManager extends EventEmitter {
return nodes;
}

return nodes.map((item) => {
const node = compliedIteratorItem({
return nodes.map((item) =>
compliedIteratorItem({
compile: (value: any) => compiledNodeField(value, ctxData),
dsId: ds.id,
item,
deps,
});

if (condDeps[node.id]?.keys.length && this.app.platform !== 'editor') {
node.condResult = compliedConditions(node, ctxData);
}

return node;
});
condDeps,
inEditor: this.app.platform === 'editor',
ctxData,
}),
);
}

public destroy() {
Expand Down
14 changes: 13 additions & 1 deletion packages/data-source/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,17 +191,29 @@ export const compliedIteratorItem = ({
dsId,
item,
deps,
condDeps,
inEditor,
ctxData,
}: {
compile: (value: any) => any;
dsId: string;
item: MNode;
deps: DepData;
condDeps: DepData;
inEditor: boolean;
ctxData: DataSourceManagerData;
}) => {
const { items, ...node } = item;
const newNode = cloneDeep(node);

if (condDeps[node.id]?.keys.length && !inEditor) {
newNode.condResult = compliedConditions(node, ctxData);
}

if (Array.isArray(items) && items.length) {
newNode.items = items.map((item) => compliedIteratorItem({ compile, dsId, item, deps }));
newNode.items = items.map((item) =>
compliedIteratorItem({ compile, dsId, item, deps, condDeps, inEditor, ctxData }),
);
} else if (items) {
newNode.items = items;
}
Expand Down

0 comments on commit e6f298a

Please sign in to comment.