fix(editor): 更新组件配置后,如果当前没有任何依赖,不会触发收集,导致画布不更新

This commit is contained in:
roymondchen 2024-10-09 15:04:25 +08:00 committed by roymondchen
parent 6521fdc988
commit d33ddcfa65

View File

@ -79,7 +79,9 @@ class Dep extends BaseService {
}
public collectIdle(nodes: MNode[], depExtendedData: DepExtendedData = {}, deep = false, type?: DepTargetType) {
let startTask = false;
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
startTask = true;
idleTask.enqueueTask(
({ node, deep, target }) => {
this.collectNode(node, target, depExtendedData, deep);
@ -93,6 +95,11 @@ class Dep extends BaseService {
});
return new Promise<void>((resolve) => {
if (!startTask) {
this.emit('collected', nodes, deep);
resolve();
return;
}
idleTask.once('finish', () => {
this.emit('collected', nodes, deep);
resolve();