mirror of
				https://github.com/Tencent/tmagic-editor.git
				synced 2025-11-04 18:52:18 +08:00 
			
		
		
		
	feat(core): app添加dsl-change事件
This commit is contained in:
		
							parent
							
								
									3c66319b03
								
							
						
					
					
						commit
						a4d021d2fb
					
				@ -144,7 +144,12 @@ class App extends EventEmitter {
 | 
			
		||||
    this.dataSourceManager = createDataSourceManager(this, this.useMock);
 | 
			
		||||
 | 
			
		||||
    this.codeDsl = config.codeBlocks;
 | 
			
		||||
    this.setPage(curPage || this.page?.data?.id);
 | 
			
		||||
 | 
			
		||||
    const pageId = curPage || this.page?.data?.id;
 | 
			
		||||
 | 
			
		||||
    super.emit('dsl-change', { dsl: config, curPage: pageId });
 | 
			
		||||
 | 
			
		||||
    this.setPage(pageId);
 | 
			
		||||
 | 
			
		||||
    if (this.dataSourceManager) {
 | 
			
		||||
      const dataSourceList = Array.from(this.dataSourceManager.dataSourceMap.values());
 | 
			
		||||
@ -162,19 +167,22 @@ class App extends EventEmitter {
 | 
			
		||||
      return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    if (pageConfig === this.page?.data) return;
 | 
			
		||||
 | 
			
		||||
    this.page?.destroy();
 | 
			
		||||
    if (this.page) {
 | 
			
		||||
      if (pageConfig === this.page.data) return;
 | 
			
		||||
      this.page.destroy();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    this.page = new Page({
 | 
			
		||||
      config: pageConfig,
 | 
			
		||||
      app: this,
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    this.eventHelper?.removeNodeEvents();
 | 
			
		||||
    this.page.nodes.forEach((node) => {
 | 
			
		||||
      this.eventHelper?.bindNodeEvents(node);
 | 
			
		||||
    });
 | 
			
		||||
    if (this.eventHelper) {
 | 
			
		||||
      this.eventHelper.removeNodeEvents();
 | 
			
		||||
      for (const [, node] of this.page.nodes) {
 | 
			
		||||
        this.eventHelper.bindNodeEvents(node);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    super.emit('page-change', this.page);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user