import { HTTP_INTERCEPTORS, HttpClientXsrfModule } from '@angular/common/http'; import { APP_ID, NgModule, APP_INITIALIZER } from '@angular/core'; import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { BrowserTransferStateModule, BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { ServiceWorkerModule } from '@angular/service-worker'; import { JwtModule } from '@auth0/angular-jwt'; import { NaCoreModule, NaStartupModule, NaTranslateModule, NaMessageModule } from '@ng-arthur-mobile/core'; import { NaDefaultHttpClientInterceptor, NaDefaultHttpTimingInterceptor, NaHttpModule, NaPaginationModule, NA_PAGINATION_MAPPING, NA_HTTP_CONFIG } from '@ng-arthur-mobile/http'; import { NaMobileModule } from '@ng-arthur-mobile/mobile'; import { NaPcModule } from '@ng-arthur-mobile/pc'; import { environment } from '../environments/environment'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { NgZorroAntdModule, NZ_I18N, zh_CN } from 'ng-zorro-antd'; import { NgZorroAntdMobileModule } from 'ng-zorro-antd-mobile'; import { NaLogModule } from '@ng-arthur-mobile/common'; import zh from '@angular/common/locales/zh'; import { registerLocaleData } from '@angular/common'; import { StartupService } from './shared/startup.service'; import { NaFormsModule } from '@ng-arthur-mobile/forms'; registerLocaleData(zh); export function tokenGetter() { return localStorage.getItem('Access-Token'); } /** * 应用启动查询系统配置信息 * * @export * @returns {Function} */ export function AppStartupServiceFactory(startupService: StartupService): Function { const initializer = () => { return startupService.load(); }; return initializer; } @NgModule({ declarations: [ AppComponent ], imports: [ AppRoutingModule, BrowserModule, BrowserAnimationsModule, BrowserTransferStateModule, ReactiveFormsModule, FormsModule, NaCoreModule, NaFormsModule, NaStartupModule.forRoot({ prefix: './assets/config/app', suffix: '.json' }), NaTranslateModule.forRoot( [ { prefix: './assets/i18n/dict_', suffix: '.json' }, { prefix: './assets/i18n/error_', suffix: '.json' }, // { prefix: './assets/i18n/errorCode_', suffix: '.json' }, ] ), NaHttpModule, NaPcModule, ServiceWorkerModule.register('ngsw-worker.js', { enabled: environment.production }), NgZorroAntdModule, /** 导入 ng-zorro-antd-mobile 模块 **/ // NgZorroAntdMobileModule // SharedModule ], providers: [ { provide: NA_PAGINATION_MAPPING, useValue: { data: 'rows', // total: 'total', // pageIndex: 'pageIndex', // pageSize: 'pageSize' } }, // { // provide: APP_INITIALIZER, // useFactory: AppStartupServiceFactory, // deps: [StartupService], // multi: true, // }, { provide: APP_ID, useValue: 'XYY' }, { provide: NA_HTTP_CONFIG, useValue: { BASE_URL: ['api.url', 'api.default'], NULL_VALUE_HANDLING: 'ignore', DATE_VALUE_HANDLING: 'timestamp' } }, // { provide: HTTP_INTERCEPTORS, useClass: NaDefaultHttpXsrfInterceptor, multi: true }, // { provide: HTTP_INTERCEPTORS, useClass: HttpJwtInterceptor, multi: true }, // { provide: HTTP_INTERCEPTORS, useClass: NaDefaultHttpTimingInterceptor, multi: true }, { provide: HTTP_INTERCEPTORS, useClass: NaDefaultHttpClientInterceptor, multi: true }, // 使用FundebugErrorHandler // { provide: ErrorHandler, useClass: FundebugErrorHandler } /** 配置 ng-zorro-antd 国际化 **/ { provide: NZ_I18N, useValue: zh_CN } ], bootstrap: [AppComponent] }) export class AppModule { }