| | |
| | | import { element } from 'protractor'; |
| | | import { LoginService } from '@business/services/http/login.service'; |
| | | import { Component, HostBinding, OnInit, Inject } 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'; |
| | | import { TokenService, DA_SERVICE_TOKEN } from '@delon/auth'; |
| | | |
| | | @Component({ |
| | |
| | | private settings: SettingsService, |
| | | private router: Router, |
| | | private titleSrv: TitleService, |
| | | @Inject(DA_SERVICE_TOKEN) private tokenService: TokenService, |
| | | ) { |
| | | private loginService: LoginService, |
| | | @Inject(DA_SERVICE_TOKEN) private tokenService: TokenService) { |
| | | } |
| | | |
| | | ngOnInit() { |
| | | // 设置Token信息 |
| | | this.tokenService.set({ |
| | | token: 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsIm9pZCI6NSwibW9kZSI6IldlYiIsInNjb3BlcyI6WyJ0ZW1wIl0sImlzcyI6Imh0dHA6Ly9tb25pdG9yLjdkcmxiLmNvbSIsImlhdCI6MTUzMTMxNjU4MCwiZXhwIjoxNTM5MDkyNTgwfQ.tWE7AqGfLwwK-nO1FUveJ8xKqpxitqG1GdhKHp9JDyRPjNDYX7ocgkEw0W2G8hKL_tJIjjrQ1pc0zvCmLTJ-pg', |
| | | token: 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsIm9pZCI6NSwibW9kZSI6IldlYiIsInNjb3BlcyI6WyJ0ZW1wIl0sImlzcyI6Imh0dHA6Ly9tb25pdG9yLjdkcmxiLmNvbSIsImlhdCI6MTUzMTM4MTIyMiwiZXhwIjoxNTMxMzgxNTIyfQ.iIlgjuDQP1C2mOWUSd0DT6sKxg7Wavsu3oOiHxGf58BZmrwl3OEIFH71yHo9DbXTRWnm5QzEeyjdxLXcWBA3mQ', |
| | | name: 'admin', |
| | | email: `admin@qq.com`, |
| | | id: 10000, |
| | | time: +new Date(), |
| | | }); |
| | | |
| | | this.router.events |
| | | .pipe(filter(evt => evt instanceof NavigationEnd)) |
| | | .subscribe(() => this.titleSrv.setTitle()); |
| | | this.router.events.pipe( |
| | | filter(evt => evt instanceof NavigationEnd), |
| | | map(() => this.router.url) |
| | | ) |
| | | .subscribe(url => { |
| | | this.titleSrv.setTitleByUrl(url); |
| | | }); |
| | | filter(evt => evt instanceof NavigationStart) |
| | | ) |
| | | .subscribe(() => { |
| | | // 关闭静态蒙版弹窗 |
| | | if ($('.ant-modal-close').length > 0) { |
| | | $('.ant-modal-close').click(); |
| | | } |
| | | // 下拉按钮模拟点击 |
| | | if ($('.ant-select-open').length > 0) { |
| | | $('.ant-select-open').click(); |
| | | } |
| | | // 删除多余透明蒙版中元素 |
| | | const cdkOverlayContainer = $('.cdk-overlay-container'); |
| | | if (cdkOverlayContainer != null && cdkOverlayContainer.children().length > 2) { |
| | | cdkOverlayContainer.children('div:first-child').next().nextAll().each( |
| | | function (index, el) { |
| | | if ($(el).hasClass('cdk-overlay-backdrop-showing')) { |
| | | $(el).remove(); |
| | | } else { |
| | | $(el).empty(); |
| | | } |
| | | } |
| | | ); |
| | | } |
| | | |
| | | }); |
| | | } |
| | | } |