diff --git a/packages/abc/page-header/page-header.component.ts b/packages/abc/page-header/page-header.component.ts index 18bb483457..6d357f1404 100644 --- a/packages/abc/page-header/page-header.component.ts +++ b/packages/abc/page-header/page-header.component.ts @@ -7,6 +7,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + DestroyRef, ElementRef, Input, OnChanges, @@ -66,6 +67,7 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit { private readonly titleSrv = inject(TitleService, { optional: true }); private readonly reuseSrv = inject(ReuseTabService, { optional: true }); private readonly directionality = inject(Directionality, { optional: true }); + private readonly destroy$ = inject(DestroyRef); @ViewChild('conTpl', { static: false }) private conTpl!: ElementRef; @ViewChild('affix', { static: false }) private affix!: NzAffixComponent; @@ -206,7 +208,7 @@ export class PageHeaderComponent implements OnInit, OnChanges, AfterViewInit { ngOnInit(): void { this.dir = this.directionality?.value; - this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => { + this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => { this.dir = direction; this.cdr.detectChanges(); }); diff --git a/packages/abc/result/result.component.ts b/packages/abc/result/result.component.ts index 9e271c78a8..c6b975f12e 100644 --- a/packages/abc/result/result.component.ts +++ b/packages/abc/result/result.component.ts @@ -3,6 +3,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + DestroyRef, Input, OnInit, TemplateRef, @@ -31,6 +32,7 @@ import { NzIconDirective } from 'ng-zorro-antd/icon'; export class ResultComponent implements OnInit { private readonly cdr = inject(ChangeDetectorRef); private readonly directionality = inject(Directionality, { optional: true }); + private readonly destroy$ = inject(DestroyRef); _type = ''; _icon = ''; @@ -57,7 +59,7 @@ export class ResultComponent implements OnInit { ngOnInit(): void { this.dir = this.directionality?.value; - this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => { + this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => { this.dir = direction; this.cdr.detectChanges(); }); diff --git a/packages/form/src/sf.component.ts b/packages/form/src/sf.component.ts index ec68157dfb..2283c30430 100644 --- a/packages/form/src/sf.component.ts +++ b/packages/form/src/sf.component.ts @@ -4,26 +4,25 @@ import { ChangeDetectorRef, Component, EventEmitter, - Inject, Injector, Input, OnChanges, OnDestroy, OnInit, - Optional, Output, SimpleChange, SimpleChanges, TemplateRef, ViewEncapsulation, - booleanAttribute + booleanAttribute, + inject } from '@angular/core'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { DomSanitizer } from '@angular/platform-browser'; import { merge, Observable, filter } from 'rxjs'; import { ACLService } from '@delon/acl'; -import { AlainI18NService, ALAIN_I18N_TOKEN, DelonLocaleService, LocaleData } from '@delon/theme'; +import { ALAIN_I18N_TOKEN, DelonLocaleService, LocaleData } from '@delon/theme'; import { AlainConfigService, AlainSFConfig } from '@delon/util/config'; import { deepCopy } from '@delon/util/other'; import type { NzSafeAny } from 'ng-zorro-antd/core/types'; @@ -78,6 +77,15 @@ export function useFactory( encapsulation: ViewEncapsulation.None }) export class SFComponent implements OnInit, OnChanges, OnDestroy { + private readonly formPropertyFactory = inject(FormPropertyFactory); + private readonly terminator = inject(TerminatorService); + private readonly dom = inject(DomSanitizer); + private readonly cdr = inject(ChangeDetectorRef); + private readonly localeSrv = inject(DelonLocaleService); + private readonly aclSrv = inject(ACLService, { optional: true }); + private readonly i18nSrv = inject(ALAIN_I18N_TOKEN, { optional: true }); + private readonly platform = inject(Platform); + private _renders = new Map>(); private _item!: Record; private _valid = true; @@ -295,17 +303,7 @@ export class SFComponent implements OnInit, OnChanges, OnDestroy { this.formSubmit.emit(this.value); } - constructor( - private formPropertyFactory: FormPropertyFactory, - private terminator: TerminatorService, - private dom: DomSanitizer, - private cdr: ChangeDetectorRef, - private localeSrv: DelonLocaleService, - @Optional() private aclSrv: ACLService, - @Optional() @Inject(ALAIN_I18N_TOKEN) private i18nSrv: AlainI18NService, - cogSrv: AlainConfigService, - private platform: Platform - ) { + constructor(cogSrv: AlainConfigService) { this.options = mergeConfig(cogSrv); this.liveValidate = this.options.liveValidate as boolean; this.firstVisual = this.options.firstVisual as boolean; diff --git a/packages/theme/setting-drawer/setting-drawer.component.ts b/packages/theme/setting-drawer/setting-drawer.component.ts index eed356b164..810f443903 100644 --- a/packages/theme/setting-drawer/setting-drawer.component.ts +++ b/packages/theme/setting-drawer/setting-drawer.component.ts @@ -5,6 +5,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + DestroyRef, inject, Input, isDevMode, @@ -39,6 +40,7 @@ export class SettingDrawerComponent implements OnInit { private readonly ngZone = inject(NgZone); private readonly doc = inject(DOCUMENT); private readonly directionality = inject(Directionality, { optional: true }); + private readonly destroy$ = inject(DestroyRef); @Input({ transform: booleanAttribute }) autoApplyColor = true; @Input() compilingText = 'Compiling...'; @@ -71,7 +73,7 @@ export class SettingDrawerComponent implements OnInit { ngOnInit(): void { this.dir = this.directionality?.value; - this.directionality?.change.pipe(takeUntilDestroyed()).subscribe(direction => { + this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe(direction => { this.dir = direction; this.cdr.detectChanges(); }); diff --git a/packages/theme/theme-btn/theme-btn.component.ts b/packages/theme/theme-btn/theme-btn.component.ts index 6ab019705c..4f9388b30b 100644 --- a/packages/theme/theme-btn/theme-btn.component.ts +++ b/packages/theme/theme-btn/theme-btn.component.ts @@ -5,6 +5,7 @@ import { ChangeDetectionStrategy, ChangeDetectorRef, Component, + DestroyRef, EventEmitter, inject, InjectionToken, @@ -47,6 +48,7 @@ export class ThemeBtnComponent implements OnInit, OnDestroy { private readonly configSrv = inject(AlainConfigService); private readonly directionality = inject(Directionality, { optional: true }); private readonly cdr = inject(ChangeDetectorRef); + private readonly destroy$ = inject(DestroyRef); private theme = 'default'; isDev = isDevMode(); @@ -63,7 +65,7 @@ export class ThemeBtnComponent implements OnInit, OnDestroy { ngOnInit(): void { this.dir = this.directionality?.value; - this.directionality?.change.pipe(takeUntilDestroyed()).subscribe((direction: Direction) => { + this.directionality?.change.pipe(takeUntilDestroyed(this.destroy$)).subscribe((direction: Direction) => { this.dir = direction; this.cdr.detectChanges(); });