数据可视化大屏
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
2.7KB

  1. import { provideHttpClient, withInterceptors } from '@angular/common/http';
  2. import { default as ngLang } from '@angular/common/locales/zh';
  3. import { ApplicationConfig, EnvironmentProviders, Provider } from '@angular/core';
  4. import { provideAnimations } from '@angular/platform-browser/animations';
  5. import { provideRouter, withComponentInputBinding, withViewTransitions, withInMemoryScrolling, withHashLocation, RouterFeatures } from '@angular/router';
  6. import { defaultInterceptor, provideStartup } from '@core';
  7. import { provideCellWidgets } from '@delon/abc/cell';
  8. import { provideSTWidgets } from '@delon/abc/st';
  9. import { authSimpleInterceptor, provideAuth } from '@delon/auth';
  10. import { provideSFConfig } from '@delon/form';
  11. import { AlainProvideLang, provideAlain, zh_CN as delonLang } from '@delon/theme';
  12. import { AlainConfig } from '@delon/util/config';
  13. import { environment } from '@env/environment';
  14. import { CELL_WIDGETS, ST_WIDGETS, SF_WIDGETS } from '@shared';
  15. import { zhCN as dateLang } from 'date-fns/locale';
  16. import { NzConfig, provideNzConfig } from 'ng-zorro-antd/core/config';
  17. import { zh_CN as zorroLang } from 'ng-zorro-antd/i18n';
  18. import { provideBindAuthRefresh } from './core/net';
  19. import { routes } from './routes/routes';
  20. import { ICONS } from '../style-icons';
  21. import { ICONS_AUTO } from '../style-icons-auto';
  22. const defaultLang: AlainProvideLang = {
  23. abbr: 'zh-CN',
  24. ng: ngLang,
  25. zorro: zorroLang,
  26. date: dateLang,
  27. delon: delonLang
  28. };
  29. const alainConfig: AlainConfig = {
  30. auth: { login_url: '/passport/login' }
  31. };
  32. const ngZorroConfig: NzConfig = {};
  33. const routerFeatures: RouterFeatures[] = [
  34. withComponentInputBinding(),
  35. withViewTransitions(),
  36. withInMemoryScrolling({ scrollPositionRestoration: 'top' })
  37. ];
  38. if (environment.useHash) routerFeatures.push(withHashLocation());
  39. const providers: Array<Provider | EnvironmentProviders> = [
  40. provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])),
  41. provideAnimations(),
  42. provideRouter(routes, ...routerFeatures),
  43. provideAlain({ config: alainConfig, defaultLang, icons: [...ICONS_AUTO, ...ICONS] }),
  44. provideNzConfig(ngZorroConfig),
  45. provideAuth(),
  46. provideCellWidgets(...CELL_WIDGETS),
  47. provideSTWidgets(...ST_WIDGETS),
  48. provideSFConfig({
  49. widgets: [...SF_WIDGETS]
  50. }),
  51. provideStartup(),
  52. ...(environment.providers || [])
  53. ];
  54. // If you use `@delon/auth` to refresh the token, additional registration `provideBindAuthRefresh` is required
  55. if (environment.api?.refreshTokenEnabled && environment.api.refreshTokenType === 'auth-refresh') {
  56. providers.push(provideBindAuthRefresh());
  57. }
  58. export const appConfig: ApplicationConfig = {
  59. providers: providers
  60. };