-
Notifications
You must be signed in to change notification settings - Fork 670
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(schematics): fix used translate when not i18n (#230)
- Loading branch information
Showing
4 changed files
with
58 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
...s/schematics/application/files/src/app/layout/default/header/components/user.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { Component, Inject } from '@angular/core'; | ||
import { Router } from '@angular/router'; | ||
import { SettingsService } from '@delon/theme'; | ||
import { DA_SERVICE_TOKEN, ITokenService } from '@delon/auth'; | ||
|
||
@Component({ | ||
selector: 'header-user', | ||
template: ` | ||
<nz-dropdown nzPlacement="bottomRight"> | ||
<div class="alain-default__nav-item d-flex align-items-center px-sm" nz-dropdown> | ||
<nz-avatar [nzSrc]="settings.user.avatar" nzSize="small" class="mr-sm"></nz-avatar> | ||
{{settings.user.name}} | ||
</div> | ||
<div nz-menu class="width-sm"> | ||
<div nz-menu-item routerLink="/pro/account/center"><i class="anticon anticon-user mr-sm"></i> | ||
<% if (i18n) { %>{{ 'menu.account.center' | translate }}<% } else { %>个人中心<% } %> | ||
</div> | ||
<div nz-menu-item routerLink="/pro/account/settings"><i class="anticon anticon-setting mr-sm"></i> | ||
<% if (i18n) { %>{{ 'menu.account.settings' | translate }}<% } else { %>个人设置<% } %> | ||
</div> | ||
<li nz-menu-divider></li> | ||
<div nz-menu-item (click)="logout()"><i class="anticon anticon-logout mr-sm"></i> | ||
<% if (i18n) { %>{{ 'menu.account.logout' | translate }}<% } else { %>退出登录<% } %> | ||
</div> | ||
</div> | ||
</nz-dropdown> | ||
`, | ||
}) | ||
export class HeaderUserComponent { | ||
constructor( | ||
public settings: SettingsService, | ||
private router: Router, | ||
@Inject(DA_SERVICE_TOKEN) private tokenService: ITokenService, | ||
) {} | ||
|
||
logout() { | ||
this.tokenService.clear(); | ||
this.router.navigateByUrl(this.tokenService.login_url); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters