fengxiang
2018-07-11 5ff5fdaee98e8b2a0776ee5747292aa08a6b26df
打印ajax结果
3 files modified
27 ■■■■ changed files
src/app/app.component.ts 12 ●●●●● patch | view | raw | blame | history
src/app/delon.module.ts 2 ●●● patch | view | raw | blame | history
src/app/routes/home-page/home-page/home-page.component.ts 13 ●●●● patch | view | raw | blame | history
src/app/app.component.ts
@@ -1,7 +1,8 @@
import { Component, HostBinding, OnInit } from '@angular/core';
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',
@@ -25,9 +26,18 @@
    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());
src/app/delon.module.ts
@@ -35,7 +35,7 @@
export function delonAuthConfig(): DelonAuthConfig {
  return Object.assign(new DelonAuthConfig(), <DelonAuthConfig>{
    token_send_key : 'X-Authorization',
    token_send_template : 'Bearer eyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJhZG1pbiIsIm9pZCI6NSwibW9kZSI6IldlYiIsInNjb3BlcyI6WyJ0ZW1wIl0sImlzcyI6Imh0dHA6Ly9tb25pdG9yLjdkcmxiLmNvbSIsImlhdCI6MTUzMDg2NDIyNSwiZXhwIjoxNTM4NjQwMjI1fQ.QMhnq_01fSjCeMHMJwRgDnEWMuMshCxHff5J3s2fVPq_VDZC3Iid1ug9KSfWcBn8Ry03xitHTmkgnF1O_rckxA',
    token_send_template : 'Bearer ${token}',
    token_send_place : 'header',
    login_url: `/passport/login`,
    allow_anonymous_key: `_allow_anonymous`
src/app/routes/home-page/home-page/home-page.component.ts
@@ -1,4 +1,5 @@
import { Component, OnInit } from "@angular/core";
import { _HttpClient } from "@delon/theme";
@Component({
  selector: "app-home-page",
@@ -6,7 +7,15 @@
  styleUrls: ["./home-page.component.less"]
})
export class HomePageComponent implements OnInit {
  constructor() {}
  constructor(
    private http:_HttpClient
  ) {}
  ngOnInit() {}
  ngOnInit() {
     this.http.get('user-context').subscribe(
       res => {
         console.log(res);
       }
     );
  }
}