-
Notifications
You must be signed in to change notification settings - Fork 161
/
app.module.ts
106 lines (101 loc) · 3.42 KB
/
app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { NgModule, LOCALE_ID, APP_INITIALIZER, Injector } from '@angular/core';
import {
HttpClient,
HTTP_INTERCEPTORS,
HttpClientModule,
} from '@angular/common/http';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { DelonModule } from './delon.module';
import { CoreModule } from './core/core.module';
import { SharedModule } from './shared/shared.module';
import { AppComponent } from './app.component';
import { RoutesModule } from './routes/routes.module';
import { LayoutModule } from './layout/layout.module';
import { StartupService } from '@core/startup/startup.service';
import { DefaultInterceptor } from '@core/net/default.interceptor';
import { SimpleInterceptor } from '@delon/auth';
// angular i18n
import { registerLocaleData } from '@angular/common';
import localeZh from '@angular/common/locales/zh';
registerLocaleData(localeZh);
// i18n
import { TranslateModule, TranslateLoader } from '@ngx-translate/core';
import { TranslateHttpLoader } from '@ngx-translate/http-loader';
import { ALAIN_I18N_TOKEN } from '@delon/theme';
import { I18NService } from '@core/i18n/i18n.service';
// third
import { UEditorModule } from 'ngx-ueditor';
import { NgxTinymceModule } from 'ngx-tinymce';
// @delon/form: JSON Schema form
import { JsonSchemaModule } from '@shared/json-schema/json-schema.module';
// 服务
import { RequestHelperService } from './api/request-helper.service';
import { TestService } from './api/test-service.service';
import { ServiceProxyModule } from '../shared/service-proxies/service-proxy.module';
// 加载i18n语言文件
export function I18nHttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, `assets/tmp/i18n/`, '.json');
}
export function StartupServiceFactory(
startupService: StartupService,
): Function {
return () => startupService.load();
}
@NgModule({
declarations: [
AppComponent
],
imports: [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
DelonModule.forRoot(),
CoreModule,
SharedModule,
LayoutModule,
RoutesModule,
// i18n
TranslateModule.forRoot({
loader: {
provide: TranslateLoader,
useFactory: I18nHttpLoaderFactory,
deps: [HttpClient],
},
}),
// thirds
UEditorModule.forRoot({
// **注:** 建议使用本地路径;以下为了减少 ng-alain 脚手架的包体大小引用了CDN,可能会有部分功能受影响
js: [
`//apps.bdimg.com/libs/ueditor/1.4.3.1/ueditor.config.js`,
`//apps.bdimg.com/libs/ueditor/1.4.3.1/ueditor.all.min.js`,
],
options: {
UEDITOR_HOME_URL: `//apps.bdimg.com/libs/ueditor/1.4.3.1/`,
},
}),
NgxTinymceModule.forRoot({
baseURL: '//cdn.bootcss.com/tinymce/4.7.4/',
}),
// JSON-Schema form
JsonSchemaModule,
ServiceProxyModule
],
providers: [
{ provide: LOCALE_ID, useValue: 'zh-Hans' },
{ provide: HTTP_INTERCEPTORS, useClass: SimpleInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: DefaultInterceptor, multi: true },
{ provide: ALAIN_I18N_TOKEN, useClass: I18NService, multi: false },
StartupService,
{
provide: APP_INITIALIZER,
useFactory: StartupServiceFactory,
deps: [StartupService],
multi: true,
},
RequestHelperService,
TestService,
],
bootstrap: [AppComponent],
})
export class AppModule {}