mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(data-source): 编辑器中迭代器容器中的容器添加组件并关联数据源后没有编译
This commit is contained in:
parent
2885e81c8b
commit
8aba06ac38
@ -246,9 +246,11 @@ class DataSourceManager extends EventEmitter {
|
|||||||
const ds = this.get(dsId);
|
const ds = this.get(dsId);
|
||||||
if (!ds) return nodes;
|
if (!ds) return nodes;
|
||||||
|
|
||||||
|
const inEditor = this.app.platform === 'editor';
|
||||||
|
|
||||||
const ctxData = createIteratorContentData(itemData, ds.id, keys, this.data);
|
const ctxData = createIteratorContentData(itemData, ds.id, keys, this.data);
|
||||||
|
|
||||||
const { deps = {}, condDeps = {} } = getDeps(ds.schema, nodes);
|
const { deps = {}, condDeps = {} } = getDeps(ds.schema, nodes, inEditor);
|
||||||
|
|
||||||
if (!Object.keys(deps).length && !Object.keys(condDeps).length) {
|
if (!Object.keys(deps).length && !Object.keys(condDeps).length) {
|
||||||
return nodes;
|
return nodes;
|
||||||
@ -261,7 +263,7 @@ class DataSourceManager extends EventEmitter {
|
|||||||
item,
|
item,
|
||||||
deps,
|
deps,
|
||||||
condDeps,
|
condDeps,
|
||||||
inEditor: this.app.platform === 'editor',
|
inEditor,
|
||||||
ctxData,
|
ctxData,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
@ -1,10 +1,30 @@
|
|||||||
import type { DataSourceSchema, MNode } from '@tmagic/core';
|
import type { DataSourceSchema, Id, MNode } from '@tmagic/core';
|
||||||
import { DSL_NODE_KEY_COPY_PREFIX, isDataSourceCondTarget, isDataSourceTarget, Target, Watcher } from '@tmagic/core';
|
import {
|
||||||
|
DSL_NODE_KEY_COPY_PREFIX,
|
||||||
|
isDataSourceCondTarget,
|
||||||
|
isDataSourceTarget,
|
||||||
|
Target,
|
||||||
|
traverseNode,
|
||||||
|
Watcher,
|
||||||
|
} from '@tmagic/core';
|
||||||
|
|
||||||
const cache = new Map();
|
const cache = new Map();
|
||||||
|
|
||||||
export const getDeps = (ds: DataSourceSchema, nodes: MNode[]) => {
|
export const getDeps = (ds: DataSourceSchema, nodes: MNode[], inEditor: boolean) => {
|
||||||
const cacheKey = `${ds.id}:${nodes.map((node) => node.id).join(':')}`;
|
let cacheKey: string;
|
||||||
|
|
||||||
|
if (inEditor) {
|
||||||
|
const ids: Id[] = [];
|
||||||
|
nodes.forEach((node) => {
|
||||||
|
traverseNode(node, (node) => {
|
||||||
|
ids.push(node.id);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
cacheKey = `${ds.id}:${ids.join(':')}`;
|
||||||
|
} else {
|
||||||
|
cacheKey = `${ds.id}:${nodes.map((node) => node.id).join(':')}`;
|
||||||
|
}
|
||||||
|
|
||||||
if (cache.has(cacheKey)) {
|
if (cache.has(cacheKey)) {
|
||||||
return cache.get(cacheKey);
|
return cache.get(cacheKey);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user