项目初始化
This commit is contained in:
29
src/app/layout/pro/components/user/user.component.ts
Normal file
29
src/app/layout/pro/components/user/user.component.ts
Normal file
@ -0,0 +1,29 @@
|
||||
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!);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user