From c448d0e946ef4c2c6f9c0454de5e4054a9e5c7e3 Mon Sep 17 00:00:00 2001 From: AlexBob Date: Sat, 15 Feb 2025 23:40:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(`app.component.ts`,=20`app.con?= =?UTF-8?q?fig.ts`):=20Enhance=20documentation=20with=20detailed=20JSDoc?= =?UTF-8?q?=20comments=20and=20clean=20up=20import=20statements?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ng-ui/src/app/app.component.ts | 27 +++++++++++++++++++++++++++ ng-ui/src/app/app.config.ts | 16 ++-------------- 2 files changed, 29 insertions(+), 14 deletions(-) diff --git a/ng-ui/src/app/app.component.ts b/ng-ui/src/app/app.component.ts index 7502e3a5..553875da 100644 --- a/ng-ui/src/app/app.component.ts +++ b/ng-ui/src/app/app.component.ts @@ -4,6 +4,17 @@ import { MatProgressBarModule } from '@angular/material/progress-bar'; import { NavigationEnd, NavigationError, NavigationStart, Router, RouterOutlet } from '@angular/router'; import { VERSION as VERSION_ZORRO } from 'ng-zorro-antd/version'; +/** + * The root component of the application. + * + * @selector app-root + * @imports RouterOutlet, MatProgressBarModule, NgIf + * @template + * Contains a fixed-top progress bar that is displayed during navigation events + * and a router outlet for displaying routed components. + * @styles + * Ensures the host element takes up the full height and width of the viewport. + */ @Component({ selector: 'app-root', imports: [RouterOutlet, MatProgressBarModule, NgIf], @@ -23,14 +34,30 @@ import { VERSION as VERSION_ZORRO } from 'ng-zorro-antd/version'; ], }) export class AppComponent implements OnInit { + /** + * Signal to control the visibility of the progress bar. + */ progressShow = signal(false); + + /** + * Router instance for subscribing to navigation events. + */ private readonly router = inject(Router); + /** + * Constructs the AppComponent and sets initial attributes on the host element. + * + * @param el - The element reference of the host element. + * @param renderer - The renderer for manipulating the DOM. + */ constructor(el: ElementRef, renderer: Renderer2) { renderer.setAttribute(el.nativeElement, 'ng-zorro-version', VERSION_ZORRO.full); //renderer.setAttribute(el.nativeElement.parentElement, 'data-bs-theme', 'dark'); } + /** + * Initializes the component and subscribes to router events to control the progress bar visibility. + */ ngOnInit(): void { let configLoad = false; this.router.events.subscribe(event => { diff --git a/ng-ui/src/app/app.config.ts b/ng-ui/src/app/app.config.ts index e9ecb939..caf9f5ca 100644 --- a/ng-ui/src/app/app.config.ts +++ b/ng-ui/src/app/app.config.ts @@ -1,18 +1,7 @@ -import { - ApplicationConfig, - importProvidersFrom, - LOCALE_ID, - provideExperimentalZonelessChangeDetection, -} from '@angular/core'; +import { ApplicationConfig, importProvidersFrom, LOCALE_ID, provideExperimentalZonelessChangeDetection } from '@angular/core'; import { provideRouter, withComponentInputBinding } from '@angular/router'; -import { - provideHttpClient, - withFetch, - withInterceptors, - withInterceptorsFromDi, - withXsrfConfiguration, -} from '@angular/common/http'; +import { provideHttpClient, withFetch, withInterceptors, withInterceptorsFromDi, withXsrfConfiguration } from '@angular/common/http'; import { FormsModule } from '@angular/forms'; import { provideAnimationsAsync } from '@angular/platform-browser/animations/async'; @@ -52,6 +41,5 @@ export const appConfig: ApplicationConfig = { { provide: LOCALE_ID, useValue: 'zh_CN' }, provideRouter(routes, withComponentInputBinding()), provideExperimentalZonelessChangeDetection(), - provideAnimationsAsync(), provideAnimationsAsync(), ], };