callback.component.ts 951 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Component, OnInit } from '@angular/core';
  2. import { ActivatedRoute } from '@angular/router';
  3. import { SocialService } from '@delon/auth';
  4. import { SettingsService } from '@delon/theme';
  5. @Component({
  6. selector: 'app-callback',
  7. template: ``,
  8. providers: [SocialService],
  9. })
  10. export class CallbackComponent implements OnInit {
  11. type: string;
  12. constructor(
  13. private socialService: SocialService,
  14. private settingsSrv: SettingsService,
  15. private route: ActivatedRoute,
  16. ) {}
  17. ngOnInit(): void {
  18. this.type = this.route.snapshot.params['type'];
  19. this.mockModel();
  20. }
  21. private mockModel() {
  22. const info = {
  23. token: '123456789',
  24. name: 'cipchk',
  25. email: `${this.type}@${this.type}.com`,
  26. id: 10000,
  27. time: +new Date(),
  28. };
  29. this.settingsSrv.setUser({
  30. ...this.settingsSrv.user,
  31. ...info,
  32. });
  33. this.socialService.callback(info);
  34. }
  35. }