数据可视化大屏
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.

85 line
3.2KB

  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. import { IMqttMessage, IMqttServiceOptions, MqttService, IPublishOptions } from 'ngx-mqtt';
  23. export const MQTT_SERVICE_OPTIONS: IMqttServiceOptions = {
  24. hostname: 'localhost',
  25. port: 9001, // 通常对于不加密的连接是1883,加密的连接是8883
  26. path: '/mqtt', // 这是连接路径,默认通常是'/mqtt'
  27. // 如果MQTT服务需要认证,则添加以下属性:
  28. //url: 'mqtt://localhost:1883'
  29. };
  30. const defaultLang: AlainProvideLang = {
  31. abbr: 'zh-CN',
  32. ng: ngLang,
  33. zorro: zorroLang,
  34. date: dateLang,
  35. delon: delonLang
  36. };
  37. const alainConfig: AlainConfig = {
  38. auth: { login_url: '/passport/login' }
  39. };
  40. const ngZorroConfig: NzConfig = {};
  41. const routerFeatures: RouterFeatures[] = [
  42. withComponentInputBinding(),
  43. withViewTransitions(),
  44. withInMemoryScrolling({ scrollPositionRestoration: 'top' })
  45. ];
  46. if (environment.useHash) routerFeatures.push(withHashLocation());
  47. const providers: Array<Provider | EnvironmentProviders> = [
  48. provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])),
  49. provideAnimations(),
  50. provideRouter(routes, ...routerFeatures),
  51. provideAlain({ config: alainConfig, defaultLang, icons: [...ICONS_AUTO, ...ICONS] }),
  52. provideNzConfig(ngZorroConfig),
  53. provideAuth(),
  54. provideCellWidgets(...CELL_WIDGETS),
  55. provideSTWidgets(...ST_WIDGETS),
  56. provideSFConfig({
  57. widgets: [...SF_WIDGETS]
  58. }),
  59. {
  60. provide: MqttService,
  61. useFactory: () => {
  62. return new MqttService(MQTT_SERVICE_OPTIONS);
  63. }
  64. },
  65. provideStartup(),
  66. ...(environment.providers || [])
  67. ];
  68. // If you use `@delon/auth` to refresh the token, additional registration `provideBindAuthRefresh` is required
  69. if (environment.api?.refreshTokenEnabled && environment.api.refreshTokenType === 'auth-refresh') {
  70. providers.push(provideBindAuthRefresh());
  71. }
  72. export const appConfig: ApplicationConfig = {
  73. providers: providers
  74. };