import { provideHttpClient, withInterceptors } from '@angular/common/http'; import { default as ngLang } from '@angular/common/locales/zh'; import { ApplicationConfig, EnvironmentProviders, Provider } from '@angular/core'; import { provideAnimations } from '@angular/platform-browser/animations'; import { provideRouter, withComponentInputBinding, withViewTransitions, withInMemoryScrolling, withHashLocation, RouterFeatures } from '@angular/router'; import { <% if (i18n) { %>I18NService, <% } %>defaultInterceptor, provideStartup } from '@core'; import { provideCellWidgets } from '@yelon/abc/cell'; import { provideSTWidgets } from '@yelon/abc/st'; import { authSimpleInterceptor, provideAuth } from '@yelon/auth';<% if (form) { %> import { provideSFConfig } from '@yelon/form';<% } %> import { YunzaiProvideLang, provideYunzai, zh_CN as yelonLang } from '@yelon/theme'; import { YunzaiConfig } from '@yelon/util/config'; import { environment } from '@env/environment'; import { CELL_WIDGETS, ST_WIDGETS<% if (form) { %>, SF_WIDGETS<% } %> } from '@shared'; import { zhCN as dateLang } from 'date-fns/locale'; import { NzConfig, provideNzConfig } from 'ng-zorro-antd/core/config'; import { zh_CN as zorroLang } from 'ng-zorro-antd/i18n'; import { provideBindAuthRefresh } from './core/net'; import { routes } from './routes/routes'; import { ICONS } from '../style-icons'; import { ICONS_AUTO } from '../style-icons-auto'; const defaultLang: YunzaiProvideLang = { abbr: 'zh-CN', ng: ngLang, zorro: zorroLang, date: dateLang, yelon: yelonLang }; const yunzaiConfig: YunzaiConfig = { auth: { login_url: '/passport/login' } }; const ngZorroConfig: NzConfig = {}; const routerFeatures: RouterFeatures[] = [ withComponentInputBinding(), withViewTransitions(), withInMemoryScrolling({ scrollPositionRestoration: 'top' }) ]; if (environment.useHash) routerFeatures.push(withHashLocation()); const providers: Array = [ provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])), provideAnimations(), provideRouter(routes, ...routerFeatures), provideYunzai({ config: yunzaiConfig, defaultLang<% if (i18n) { %>, i18nClass: I18NService<% } %>, icons: [...ICONS_AUTO, ...ICONS] }), provideNzConfig(ngZorroConfig), provideAuth(), provideCellWidgets(...CELL_WIDGETS), provideSTWidgets(...ST_WIDGETS),<% if (form) { %> provideSFConfig({ widgets: [...SF_WIDGETS] }),<% } %> provideStartup(), ...(environment.providers || []) ]; // If you use `@yelon/auth` to refresh the token, additional registration `provideBindAuthRefresh` is required if (environment.api?.refreshTokenEnabled && environment.api.refreshTokenType === 'auth-refresh') { providers.push(provideBindAuthRefresh()); } export const appConfig: ApplicationConfig = { providers: providers };