global-config.module.ts 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /* eslint-disable import/order */
  2. import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
  3. import { DelonACLModule } from '@delon/acl';
  4. import { AlainThemeModule } from '@delon/theme';
  5. import { AlainConfig, ALAIN_CONFIG } from '@delon/util/config';
  6. import { throwIfAlreadyLoaded } from '@core';
  7. import { environment } from '@env/environment';
  8. // Please refer to: https://ng-alain.com/docs/global-config
  9. // #region NG-ALAIN Config
  10. const alainConfig: AlainConfig = {
  11. st: { modal: { size: 'lg' } },
  12. pageHeader: { homeI18n: 'home' },
  13. lodop: {
  14. license: `A59B099A586B3851E0F0D7FDBF37B603`,
  15. licenseA: `C94CEE276DB2187AE6B65D56B3FC2848`
  16. },
  17. auth: { login_url: '/passport/login' }
  18. };
  19. const alainModules: any[] = [AlainThemeModule.forRoot(), DelonACLModule.forRoot()];
  20. const alainProvides = [{ provide: ALAIN_CONFIG, useValue: alainConfig }];
  21. // #region reuse-tab
  22. /**
  23. * 若需要[路由复用](https://ng-alain.com/components/reuse-tab)需要:
  24. * 1、在 `shared-delon.module.ts` 导入 `ReuseTabModule` 模块
  25. * 2、注册 `RouteReuseStrategy`
  26. * 3、在 `src/app/layout/default/default.component.html` 修改:
  27. * ```html
  28. * <section class="alain-default__content">
  29. * <reuse-tab #reuseTab></reuse-tab>
  30. * <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
  31. * </section>
  32. * ```
  33. */
  34. // import { RouteReuseStrategy } from '@angular/router';
  35. // import { ReuseTabService, ReuseTabStrategy } from '@delon/abc/reuse-tab';
  36. // alainProvides.push({
  37. // provide: RouteReuseStrategy,
  38. // useClass: ReuseTabStrategy,
  39. // deps: [ReuseTabService],
  40. // } as any);
  41. // #endregion
  42. // #endregion
  43. // Please refer to: https://ng.ant.design/docs/global-config/en#how-to-use
  44. // #region NG-ZORRO Config
  45. import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config';
  46. const ngZorroConfig: NzConfig = {};
  47. const zorroProvides = [{ provide: NZ_CONFIG, useValue: ngZorroConfig }];
  48. // #endregion
  49. @NgModule({
  50. imports: [...alainModules, ...(environment.modules || [])]
  51. })
  52. export class GlobalConfigModule {
  53. constructor(@Optional() @SkipSelf() parentModule: GlobalConfigModule) {
  54. throwIfAlreadyLoaded(parentModule, 'GlobalConfigModule');
  55. }
  56. static forRoot(): ModuleWithProviders<GlobalConfigModule> {
  57. return {
  58. ngModule: GlobalConfigModule,
  59. providers: [...alainProvides, ...zorroProvides]
  60. };
  61. }
  62. }