mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 02:28:04 +08:00 
			
		
		
		
	fix(editor): 编辑器组件销毁后重置依赖收集
This commit is contained in:
		
							parent
							
								
									e234428965
								
							
						
					
					
						commit
						51ca1e60af
					
				@ -45,6 +45,7 @@ export const initServiceState = (
 | 
			
		||||
    codeBlockService,
 | 
			
		||||
    keybindingService,
 | 
			
		||||
    dataSourceService,
 | 
			
		||||
    depService,
 | 
			
		||||
  }: Services,
 | 
			
		||||
) => {
 | 
			
		||||
  // 初始值变化,重新设置节点信息
 | 
			
		||||
@ -203,6 +204,7 @@ export const initServiceState = (
 | 
			
		||||
    componentListService.resetState();
 | 
			
		||||
    codeBlockService.resetState();
 | 
			
		||||
    keybindingService.reset();
 | 
			
		||||
    depService.reset();
 | 
			
		||||
  });
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -176,6 +176,23 @@ class Dep extends BaseService {
 | 
			
		||||
    return super.once(eventName, listener as any);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public reset() {
 | 
			
		||||
    idleTask.removeAllListeners();
 | 
			
		||||
    idleTask.clearTasks();
 | 
			
		||||
 | 
			
		||||
    for (const type of Object.keys(this.watcher.getTargetsList())) {
 | 
			
		||||
      this.removeTargets(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.set('collecting', false);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public destroy() {
 | 
			
		||||
    this.removeAllListeners();
 | 
			
		||||
    this.reset();
 | 
			
		||||
    this.removeAllPlugins();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public emit<Name extends keyof DepEvents, Param extends DepEvents[Name]>(eventName: Name, ...args: Param) {
 | 
			
		||||
    return super.emit(eventName, ...args);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
@ -54,6 +54,7 @@ export class IdleTask<T = any> extends EventEmitter {
 | 
			
		||||
 | 
			
		||||
    this.hightLevelTaskList = [];
 | 
			
		||||
    this.taskList = [];
 | 
			
		||||
    this.taskHandle = null;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  public on<Name extends keyof IdleTaskEvents, Param extends IdleTaskEvents[Name]>(
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user