fengxiang
2018-03-08 efe936a73370a55d4c3336fb9973a92fcf87efff
src/app/app.component.ts
@@ -1,9 +1,10 @@
import { element } from 'protractor';
import { LoginService } from '@business/services/http/login.service';
import { Component, HostBinding, OnInit } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { Router, NavigationEnd, NavigationStart } from '@angular/router';
import { ThemesService, SettingsService, TitleService } from '@delon/theme';
import { filter, map } from 'rxjs/operators';
import { filter } from 'rxjs/operators';
import * as $ from 'jquery';
@Component({
  selector: 'app-root',
  template: `<router-outlet></router-outlet>`
@@ -19,16 +20,38 @@
    private settings: SettingsService,
    private router: Router,
    private titleSrv: TitleService,
    private loginService:LoginService) {
    private loginService: LoginService) {
  }
  ngOnInit() {
    this.router.events.pipe(
            filter(evt => evt instanceof NavigationEnd),
            map(() => this.router.url)
        )
        .subscribe(url => {
            this.titleSrv.setTitleByUrl(url);
        });
    this.router.events
        .pipe(filter(evt => evt instanceof NavigationEnd))
        .subscribe(() => this.titleSrv.setTitle());
      this.router.events.pipe(
          filter(evt => evt instanceof NavigationStart)
      )
      .subscribe(() => {
          // 删除多余透明蒙版中元素
          const cdkOverlayContainer = $('.cdk-overlay-container');
          if (cdkOverlayContainer != null && cdkOverlayContainer.children().length > 1) {
            cdkOverlayContainer.children('div:first-child').nextAll().each(
               function(index, el) {
                    if ($(el).hasClass('cdk-overlay-backdrop-showing')) {
                      $(el).remove();
                    } else {
                      $(el).empty();
                    }
               }
            );
          }
          // 关闭静态蒙版弹窗
          if ($('.ant-modal-close').length > 0) {
              $('.ant-modal-close').click();
          }
          // 下拉按钮模拟点击
          if ($('.ant-select-open').length > 0) {
          $('.ant-select-open').click();
          }
      });
  }
}