fengxiang
2018-07-11 5ff5fdaee98e8b2a0776ee5747292aa08a6b26df
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
import { Component, HostBinding, OnInit, Inject } from '@angular/core';
import { Router, NavigationEnd } from '@angular/router';
import { SettingsService, TitleService } from '@delon/theme';
import { filter } from 'rxjs/operators';
import { DA_SERVICE_TOKEN, TokenService } from '@delon/auth';
 
@Component({
  selector: 'app-root',
  template: `<router-outlet></router-outlet>`,
})
export class AppComponent implements OnInit {
  @HostBinding('class.layout-fixed')
  get isFixed() {
    return this.settings.layout.fixed;
  }
  @HostBinding('class.layout-boxed')
  get isBoxed() {
    return this.settings.layout.boxed;
  }
  @HostBinding('class.aside-collapsed')
  get isCollapsed() {
    return this.settings.layout.collapsed;
  }
 
  constructor(
    private settings: SettingsService,
    private router: Router,
    private titleSrv: TitleService,
    @Inject(DA_SERVICE_TOKEN) private tokenService: TokenService, 
  ) {}
 
  ngOnInit() {
        // 设置Token信息
        this.tokenService.set({
          token: 'eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsIm9pZCI6NSwibW9kZSI6IldlYiIsInNjb3BlcyI6WyJ0ZW1wIl0sImlzcyI6Imh0dHA6Ly9tb25pdG9yLjdkcmxiLmNvbSIsImlhdCI6MTUzMTMxNjU4MCwiZXhwIjoxNTM5MDkyNTgwfQ.tWE7AqGfLwwK-nO1FUveJ8xKqpxitqG1GdhKHp9JDyRPjNDYX7ocgkEw0W2G8hKL_tJIjjrQ1pc0zvCmLTJ-pg',
          name: 'admin',
          email: `admin@qq.com`,
          id: 10000,
          time: +new Date(),
        });
    this.router.events
      .pipe(filter(evt => evt instanceof NavigationEnd))
      .subscribe(() => this.titleSrv.setTitle());
  }
}