import { Direction , Directionality } from '@angular/cdk/bidi' ; import { ChangeDetectionStrategy , Component , ContentChildren , Inject , Input , OnDestroy , OnInit , Optional , QueryList , ViewEncapsulation } from '@angular/core' ; import { DomSanitizer } from '@angular/platform-browser' ; import { Router } from '@angular/router' ; import { Subject } from 'rxjs' ; import { takeUntil } from 'rxjs/operators' ; import { WINDOW } from '@delon/util/token' ; import type { NzSafeAny } from 'ng-zorro-antd/core/types' ; import { GlobalFooterItemComponent } from './global-footer-item.component' ; import { GlobalFooterLink } from './global-footer.types' ; @ Component ( { selector : 'global-footer' , exportAs : 'globalFooter' , templateUrl : './global-footer.component.html' , host : { '[class.global-footer]' : 'true' , '[class.global-footer-rtl]' : `dir === 'rtl'` } , preserveWhitespaces : false , changeDetection : ChangeDetectionStrategy . OnPush , encapsulation : ViewEncapsulation . None } ) export class GlobalFooterComponent implements OnInit , OnDestroy { private destroy$ = new Subject < void > ( ) ; private _links : GlobalFooterLink [ ] = [ ] ; dir : Direction = 'ltr' ; @ Input ( ) set links ( val ) { val . forEach ( i => ( i . _title = this . dom . bypassSecurityTrustHtml ( i . title ) ) ) ; this . _links = val ; } get links ( ) : GlobalFooterLink [ ] { return this . _links ; } @ ContentChildren ( GlobalFooterItemComponent ) items ! : QueryList < GlobalFooterItemComponent > ; constructor ( private router , @ Inject ( WINDOW ) private win , private dom , @ Optional ( ) private directionality ) { } to ( item ) { if ( ! item . href ) { return ; } if ( item . blankTarget ) { this . win . open ( item . href ) ; return ; } if ( /^https?:\/\// . test ( item . href ) ) { this . win . location . href = item . href ; } else { this . router . navigateByUrl ( item . href ) ; } } ngOnInit ( ) { this . dir = this . directionality . value ; this . directionality . change ?. pipe ( takeUntil ( this . destroy$ ) ) . subscribe ( ( direction ) => { this . dir = direction ; } ) ; } ngOnDestroy ( ) { this . destroy$ . next ( ) ; this . destroy$ . complete ( ) ; } }