mirror of https://github.com/abpframework/abp.git
1 changed files with 35 additions and 31 deletions
@ -1,40 +1,44 @@ |
|||||
import { Injectable, effect, inject } from "@angular/core"; |
import { Injectable, effect, inject } from '@angular/core'; |
||||
import { Title } from "@angular/platform-browser"; |
import { toSignal } from '@angular/core/rxjs-interop'; |
||||
import { TitleStrategy, RouterStateSnapshot } from "@angular/router"; |
import { TitleStrategy, RouterStateSnapshot } from '@angular/router'; |
||||
import { ConfigStateService } from "./config-state.service"; |
import { Title } from '@angular/platform-browser'; |
||||
import { LocalizationService } from "./localization.service"; |
import { ConfigStateService } from './config-state.service'; |
||||
import { toSignal } from "@angular/core/rxjs-interop"; |
import { LocalizationService } from './localization.service'; |
||||
|
|
||||
@Injectable({ |
@Injectable({ |
||||
providedIn: 'root' |
providedIn: 'root', |
||||
}) |
}) |
||||
export class AbpTitleStrategy extends TitleStrategy { |
export class AbpTitleStrategy extends TitleStrategy { |
||||
protected readonly title = inject(Title); |
protected readonly title = inject(Title); |
||||
protected readonly configState = inject(ConfigStateService); |
protected readonly configState = inject(ConfigStateService); |
||||
protected readonly localizationService = inject(LocalizationService); |
protected readonly localizationService = inject(LocalizationService); |
||||
routerState: RouterStateSnapshot; |
protected routerState: RouterStateSnapshot; |
||||
projectName = toSignal(this.configState.getDeep$("localization.defaultResourceName"), { initialValue: "MyProjectName" }); |
|
||||
langugageChange = toSignal(this.localizationService.languageChange$); |
|
||||
|
|
||||
override updateTitle(routerState: RouterStateSnapshot) { |
projectName = toSignal(this.configState.getDeep$('localization.defaultResourceName'), { |
||||
let title = this.buildTitle(routerState); |
initialValue: 'MyProjectName', |
||||
this.routerState = routerState; |
}); |
||||
|
langugageChange = toSignal(this.localizationService.languageChange$); |
||||
|
|
||||
if (title === undefined) { |
constructor() { |
||||
this.title.setTitle(`${this.projectName()}`); |
super(); |
||||
return; |
effect(() => { |
||||
} |
if (this.langugageChange()) { |
||||
|
this.updateTitle(this.routerState); |
||||
|
} |
||||
|
}); |
||||
|
} |
||||
|
|
||||
const localizedTitle = this.localizationService.instant({ key: title, defaultValue: title }); |
override updateTitle(routerState: RouterStateSnapshot) { |
||||
this.title.setTitle(`${localizedTitle} | ${this.projectName()}`); |
let title = this.buildTitle(routerState); |
||||
} |
|
||||
|
|
||||
constructor() { |
if (!title) { |
||||
super(); |
this.title.setTitle(this.projectName()); |
||||
effect(() => { |
return; |
||||
if (this.langugageChange()) { |
|
||||
this.updateTitle(this.routerState); |
|
||||
} |
|
||||
}); |
|
||||
} |
} |
||||
} |
|
||||
|
this.routerState = routerState; |
||||
|
|
||||
|
const localizedTitle = this.localizationService.instant({ key: title, defaultValue: title }); |
||||
|
this.title.setTitle(`${localizedTitle} | ${this.projectName()}`); |
||||
|
} |
||||
|
} |
||||
|
|||||
Loading…
Reference in new issue