import { Injectable , Injector , Inject } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { MenuService , SettingsService , TitleService } from '@delon/theme' ; import { DA_SERVICE_TOKEN , ITokenService } from '@delon/auth' ; import { ACLService } from '@delon/acl' ; import { NzMessageService } from 'ng-zorro-antd' ; import { catchError } from 'rxjs/operators' ; /**
 * 用于应用启动时
 * 一般用来获取应用所需要的基础数据等
 */ @ Injectable ( ) export class StartupService { constructor ( private menuService , private settingService , private aclService , private titleService , @ Inject ( DA_SERVICE_TOKEN ) private tokenService , private httpClient , private injector ) { } load ( ) { return new Promise ( ( resolve , reject ) => { this . httpClient . get ( 'values' ) . pipe ( catchError ( ( res ) => { resolve ( null ) ; return null ; } ) ) . subscribe ( ( res ) => { if ( res != null ) this . injector . get ( NzMessageService ) . success ( JSON . stringify ( res ) ) ; } , ( ) => { } , ( ) => { resolve ( null ) ; } ) ; } ) ; } }