global-config.module.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*
  2. * Copyright [2022] [MaxKey of copyright http://www.maxkey.top]
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /* eslint-disable import/order */
  17. import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
  18. import { DelonACLModule } from '@delon/acl';
  19. import { AlainThemeModule } from '@delon/theme';
  20. import { AlainConfig, ALAIN_CONFIG } from '@delon/util/config';
  21. import { throwIfAlreadyLoaded } from '@core';
  22. import { environment } from '@env/environment';
  23. // Please refer to: https://ng-alain.com/docs/global-config
  24. // #region NG-ALAIN Config
  25. const alainConfig: AlainConfig = {
  26. st: { modal: { size: 'lg' } },
  27. pageHeader: { homeI18n: 'home' },
  28. lodop: {
  29. license: `A59B099A586B3851E0F0D7FDBF37B603`,
  30. licenseA: `C94CEE276DB2187AE6B65D56B3FC2848`
  31. },
  32. auth: { login_url: '/passport/login' }
  33. };
  34. const alainModules: any[] = [AlainThemeModule.forRoot(), DelonACLModule.forRoot()];
  35. const alainProvides = [{ provide: ALAIN_CONFIG, useValue: alainConfig }];
  36. // #region reuse-tab
  37. /**
  38. * 若需要[路由复用](https://ng-alain.com/components/reuse-tab)需要:
  39. * 1、在 `shared-delon.module.ts` 导入 `ReuseTabModule` 模块
  40. * 2、注册 `RouteReuseStrategy`
  41. * 3、在 `src/app/layout/default/default.component.html` 修改:
  42. * ```html
  43. * <section class="alain-default__content">
  44. * <reuse-tab #reuseTab></reuse-tab>
  45. * <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
  46. * </section>
  47. * ```
  48. */
  49. // import { RouteReuseStrategy } from '@angular/router';
  50. // import { ReuseTabService, ReuseTabStrategy } from '@delon/abc/reuse-tab';
  51. // alainProvides.push({
  52. // provide: RouteReuseStrategy,
  53. // useClass: ReuseTabStrategy,
  54. // deps: [ReuseTabService],
  55. // } as any);
  56. // #endregion
  57. // #endregion
  58. // Please refer to: https://ng.ant.design/docs/global-config/en#how-to-use
  59. // #region NG-ZORRO Config
  60. import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config';
  61. const ngZorroConfig: NzConfig = {};
  62. const zorroProvides = [{ provide: NZ_CONFIG, useValue: ngZorroConfig }];
  63. // #endregion
  64. @NgModule({
  65. imports: [...alainModules, ...(environment.modules || [])]
  66. })
  67. export class GlobalConfigModule {
  68. constructor(@Optional() @SkipSelf() parentModule: GlobalConfigModule) {
  69. throwIfAlreadyLoaded(parentModule, 'GlobalConfigModule');
  70. }
  71. static forRoot(): ModuleWithProviders<GlobalConfigModule> {
  72. return {
  73. ngModule: GlobalConfigModule,
  74. providers: [...alainProvides, ...zorroProvides]
  75. };
  76. }
  77. }