30 lines
932 B
TypeScript
30 lines
932 B
TypeScript
import { ChangeDetectionStrategy, Component, Inject, OnInit } from '@angular/core';
|
|
import { Router } from '@angular/router';
|
|
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth';
|
|
import { SettingsService } from '@delon/theme';
|
|
|
|
@Component({
|
|
selector: 'layout-pro-user',
|
|
templateUrl: 'user.component.html',
|
|
changeDetection: ChangeDetectionStrategy.OnPush
|
|
})
|
|
export class LayoutProWidgetUserComponent implements OnInit {
|
|
constructor(public settings: SettingsService, private router: Router, @Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService) {}
|
|
|
|
ngOnInit(): void {
|
|
// mock
|
|
const token = this.tokenService.get() || {
|
|
token: 'nothing',
|
|
name: 'Admin',
|
|
avatar: './assets/logo-color.svg',
|
|
email: 'cipchk@qq.com'
|
|
};
|
|
this.tokenService.set(token);
|
|
}
|
|
|
|
logout(): void {
|
|
this.tokenService.clear();
|
|
this.router.navigateByUrl(this.tokenService.login_url!);
|
|
}
|
|
}
|