import { Component } from '@angular/core' ; import { Router , NavigationEnd , RouteConfigLoadStart , NavigationError , } from '@angular/router' ; import { NzMessageService } from 'ng-zorro-antd' ; import { ScrollService , MenuService , SettingsService } from '@delon/theme' ; @ Component ( { selector : 'layout-default' , templateUrl : './default.component.html' , } ) export class LayoutDefaultComponent { isFetching = false ; constructor ( router , scroll , private _message , public menuSrv , public settings ) { router . events . subscribe ( evt => { if ( ! this . isFetching && evt instanceof RouteConfigLoadStart ) { this . isFetching = true ; } if ( evt instanceof NavigationError ) { this . isFetching = false ; _message . error ( `无法加载${ evt . url }路由` , { nzDuration : 1000 * 3 } ) ; return ; } if ( ! ( evt instanceof NavigationEnd ) ) { return ; } setTimeout ( ( ) => { scroll . scrollToTop ( ) ; this . isFetching = false ; } , 100 ) ; } ) ; } }