ohayolibs
Version:
Ohayo is a set of essential modules for ohayojp.
80 lines (64 loc) • 2.41 kB
text/typescript
export default `import { ModuleWithProviders, NgModule, Optional, SkipSelf } from '@angular/core';
import { throwIfAlreadyLoaded } from '@core';
import { OhayoMockModule } from '@ohayo/mock';
import { OhayoThemeModule } from '@ohayo/theme';
import { OhayoConfig, OHAYO_CONFIG } from '@ohayo/util';
// Please refer to: https://ohayojp.com/docs/global-config
// #region ohayojp Config
import { OhayoACLModule } from '@ohayo/acl';
const ohayoConfig: OhayoConfig = {
// st: { modal: { size: 'lg' } },
// pageHeader: { homeI18n: 'home' },
// auth: { login_url: '/passport/login' },
};
const ohayoModules = [OhayoThemeModule.forRoot(), OhayoACLModule.forRoot(), OhayoMockModule.forRoot()];
const ohayoProvides = [{ provide: OHAYO_CONFIG, useValue: ohayoConfig }];
// mock
import { environment } from '@env/environment';
import * as MOCKDATA from '../../_mock';
if (!environment.production) {
ohayoConfig.mock = { data: MOCKDATA };
}
// #region reuse-tab
/**
* 若需要[路由复用](https://ohayojp.com/components/reuse-tab)需要:
* 1、在 \`shared-ohayo.module.ts\` 导入 \`ReuseTabModule\` 模块
* 2、注册 \`RouteReuseStrategy\`
* 3、在 \`src/app/layout/default/default.component.html\` 修改:
* \`\`\`html
* <section class="ohayo-default__content">
* <reuse-tab #reuseTab></reuse-tab>
* <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
* </section>
* \`\`\`
*/
// import { RouteReuseStrategy } from '@angular/router';
// import { ReuseTabService, ReuseTabStrategy } from '@ohayo/components/reuse-tab';
// ohayoProvides.push({
// provide: RouteReuseStrategy,
// useClass: ReuseTabStrategy,
// deps: [ReuseTabService],
// } as any);
// #endregion
// #endregion
// Please refer to: https://ng.ant.design/docs/global-config/en#how-to-use
// #region NG-ZORRO Config
import { NzConfig, NZ_CONFIG } from 'ng-zorro-antd/core/config';
const ngZorroConfig: NzConfig = {};
const zorroProvides = [{ provide: NZ_CONFIG, useValue: ngZorroConfig }];
// #endregion
export class GlobalConfigModule {
constructor( parentModule: GlobalConfigModule) {
throwIfAlreadyLoaded(parentModule, 'GlobalConfigModule');
}
static forRoot(): ModuleWithProviders {
return {
ngModule: GlobalConfigModule,
providers: [...ohayoProvides, ...zorroProvides],
};
}
}
`;