|
- 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 { defaultInterceptor, provideStartup } from '@core';
- import { provideCellWidgets } from '@delon/abc/cell';
- import { provideSTWidgets } from '@delon/abc/st';
- import { authSimpleInterceptor, provideAuth } from '@delon/auth';
- import { provideSFConfig } from '@delon/form';
- import { AlainProvideLang, provideAlain, zh_CN as delonLang } from '@delon/theme';
- import { AlainConfig } from '@delon/util/config';
- import { environment } from '@env/environment';
- import { CELL_WIDGETS, ST_WIDGETS, 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';
- import { IMqttMessage, IMqttServiceOptions, MqttService, IPublishOptions } from 'ngx-mqtt';
-
- export const MQTT_SERVICE_OPTIONS: IMqttServiceOptions = {
- hostname: 'localhost',
- port: 9001, // 通常对于不加密的连接是1883,加密的连接是8883
- path: '/mqtt', // 这是连接路径,默认通常是'/mqtt'
- // 如果MQTT服务需要认证,则添加以下属性:
- //url: 'mqtt://localhost:1883'
- };
-
- const defaultLang: AlainProvideLang = {
- abbr: 'zh-CN',
- ng: ngLang,
- zorro: zorroLang,
- date: dateLang,
- delon: delonLang
- };
-
- const alainConfig: AlainConfig = {
- 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<Provider | EnvironmentProviders> = [
- provideHttpClient(withInterceptors([...(environment.interceptorFns ?? []), authSimpleInterceptor, defaultInterceptor])),
- provideAnimations(),
- provideRouter(routes, ...routerFeatures),
- provideAlain({ config: alainConfig, defaultLang, icons: [...ICONS_AUTO, ...ICONS] }),
- provideNzConfig(ngZorroConfig),
- provideAuth(),
- provideCellWidgets(...CELL_WIDGETS),
- provideSTWidgets(...ST_WIDGETS),
- provideSFConfig({
- widgets: [...SF_WIDGETS]
- }),
- {
- provide: MqttService,
- useFactory: () => {
- return new MqttService(MQTT_SERVICE_OPTIONS);
- }
- },
- provideStartup(),
- ...(environment.providers || [])
- ];
-
- // If you use `@delon/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
- };
|