@yelon/bis 12.0.13 → 12.0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/LICENSE +21 -21
  2. package/bis.d.ts +4 -4
  3. package/bundles/bis.umd.js +7 -7
  4. package/bundles/layout.umd.js +2570 -1631
  5. package/bundles/layout.umd.js.map +1 -1
  6. package/bundles/shared.umd.js +1226 -1229
  7. package/bundles/shared.umd.js.map +1 -1
  8. package/esm2015/bis.js +4 -4
  9. package/esm2015/layout/act.guard.js +115 -0
  10. package/esm2015/layout/bis.config.js +10 -10
  11. package/esm2015/layout/contact/contact.component.js +434 -0
  12. package/esm2015/layout/contact/contact.service.js +150 -0
  13. package/esm2015/layout/layout.js +8 -6
  14. package/esm2015/layout/layout.module.js +47 -35
  15. package/esm2015/layout/path-to-regexp.service.js +237 -0
  16. package/esm2015/layout/public_api.js +15 -11
  17. package/esm2015/layout/stomp.config.js +19 -19
  18. package/esm2015/layout/widgets/index.js +7 -7
  19. package/esm2015/layout/widgets/yz.application.component.js +132 -132
  20. package/esm2015/layout/widgets/yz.clear-storage.component.js +35 -35
  21. package/esm2015/layout/widgets/yz.fullscreen.component.js +32 -32
  22. package/esm2015/layout/widgets/yz.i18n.component.js +50 -50
  23. package/esm2015/layout/widgets/yz.notify.component.js +143 -143
  24. package/esm2015/layout/widgets/yz.them-btn.component.js +106 -106
  25. package/esm2015/layout/widgets/yz.user.component.js +57 -57
  26. package/esm2015/layout/yz.auth.service.js +157 -157
  27. package/esm2015/layout/yz.basic.component.js +40 -40
  28. package/esm2015/layout/yz.default.interceptor.js +203 -203
  29. package/esm2015/layout/yz.i18n.service.js +102 -104
  30. package/esm2015/layout/yz.startup.service.js +137 -137
  31. package/esm2015/layout/yz.stomp.service.js +90 -90
  32. package/esm2015/public_api.js +1 -1
  33. package/esm2015/shared/public_api.js +4 -4
  34. package/esm2015/shared/shared-yelon.module.js +107 -107
  35. package/esm2015/shared/shared-zorro.module.js +81 -79
  36. package/esm2015/shared/shared.js +4 -4
  37. package/esm2015/shared/shared.module.js +22 -16
  38. package/esm2015/shared/style-icons.js +795 -795
  39. package/fesm2015/bis.js +2 -2
  40. package/fesm2015/layout.js +2148 -1221
  41. package/fesm2015/layout.js.map +1 -1
  42. package/fesm2015/shared.js +909 -901
  43. package/fesm2015/shared.js.map +1 -1
  44. package/layout/act.guard.d.ts +20 -0
  45. package/layout/bis.config.d.ts +3 -3
  46. package/layout/contact/contact.component.d.ts +166 -0
  47. package/layout/contact/contact.service.d.ts +115 -0
  48. package/layout/layout.d.ts +7 -5
  49. package/layout/layout.metadata.json +1 -1
  50. package/layout/layout.module.d.ts +2 -2
  51. package/layout/path-to-regexp.service.d.ts +23 -0
  52. package/layout/public_api.d.ts +12 -10
  53. package/layout/stomp.config.d.ts +3 -3
  54. package/layout/widgets/index.d.ts +7 -7
  55. package/layout/widgets/yz.application.component.d.ts +45 -45
  56. package/layout/widgets/yz.clear-storage.component.d.ts +8 -8
  57. package/layout/widgets/yz.fullscreen.component.d.ts +6 -6
  58. package/layout/widgets/yz.i18n.component.d.ts +19 -19
  59. package/layout/widgets/yz.notify.component.d.ts +25 -25
  60. package/layout/widgets/yz.them-btn.component.d.ts +29 -29
  61. package/layout/widgets/yz.user.component.d.ts +25 -25
  62. package/layout/yz.auth.service.d.ts +19 -19
  63. package/layout/yz.basic.component.d.ts +15 -15
  64. package/layout/yz.default.interceptor.d.ts +26 -26
  65. package/layout/yz.i18n.service.d.ts +24 -24
  66. package/layout/yz.startup.service.d.ts +31 -31
  67. package/layout/yz.stomp.service.d.ts +39 -39
  68. package/package.json +10 -10
  69. package/public_api.d.ts +2 -2
  70. package/shared/public_api.d.ts +4 -4
  71. package/shared/shared-yelon.module.d.ts +3 -3
  72. package/shared/shared-zorro.module.d.ts +2 -2
  73. package/shared/shared.d.ts +4 -4
  74. package/shared/shared.metadata.json +1 -1
  75. package/shared/shared.module.d.ts +2 -2
  76. package/shared/style-icons.d.ts +1 -1
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Component, ChangeDetectionStrategy, Injector, Inject, Input, ChangeDetectorRef, Renderer2, Optional, HostListener, isDevMode, NgModule, APP_INITIALIZER } from '@angular/core';
2
+ import { Injectable, Component, ChangeDetectionStrategy, Injector, Inject, Input, ChangeDetectorRef, Renderer2, Optional, HostListener, EventEmitter, ViewChild, Output, isDevMode, NgModule, APP_INITIALIZER } from '@angular/core';
3
3
  import * as i2$1 from '@yelon/cache';
4
4
  import { CacheService } from '@yelon/cache';
5
5
  import * as i1 from '@yelon/theme';
@@ -12,10 +12,10 @@ import ngEn from '@angular/common/locales/en';
12
12
  import ngZh from '@angular/common/locales/zh';
13
13
  import ngZhTw from '@angular/common/locales/zh-Hant';
14
14
  import { zhCN, zhTW, enUS } from 'date-fns/locale';
15
+ import * as i1$1 from '@yelon/util/config';
16
+ import { YunzaiConfigService } from '@yelon/util/config';
15
17
  import * as i2 from 'ng-zorro-antd/i18n';
16
18
  import { zh_CN, zh_TW, en_US, NzI18nService } from 'ng-zorro-antd/i18n';
17
- import * as i4 from '@yelon/util/config';
18
- import { YunzaiConfigService } from '@yelon/util/config';
19
19
  import { __decorate } from 'tslib';
20
20
  import { InputBoolean } from '@yelon/util/decorator';
21
21
  import { forkJoin, Subject, of, BehaviorSubject, throwError } from 'rxjs';
@@ -30,6 +30,7 @@ import { NzModalService } from 'ng-zorro-antd/modal';
30
30
  import * as screenfull from 'screenfull';
31
31
  import { HttpClientModule, HttpErrorResponse, HttpResponse, HttpResponseBase } from '@angular/common/http';
32
32
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
33
+ import * as i4 from '@angular/router';
33
34
  import { RouterModule, Router } from '@angular/router';
34
35
  import { YzSharedModule, ICONS } from '@yelon/bis/shared';
35
36
  import { RxStomp } from '@stomp/rx-stomp';
@@ -38,212 +39,210 @@ import { NzNotificationService } from 'ng-zorro-antd/notification';
38
39
  import { NzIconService } from 'ng-zorro-antd/icon';
39
40
  import { ACLService } from '@yelon/acl';
40
41
 
41
- // 请参考:https://ng.yunzainfo.com/docs/i18n
42
- const DEFAULT = 'zh-CN';
43
- const LANGS = {
44
- 'zh-CN': {
45
- text: '简体中文',
46
- ng: ngZh,
47
- zorro: zh_CN,
48
- date: zhCN,
49
- yelon: zh_CN$1,
50
- abbr: '🇨🇳'
51
- },
52
- 'zh-TW': {
53
- text: '繁体中文',
54
- ng: ngZhTw,
55
- zorro: zh_TW,
56
- date: zhTW,
57
- yelon: zh_TW$1,
58
- abbr: '🇭🇰'
59
- },
60
- 'en-US': {
61
- text: 'English',
62
- ng: ngEn,
63
- zorro: en_US,
64
- date: enUS,
65
- yelon: en_US$1,
66
- abbr: '🇬🇧'
67
- }
68
- };
69
- class YzI18NService extends YunzaiI18nBaseService {
70
- constructor(http, settings, nzI18nService, yelonLocaleService, platform, cogSrv) {
71
- super(cogSrv);
72
- this.http = http;
73
- this.settings = settings;
74
- this.nzI18nService = nzI18nService;
75
- this.yelonLocaleService = yelonLocaleService;
76
- this.platform = platform;
77
- this._defaultLang = DEFAULT;
78
- this._langs = Object.keys(LANGS).map(code => {
79
- const item = LANGS[code];
80
- return { code, text: item.text, abbr: item.abbr };
81
- });
82
- const defaultLang = this.getDefaultLang();
83
- if (this._langs.findIndex(w => w.code === defaultLang)) {
84
- this._defaultLang = defaultLang;
85
- }
86
- }
87
- getDefaultLang() {
88
- if (!this.platform.isBrowser) {
89
- return DEFAULT;
90
- }
91
- if (this.settings.layout.lang) {
92
- return this.settings.layout.lang;
93
- }
94
- let res = (navigator.languages ? navigator.languages[0] : null) || navigator.language;
95
- const arr = res.split('-');
96
- return arr.length <= 1 ? res : `${arr[0]}-${arr[1].toUpperCase()}`;
97
- }
98
- loadLangData(lang) {
99
- return this.http.get(`assets/tmp/i18n/${lang}.json`);
100
- }
101
- use(lang, data) {
102
- if (this._currentLang === lang)
103
- return;
104
- this._data = data;
105
- const item = LANGS[lang];
106
- registerLocaleData(item.ng);
107
- this.nzI18nService.setLocale(item.zorro);
108
- this.nzI18nService.setDateLocale(item.date);
109
- this.yelonLocaleService.setLocale(item.yelon);
110
- this._currentLang = lang;
111
- this._change$.next(lang);
112
- }
113
- getLangs() {
114
- return this._langs;
115
- }
116
- }
117
- YzI18NService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzI18NService_Factory() { return new YzI18NService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i1.SettingsService), i0.ɵɵinject(i2.NzI18nService), i0.ɵɵinject(i1.YelonLocaleService), i0.ɵɵinject(i3.Platform), i0.ɵɵinject(i4.YunzaiConfigService)); }, token: YzI18NService, providedIn: "root" });
118
- YzI18NService.decorators = [
119
- { type: Injectable, args: [{ providedIn: 'root' },] }
120
- ];
121
- YzI18NService.ctorParameters = () => [
122
- { type: _HttpClient },
123
- { type: SettingsService },
124
- { type: NzI18nService },
125
- { type: YelonLocaleService },
126
- { type: Platform },
127
- { type: YunzaiConfigService }
42
+ // 请参考:https://ng.yunzainfo.com/docs/i18n
43
+ const DEFAULT = 'zh-CN';
44
+ const LANGS = {
45
+ 'zh-CN': {
46
+ text: '简体中文',
47
+ ng: ngZh,
48
+ zorro: zh_CN,
49
+ date: zhCN,
50
+ yelon: zh_CN$1,
51
+ abbr: '🇨🇳'
52
+ },
53
+ 'zh-TW': {
54
+ text: '繁体中文',
55
+ ng: ngZhTw,
56
+ zorro: zh_TW,
57
+ date: zhTW,
58
+ yelon: zh_TW$1,
59
+ abbr: '🇭🇰'
60
+ },
61
+ 'en-US': {
62
+ text: 'English',
63
+ ng: ngEn,
64
+ zorro: en_US,
65
+ date: enUS,
66
+ yelon: en_US$1,
67
+ abbr: '🇬🇧'
68
+ }
69
+ };
70
+ class YzI18NService extends YunzaiI18nBaseService {
71
+ constructor(http, settings, nzI18nService, yelonLocaleService, platform, cogSrv) {
72
+ super(cogSrv);
73
+ this.http = http;
74
+ this.settings = settings;
75
+ this.nzI18nService = nzI18nService;
76
+ this.yelonLocaleService = yelonLocaleService;
77
+ this.platform = platform;
78
+ this._defaultLang = DEFAULT;
79
+ this._langs = Object.keys(LANGS).map(code => {
80
+ const item = LANGS[code];
81
+ return { code, text: item.text, abbr: item.abbr };
82
+ });
83
+ const defaultLang = this.getDefaultLang();
84
+ this._defaultLang = this._langs.findIndex(w => w.code === defaultLang) === -1 ? DEFAULT : defaultLang;
85
+ }
86
+ getDefaultLang() {
87
+ if (!this.platform.isBrowser) {
88
+ return DEFAULT;
89
+ }
90
+ if (this.settings.layout.lang) {
91
+ return this.settings.layout.lang;
92
+ }
93
+ let res = (navigator.languages ? navigator.languages[0] : null) || navigator.language;
94
+ const arr = res.split('-');
95
+ return arr.length <= 1 ? res : `${arr[0]}-${arr[1].toUpperCase()}`;
96
+ }
97
+ loadLangData(lang) {
98
+ return this.http.get(`assets/tmp/i18n/${lang}.json`);
99
+ }
100
+ use(lang, data) {
101
+ if (this._currentLang === lang)
102
+ return;
103
+ this._data = this.flatData(data, []);
104
+ const item = LANGS[lang];
105
+ registerLocaleData(item.ng);
106
+ this.nzI18nService.setLocale(item.zorro);
107
+ this.nzI18nService.setDateLocale(item.date);
108
+ this.yelonLocaleService.setLocale(item.yelon);
109
+ this._currentLang = lang;
110
+ this._change$.next(lang);
111
+ }
112
+ getLangs() {
113
+ return this._langs;
114
+ }
115
+ }
116
+ YzI18NService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzI18NService_Factory() { return new YzI18NService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i1.SettingsService), i0.ɵɵinject(i2.NzI18nService), i0.ɵɵinject(i1.YelonLocaleService), i0.ɵɵinject(i3.Platform), i0.ɵɵinject(i1$1.YunzaiConfigService)); }, token: YzI18NService, providedIn: "root" });
117
+ YzI18NService.decorators = [
118
+ { type: Injectable, args: [{ providedIn: 'root' },] }
119
+ ];
120
+ YzI18NService.ctorParameters = () => [
121
+ { type: _HttpClient },
122
+ { type: SettingsService },
123
+ { type: NzI18nService },
124
+ { type: YelonLocaleService },
125
+ { type: Platform },
126
+ { type: YunzaiConfigService }
128
127
  ];
129
128
 
130
- var TOPIC;
131
- (function (TOPIC) {
132
- TOPIC[TOPIC["FULL"] = 0] = "FULL";
133
- TOPIC[TOPIC["OWN"] = 1] = "OWN";
134
- TOPIC[TOPIC["EVERY"] = 2] = "EVERY";
135
- })(TOPIC || (TOPIC = {}));
136
- class YzHeaderApplicationComponent {
137
- constructor(inject, cacheService, i18n, http) {
138
- this.inject = inject;
139
- this.cacheService = cacheService;
140
- this.i18n = i18n;
141
- this.http = http;
142
- this.T = TOPIC;
143
- this.active = false;
144
- this.topicData = [];
145
- this.listData = [];
146
- this.topic = TOPIC.FULL;
147
- this.searchValue = null;
148
- this.subs = [];
149
- }
150
- ngOnInit() {
151
- this.topicData = this.cacheService.get('_yz_header', { mode: 'none' });
152
- this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
153
- }
154
- ngOnDestroy() {
155
- this.subs.forEach(f => f.unsubscribe());
156
- }
157
- diffChange(flag) {
158
- if (flag) {
159
- this.active = flag;
160
- }
161
- else {
162
- this.active = !this.active;
163
- }
164
- }
165
- initTopic(topic) {
166
- this.searchValue = null;
167
- this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
168
- this.topic = topic;
169
- }
170
- full() {
171
- this.initTopic(TOPIC.FULL);
172
- }
173
- own() {
174
- this.initTopic(TOPIC.OWN);
175
- const temp = this.cacheService.get('_yz_header', { mode: 'none' });
176
- this.listData = temp
177
- .filter((topic) => {
178
- topic.children = topic.children.filter((child) => {
179
- return child.auth;
180
- });
181
- return topic;
182
- })
183
- .filter((topic) => {
184
- return topic.children.length > 0;
185
- });
186
- }
187
- every(e) {
188
- this.initTopic(TOPIC.EVERY);
189
- this.choosed = e;
190
- const temp = this.cacheService.get('_yz_header', { mode: 'none' });
191
- this.listData = [...temp.filter(t => t.key === e.key)[0].children];
192
- }
193
- onSearch() {
194
- const temp = this.cacheService.get('_yz_header', { mode: 'none' });
195
- // 如果搜索输入的有值
196
- if (this.searchValue) {
197
- // 过滤菜单过滤出搜索的值
198
- this.listData = temp
199
- .filter((topic) => {
200
- if (this.i18n.fanyi(topic.name).includes(this.searchValue)) {
201
- return topic;
202
- }
203
- else {
204
- topic.children = topic.children.filter((child) => {
205
- return this.i18n.fanyi(child.name).includes(this.searchValue);
206
- });
207
- return topic;
208
- }
209
- })
210
- .filter((topic) => {
211
- return topic.children.length > 0;
212
- });
213
- }
214
- else {
215
- // 如果没有值,取消搜索
216
- this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
217
- }
218
- }
219
- open(topic) {
220
- if (topic.key) {
221
- this.subs.push(this.http
222
- .post(`/app-manager/web-scan/save`, {
223
- appId: topic.key,
224
- createDate: new Date()
225
- })
226
- .subscribe());
227
- }
228
- switch (topic.target) {
229
- case 'href':
230
- this.inject.get(WINDOW).location.href = topic.url;
231
- break;
232
- case 'blank':
233
- this.inject.get(WINDOW).location.href = topic.url;
234
- break;
235
- case 'target':
236
- this.inject.get(WINDOW).location.href = topic.url;
237
- break;
238
- default:
239
- this.inject.get(WINDOW).location.href = topic.url;
240
- break;
241
- }
242
- }
243
- }
244
- YzHeaderApplicationComponent.decorators = [
245
- { type: Component, args: [{
246
- selector: 'yz-header-application',
129
+ var TOPIC;
130
+ (function (TOPIC) {
131
+ TOPIC[TOPIC["FULL"] = 0] = "FULL";
132
+ TOPIC[TOPIC["OWN"] = 1] = "OWN";
133
+ TOPIC[TOPIC["EVERY"] = 2] = "EVERY";
134
+ })(TOPIC || (TOPIC = {}));
135
+ class YzHeaderApplicationComponent {
136
+ constructor(inject, cacheService, i18n, http) {
137
+ this.inject = inject;
138
+ this.cacheService = cacheService;
139
+ this.i18n = i18n;
140
+ this.http = http;
141
+ this.T = TOPIC;
142
+ this.active = false;
143
+ this.topicData = [];
144
+ this.listData = [];
145
+ this.topic = TOPIC.FULL;
146
+ this.searchValue = null;
147
+ this.subs = [];
148
+ }
149
+ ngOnInit() {
150
+ this.topicData = this.cacheService.get('_yz_header', { mode: 'none' });
151
+ this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
152
+ }
153
+ ngOnDestroy() {
154
+ this.subs.forEach(f => f.unsubscribe());
155
+ }
156
+ diffChange(flag) {
157
+ if (flag) {
158
+ this.active = flag;
159
+ }
160
+ else {
161
+ this.active = !this.active;
162
+ }
163
+ }
164
+ initTopic(topic) {
165
+ this.searchValue = null;
166
+ this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
167
+ this.topic = topic;
168
+ }
169
+ full() {
170
+ this.initTopic(TOPIC.FULL);
171
+ }
172
+ own() {
173
+ this.initTopic(TOPIC.OWN);
174
+ const temp = this.cacheService.get('_yz_header', { mode: 'none' });
175
+ this.listData = temp
176
+ .filter((topic) => {
177
+ topic.children = topic.children.filter((child) => {
178
+ return child.auth;
179
+ });
180
+ return topic;
181
+ })
182
+ .filter((topic) => {
183
+ return topic.children.length > 0;
184
+ });
185
+ }
186
+ every(e) {
187
+ this.initTopic(TOPIC.EVERY);
188
+ this.choosed = e;
189
+ const temp = this.cacheService.get('_yz_header', { mode: 'none' });
190
+ this.listData = [...temp.filter(t => t.key === e.key)[0].children];
191
+ }
192
+ onSearch() {
193
+ const temp = this.cacheService.get('_yz_header', { mode: 'none' });
194
+ // 如果搜索输入的有值
195
+ if (this.searchValue) {
196
+ // 过滤菜单过滤出搜索的值
197
+ this.listData = temp
198
+ .filter((topic) => {
199
+ if (this.i18n.fanyi(topic.name).includes(this.searchValue)) {
200
+ return topic;
201
+ }
202
+ else {
203
+ topic.children = topic.children.filter((child) => {
204
+ return this.i18n.fanyi(child.name).includes(this.searchValue);
205
+ });
206
+ return topic;
207
+ }
208
+ })
209
+ .filter((topic) => {
210
+ return topic.children.length > 0;
211
+ });
212
+ }
213
+ else {
214
+ // 如果没有值,取消搜索
215
+ this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
216
+ }
217
+ }
218
+ open(topic) {
219
+ if (topic.key) {
220
+ this.subs.push(this.http
221
+ .post(`/app-manager/web-scan/save`, {
222
+ appId: topic.key,
223
+ createDate: new Date()
224
+ })
225
+ .subscribe());
226
+ }
227
+ switch (topic.target) {
228
+ case 'href':
229
+ this.inject.get(WINDOW).location.href = topic.url;
230
+ break;
231
+ case 'blank':
232
+ this.inject.get(WINDOW).location.href = topic.url;
233
+ break;
234
+ case 'target':
235
+ this.inject.get(WINDOW).location.href = topic.url;
236
+ break;
237
+ default:
238
+ this.inject.get(WINDOW).location.href = topic.url;
239
+ break;
240
+ }
241
+ }
242
+ }
243
+ YzHeaderApplicationComponent.decorators = [
244
+ { type: Component, args: [{
245
+ selector: 'yz-header-application',
247
246
  template: `
248
247
  <!-- template start-->
249
248
  <ng-template #search>
@@ -311,46 +310,46 @@ YzHeaderApplicationComponent.decorators = [
311
310
  </div>
312
311
  </div>
313
312
  <!-- header end-->
314
- `,
315
- changeDetection: ChangeDetectionStrategy.OnPush
316
- },] }
317
- ];
318
- YzHeaderApplicationComponent.ctorParameters = () => [
319
- { type: Injector },
320
- { type: CacheService },
321
- { type: YzI18NService },
322
- { type: _HttpClient }
313
+ `,
314
+ changeDetection: ChangeDetectionStrategy.OnPush
315
+ },] }
316
+ ];
317
+ YzHeaderApplicationComponent.ctorParameters = () => [
318
+ { type: Injector },
319
+ { type: CacheService },
320
+ { type: YzI18NService },
321
+ { type: _HttpClient }
323
322
  ];
324
323
 
325
- class YzHeaderI18NComponent {
326
- constructor(settings, i18n, doc) {
327
- this.settings = settings;
328
- this.i18n = i18n;
329
- this.doc = doc;
330
- /** Whether to display language text */
331
- this.showLangText = true;
332
- }
333
- get langs() {
334
- return this.i18n.getLangs();
335
- }
336
- get curLangCode() {
337
- return this.settings.layout.lang;
338
- }
339
- change(lang) {
340
- const spinEl = this.doc.createElement('div');
341
- spinEl.setAttribute('class', `page-loading ant-spin ant-spin-lg ant-spin-spinning`);
342
- spinEl.innerHTML = `<span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>`;
343
- this.doc.body.appendChild(spinEl);
344
- this.i18n.loadLangData(lang).subscribe(res => {
345
- this.i18n.use(lang, res);
346
- this.settings.setLayout('lang', lang);
347
- setTimeout(() => this.doc.location.reload());
348
- });
349
- }
350
- }
351
- YzHeaderI18NComponent.decorators = [
352
- { type: Component, args: [{
353
- selector: 'yz-header-i18n',
324
+ class YzHeaderI18NComponent {
325
+ constructor(settings, i18n, doc) {
326
+ this.settings = settings;
327
+ this.i18n = i18n;
328
+ this.doc = doc;
329
+ /** Whether to display language text */
330
+ this.showLangText = true;
331
+ }
332
+ get langs() {
333
+ return this.i18n.getLangs();
334
+ }
335
+ get curLangCode() {
336
+ return this.settings.layout.lang;
337
+ }
338
+ change(lang) {
339
+ const spinEl = this.doc.createElement('div');
340
+ spinEl.setAttribute('class', `page-loading ant-spin ant-spin-lg ant-spin-spinning`);
341
+ spinEl.innerHTML = `<span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>`;
342
+ this.doc.body.appendChild(spinEl);
343
+ this.i18n.loadLangData(lang).subscribe(res => {
344
+ this.i18n.use(lang, res);
345
+ this.settings.setLayout('lang', lang);
346
+ setTimeout(() => this.doc.location.reload());
347
+ });
348
+ }
349
+ }
350
+ YzHeaderI18NComponent.decorators = [
351
+ { type: Component, args: [{
352
+ selector: 'yz-header-i18n',
354
353
  template: `
355
354
  <div *ngIf="showLangText" nz-dropdown [nzDropdownMenu]="langMenu" nzPlacement="bottomRight">
356
355
  <i nz-icon nzType="global"></i>
@@ -378,145 +377,145 @@ YzHeaderI18NComponent.decorators = [
378
377
  </li>
379
378
  </ul>
380
379
  </nz-dropdown-menu>
381
- `,
382
- changeDetection: ChangeDetectionStrategy.OnPush
383
- },] }
384
- ];
385
- YzHeaderI18NComponent.ctorParameters = () => [
386
- { type: SettingsService },
387
- { type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
388
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
389
- ];
390
- YzHeaderI18NComponent.propDecorators = {
391
- showLangText: [{ type: Input }]
392
- };
393
- __decorate([
394
- InputBoolean()
380
+ `,
381
+ changeDetection: ChangeDetectionStrategy.OnPush
382
+ },] }
383
+ ];
384
+ YzHeaderI18NComponent.ctorParameters = () => [
385
+ { type: SettingsService },
386
+ { type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
387
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
388
+ ];
389
+ YzHeaderI18NComponent.propDecorators = {
390
+ showLangText: [{ type: Input }]
391
+ };
392
+ __decorate([
393
+ InputBoolean()
395
394
  ], YzHeaderI18NComponent.prototype, "showLangText", void 0);
396
395
 
397
- class YzHeaderNotifyComponent {
398
- constructor(injector, msg, nzI18n, cdr, httpClient) {
399
- this.injector = injector;
400
- this.msg = msg;
401
- this.nzI18n = nzI18n;
402
- this.cdr = cdr;
403
- this.httpClient = httpClient;
404
- this.data = [
405
- {
406
- key: 'msg',
407
- title: '消息',
408
- list: [],
409
- emptyText: '您已读完所有消息',
410
- emptyImage: './assets/tmp/img/message.svg',
411
- clearText: '清空消息'
412
- },
413
- {
414
- key: 'todo',
415
- title: '待办',
416
- list: [],
417
- emptyText: '你已完成所有待办',
418
- emptyImage: './assets/tmp/img/todo.svg',
419
- clearText: '重新加载'
420
- },
421
- {
422
- key: 'notice',
423
- title: '通知',
424
- list: [],
425
- emptyText: '你已查看所有通知',
426
- emptyImage: './assets/tmp/img/notice.svg',
427
- clearText: '重新加载'
428
- }
429
- ];
430
- this.loading = false;
431
- this.count = 0;
432
- this.subs = [];
433
- }
434
- ngOnInit() {
435
- this.loadData();
436
- }
437
- loadData() {
438
- this.count = 0;
439
- this.loading = true;
440
- this.subs.push(forkJoin(this.loadTodo(), this.loadMessage()).subscribe(() => {
441
- this.loading = false;
442
- this.cdr.detectChanges();
443
- }));
444
- }
445
- loadMessage() {
446
- log('notify.component: ', 'fetch message list');
447
- const formatMessageStatus = (status) => {
448
- switch (status) {
449
- case '0':
450
- return { extra: '未读', color: 'red' };
451
- case '1':
452
- return { extra: '已读', color: 'green' };
453
- default:
454
- return { extra: '无状态', color: 'primary' };
455
- }
456
- };
457
- return this.httpClient
458
- .post(`/message-center-3/my-msg-and-todo/msg-list`, {
459
- pageNum: 1,
460
- pageSize: 10,
461
- status: '0'
462
- })
463
- .pipe(map((response) => {
464
- const viewMessage = this.data.filter(d => d.key === 'msg')[0];
465
- viewMessage.list = response.data.list.map((m) => {
466
- return Object.assign(Object.assign({}, m), { avatar: (m === null || m === void 0 ? void 0 : m.imgUrl) || './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
467
- });
468
- this.count += viewMessage.list.length;
469
- }));
470
- }
471
- loadTodo() {
472
- log('notify.component: ', 'fetch todo list');
473
- const formatTodoStatus = (status) => {
474
- switch (status) {
475
- case '0':
476
- return { extra: '未开始', color: 'red' };
477
- case '1':
478
- return { extra: '已开始', color: 'green' };
479
- default:
480
- return { extra: '无状态', color: 'primary' };
481
- }
482
- };
483
- return this.httpClient
484
- .post(`/message-center-3/my-msg-and-todo/todo-list`, {
485
- pageNum: 1,
486
- pageSize: 10,
487
- status: '0'
488
- })
489
- .pipe(map((response) => {
490
- const viewTodo = this.data.filter(d => d.key === 'todo')[0];
491
- viewTodo.list = response.data.list.map((t) => {
492
- return Object.assign(Object.assign({}, t), { avatar: (t === null || t === void 0 ? void 0 : t.imgUrl) || './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
493
- });
494
- this.count += viewTodo.list.length;
495
- }));
496
- }
497
- clear(type) {
498
- const t = this.data.filter(d => d.title === type)[0];
499
- if (t.key == 'msg' || t.key == 'notice') {
500
- this.subs.push(this.httpClient.post(`/message-center-3/my-msg-and-todo/msg-clear`, {}).subscribe(_ => {
501
- this.msg.success(`清空了 ${type}`);
502
- this.loadData();
503
- }));
504
- }
505
- if (t.key == 'todo') {
506
- this.loadData();
507
- }
508
- }
509
- select(res) {
510
- this.injector.get(WINDOW).open(res.item.url);
511
- this.loadData();
512
- }
513
- ngOnDestroy() {
514
- this.subs.forEach(a => a.unsubscribe());
515
- }
516
- }
517
- YzHeaderNotifyComponent.decorators = [
518
- { type: Component, args: [{
519
- selector: 'yz-header-notify',
396
+ class YzHeaderNotifyComponent {
397
+ constructor(injector, msg, nzI18n, cdr, httpClient) {
398
+ this.injector = injector;
399
+ this.msg = msg;
400
+ this.nzI18n = nzI18n;
401
+ this.cdr = cdr;
402
+ this.httpClient = httpClient;
403
+ this.data = [
404
+ {
405
+ key: 'msg',
406
+ title: '消息',
407
+ list: [],
408
+ emptyText: '您已读完所有消息',
409
+ emptyImage: './assets/tmp/img/message.svg',
410
+ clearText: '清空消息'
411
+ },
412
+ {
413
+ key: 'todo',
414
+ title: '待办',
415
+ list: [],
416
+ emptyText: '你已完成所有待办',
417
+ emptyImage: './assets/tmp/img/todo.svg',
418
+ clearText: '重新加载'
419
+ },
420
+ {
421
+ key: 'notice',
422
+ title: '通知',
423
+ list: [],
424
+ emptyText: '你已查看所有通知',
425
+ emptyImage: './assets/tmp/img/notice.svg',
426
+ clearText: '重新加载'
427
+ }
428
+ ];
429
+ this.loading = false;
430
+ this.count = 0;
431
+ this.subs = [];
432
+ }
433
+ ngOnInit() {
434
+ this.loadData();
435
+ }
436
+ loadData() {
437
+ this.count = 0;
438
+ this.loading = true;
439
+ this.subs.push(forkJoin(this.loadTodo(), this.loadMessage()).subscribe(() => {
440
+ this.loading = false;
441
+ this.cdr.detectChanges();
442
+ }));
443
+ }
444
+ loadMessage() {
445
+ log('notify.component: ', 'fetch message list');
446
+ const formatMessageStatus = (status) => {
447
+ switch (status) {
448
+ case '0':
449
+ return { extra: '未读', color: 'red' };
450
+ case '1':
451
+ return { extra: '已读', color: 'green' };
452
+ default:
453
+ return { extra: '无状态', color: 'primary' };
454
+ }
455
+ };
456
+ return this.httpClient
457
+ .post(`/message-center-3/my-msg-and-todo/msg-list`, {
458
+ pageNum: 1,
459
+ pageSize: 10,
460
+ status: '0'
461
+ })
462
+ .pipe(map((response) => {
463
+ const viewMessage = this.data.filter(d => d.key === 'msg')[0];
464
+ viewMessage.list = response.data.list.map((m) => {
465
+ return Object.assign(Object.assign({}, m), { avatar: (m === null || m === void 0 ? void 0 : m.imgUrl) || './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
466
+ });
467
+ this.count += viewMessage.list.length;
468
+ }));
469
+ }
470
+ loadTodo() {
471
+ log('notify.component: ', 'fetch todo list');
472
+ const formatTodoStatus = (status) => {
473
+ switch (status) {
474
+ case '0':
475
+ return { extra: '未开始', color: 'red' };
476
+ case '1':
477
+ return { extra: '已开始', color: 'green' };
478
+ default:
479
+ return { extra: '无状态', color: 'primary' };
480
+ }
481
+ };
482
+ return this.httpClient
483
+ .post(`/message-center-3/my-msg-and-todo/todo-list`, {
484
+ pageNum: 1,
485
+ pageSize: 10,
486
+ status: '0'
487
+ })
488
+ .pipe(map((response) => {
489
+ const viewTodo = this.data.filter(d => d.key === 'todo')[0];
490
+ viewTodo.list = response.data.list.map((t) => {
491
+ return Object.assign(Object.assign({}, t), { avatar: (t === null || t === void 0 ? void 0 : t.imgUrl) || './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
492
+ });
493
+ this.count += viewTodo.list.length;
494
+ }));
495
+ }
496
+ clear(type) {
497
+ const t = this.data.filter(d => d.title === type)[0];
498
+ if (t.key == 'msg' || t.key == 'notice') {
499
+ this.subs.push(this.httpClient.post(`/message-center-3/my-msg-and-todo/msg-clear`, {}).subscribe(_ => {
500
+ this.msg.success(`清空了 ${type}`);
501
+ this.loadData();
502
+ }));
503
+ }
504
+ if (t.key == 'todo') {
505
+ this.loadData();
506
+ }
507
+ }
508
+ select(res) {
509
+ this.injector.get(WINDOW).open(res.item.url);
510
+ this.loadData();
511
+ }
512
+ ngOnDestroy() {
513
+ this.subs.forEach(a => a.unsubscribe());
514
+ }
515
+ }
516
+ YzHeaderNotifyComponent.decorators = [
517
+ { type: Component, args: [{
518
+ selector: 'yz-header-notify',
520
519
  template: `
521
520
  <notice-icon
522
521
  [data]="data"
@@ -527,99 +526,99 @@ YzHeaderNotifyComponent.decorators = [
527
526
  (select)="select($event)"
528
527
  (clear)="clear($event)"
529
528
  ></notice-icon>
530
- `,
531
- changeDetection: ChangeDetectionStrategy.OnPush
532
- },] }
533
- ];
534
- YzHeaderNotifyComponent.ctorParameters = () => [
535
- { type: Injector },
536
- { type: NzMessageService },
537
- { type: NzI18nService },
538
- { type: ChangeDetectorRef },
539
- { type: _HttpClient }
529
+ `,
530
+ changeDetection: ChangeDetectionStrategy.OnPush
531
+ },] }
532
+ ];
533
+ YzHeaderNotifyComponent.ctorParameters = () => [
534
+ { type: Injector },
535
+ { type: NzMessageService },
536
+ { type: NzI18nService },
537
+ { type: ChangeDetectorRef },
538
+ { type: _HttpClient }
540
539
  ];
541
540
 
542
- class YzHeaderThemBtnComponent {
543
- constructor(renderer, configSrv, platform, doc, directionality, KEYS) {
544
- this.renderer = renderer;
545
- this.configSrv = configSrv;
546
- this.platform = platform;
547
- this.doc = doc;
548
- this.directionality = directionality;
549
- this.KEYS = KEYS;
550
- this.theme = 'default';
551
- this.types = [
552
- { key: 'default', text: 'theme.default', color: '#2163ff' },
553
- { key: 'compact', text: 'theme.compact', color: '#2163ff' },
554
- { key: 'dark', text: 'theme.dark', color: '#020202' },
555
- { key: 'yuhong', text: 'theme.yuhong', color: '#C04851' },
556
- { key: 'danjuhuang', text: 'theme.danjuhuang', color: '#FBA414' },
557
- { key: 'xinghuang', text: 'theme.xinghuang', color: '#F28E16' },
558
- { key: 'shilv', text: 'theme.shilv', color: '#57C3C2' },
559
- { key: 'zhulv', text: 'theme.zhulv', color: '#1BA784' },
560
- { key: 'youlan', text: 'theme.youlan', color: '#1781B5' },
561
- { key: 'dianqing', text: 'theme.dianqing', color: '#1661AB' },
562
- { key: 'shangengzi', text: 'theme.shangengzi', color: '#61649F' },
563
- { key: 'shuiniuhui', text: 'theme.shuiniuhui', color: '#2F2F35' }
564
- ];
565
- this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
566
- this.deployUrl = '';
567
- this.destroy$ = new Subject();
568
- this.dir = 'ltr';
569
- }
570
- ngOnInit() {
571
- var _a;
572
- this.dir = this.directionality.value;
573
- (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
574
- this.dir = direction;
575
- });
576
- this.initTheme();
577
- }
578
- initTheme() {
579
- if (!this.platform.isBrowser) {
580
- return;
581
- }
582
- this.theme = localStorage.getItem(this.KEYS) || 'default';
583
- this.updateChartTheme();
584
- this.onThemeChange(this.theme);
585
- }
586
- updateChartTheme() {
587
- this.configSrv.set('chart', { theme: this.theme === 'dark' ? 'dark' : '' });
588
- }
589
- onThemeChange(theme) {
590
- if (!this.platform.isBrowser) {
591
- return;
592
- }
593
- this.theme = theme;
594
- this.renderer.setAttribute(this.doc.body, 'data-theme', theme);
595
- const dom = this.doc.getElementById(this.KEYS);
596
- if (dom) {
597
- dom.remove();
598
- }
599
- localStorage.removeItem(this.KEYS);
600
- if (theme !== 'default') {
601
- const el = this.doc.createElement('link');
602
- el.type = 'text/css';
603
- el.rel = 'stylesheet';
604
- el.id = this.KEYS;
605
- el.href = `${this.deployUrl}assets/style.${theme}.css`;
606
- localStorage.setItem(this.KEYS, theme);
607
- this.doc.body.append(el);
608
- }
609
- this.updateChartTheme();
610
- }
611
- ngOnDestroy() {
612
- const el = this.doc.getElementById(this.KEYS);
613
- if (el != null) {
614
- this.doc.body.removeChild(el);
615
- }
616
- this.destroy$.next();
617
- this.destroy$.complete();
618
- }
619
- }
620
- YzHeaderThemBtnComponent.decorators = [
621
- { type: Component, args: [{
622
- selector: 'yz-header-theme-btn',
541
+ class YzHeaderThemBtnComponent {
542
+ constructor(renderer, configSrv, platform, doc, directionality, KEYS) {
543
+ this.renderer = renderer;
544
+ this.configSrv = configSrv;
545
+ this.platform = platform;
546
+ this.doc = doc;
547
+ this.directionality = directionality;
548
+ this.KEYS = KEYS;
549
+ this.theme = 'default';
550
+ this.types = [
551
+ { key: 'default', text: 'theme.default', color: '#2163ff' },
552
+ { key: 'compact', text: 'theme.compact', color: '#2163ff' },
553
+ { key: 'dark', text: 'theme.dark', color: '#020202' },
554
+ { key: 'yuhong', text: 'theme.yuhong', color: '#C04851' },
555
+ { key: 'danjuhuang', text: 'theme.danjuhuang', color: '#FBA414' },
556
+ { key: 'xinghuang', text: 'theme.xinghuang', color: '#F28E16' },
557
+ { key: 'shilv', text: 'theme.shilv', color: '#57C3C2' },
558
+ { key: 'zhulv', text: 'theme.zhulv', color: '#1BA784' },
559
+ { key: 'youlan', text: 'theme.youlan', color: '#1781B5' },
560
+ { key: 'dianqing', text: 'theme.dianqing', color: '#1661AB' },
561
+ { key: 'shangengzi', text: 'theme.shangengzi', color: '#61649F' },
562
+ { key: 'shuiniuhui', text: 'theme.shuiniuhui', color: '#2F2F35' }
563
+ ];
564
+ this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
565
+ this.deployUrl = '';
566
+ this.destroy$ = new Subject();
567
+ this.dir = 'ltr';
568
+ }
569
+ ngOnInit() {
570
+ var _a;
571
+ this.dir = this.directionality.value;
572
+ (_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
573
+ this.dir = direction;
574
+ });
575
+ this.initTheme();
576
+ }
577
+ initTheme() {
578
+ if (!this.platform.isBrowser) {
579
+ return;
580
+ }
581
+ this.theme = localStorage.getItem(this.KEYS) || 'default';
582
+ this.updateChartTheme();
583
+ this.onThemeChange(this.theme);
584
+ }
585
+ updateChartTheme() {
586
+ this.configSrv.set('chart', { theme: this.theme === 'dark' ? 'dark' : '' });
587
+ }
588
+ onThemeChange(theme) {
589
+ if (!this.platform.isBrowser) {
590
+ return;
591
+ }
592
+ this.theme = theme;
593
+ this.renderer.setAttribute(this.doc.body, 'data-theme', theme);
594
+ const dom = this.doc.getElementById(this.KEYS);
595
+ if (dom) {
596
+ dom.remove();
597
+ }
598
+ localStorage.removeItem(this.KEYS);
599
+ if (theme !== 'default') {
600
+ const el = this.doc.createElement('link');
601
+ el.type = 'text/css';
602
+ el.rel = 'stylesheet';
603
+ el.id = this.KEYS;
604
+ el.href = `${this.deployUrl}assets/style.${theme}.css`;
605
+ localStorage.setItem(this.KEYS, theme);
606
+ this.doc.body.append(el);
607
+ }
608
+ this.updateChartTheme();
609
+ }
610
+ ngOnDestroy() {
611
+ const el = this.doc.getElementById(this.KEYS);
612
+ if (el != null) {
613
+ this.doc.body.removeChild(el);
614
+ }
615
+ this.destroy$.next();
616
+ this.destroy$.complete();
617
+ }
618
+ }
619
+ YzHeaderThemBtnComponent.decorators = [
620
+ { type: Component, args: [{
621
+ selector: 'yz-header-theme-btn',
623
622
  template: `
624
623
  <div
625
624
  class="yunzai-default__nav-item"
@@ -659,75 +658,75 @@ YzHeaderThemBtnComponent.decorators = [
659
658
  <!-- </div>-->
660
659
  <!-- </div>-->
661
660
  </nz-dropdown-menu>
662
- `,
663
- changeDetection: ChangeDetectionStrategy.OnPush
664
- },] }
665
- ];
666
- YzHeaderThemBtnComponent.ctorParameters = () => [
667
- { type: Renderer2 },
668
- { type: YunzaiConfigService },
669
- { type: Platform },
670
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
671
- { type: Directionality, decorators: [{ type: Optional }] },
672
- { type: String, decorators: [{ type: Inject, args: [YUNZAI_THEME_BTN_KEYS,] }] }
673
- ];
674
- YzHeaderThemBtnComponent.propDecorators = {
675
- types: [{ type: Input }],
676
- devTips: [{ type: Input }],
677
- deployUrl: [{ type: Input }]
661
+ `,
662
+ changeDetection: ChangeDetectionStrategy.OnPush
663
+ },] }
664
+ ];
665
+ YzHeaderThemBtnComponent.ctorParameters = () => [
666
+ { type: Renderer2 },
667
+ { type: YunzaiConfigService },
668
+ { type: Platform },
669
+ { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
670
+ { type: Directionality, decorators: [{ type: Optional }] },
671
+ { type: String, decorators: [{ type: Inject, args: [YUNZAI_THEME_BTN_KEYS,] }] }
672
+ ];
673
+ YzHeaderThemBtnComponent.propDecorators = {
674
+ types: [{ type: Input }],
675
+ devTips: [{ type: Input }],
676
+ deployUrl: [{ type: Input }]
678
677
  };
679
678
 
680
- const BUSINESS_DEFAULT_CONFIG = {
681
- baseUrl: '/backstage',
682
- systemCode: 'portal',
683
- loginForm: null,
684
- refreshTokenEnabled: true,
685
- refreshTokenType: 're-request'
686
- };
687
- function mergeBisConfig(srv) {
688
- return srv.merge('bis', BUSINESS_DEFAULT_CONFIG);
679
+ const BUSINESS_DEFAULT_CONFIG = {
680
+ baseUrl: '/backstage',
681
+ systemCode: 'portal',
682
+ loginForm: null,
683
+ refreshTokenEnabled: true,
684
+ refreshTokenType: 're-request'
685
+ };
686
+ function mergeBisConfig(srv) {
687
+ return srv.merge('bis', BUSINESS_DEFAULT_CONFIG);
689
688
  }
690
689
 
691
- class YzHeaderUserComponent {
692
- constructor(injector, msg, tokenService,
693
- // @ts-ignore
694
- configService, cacheService) {
695
- this.injector = injector;
696
- this.msg = msg;
697
- this.tokenService = tokenService;
698
- this.configService = configService;
699
- this.cacheService = cacheService;
700
- this.icon = '';
701
- this.username = '';
702
- this.menus = [];
703
- this.config = mergeBisConfig(configService);
704
- }
705
- ngOnInit() {
706
- const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
707
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
708
- this.username = user.realname ? user.realname : '未命名';
709
- this.icon = user.avatarId
710
- ? `${this.config.baseUrl}/filecenter/file/${user.avatarId}`
711
- : `./assets/tmp/img/avatar.jpg`;
712
- this.menus = projectInfo.profileList;
713
- }
714
- logout() {
715
- localStorage.clear();
716
- this.tokenService.clear();
717
- this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
718
- }
719
- to(href) {
720
- if (href) {
721
- this.injector.get(WINDOW).open(href);
722
- }
723
- else {
724
- this.msg.error('该菜单没有配置链接!');
725
- }
726
- }
727
- }
728
- YzHeaderUserComponent.decorators = [
729
- { type: Component, args: [{
730
- selector: 'yz-header-user',
690
+ class YzHeaderUserComponent {
691
+ constructor(injector, msg, tokenService,
692
+ // @ts-ignore
693
+ configService, cacheService) {
694
+ this.injector = injector;
695
+ this.msg = msg;
696
+ this.tokenService = tokenService;
697
+ this.configService = configService;
698
+ this.cacheService = cacheService;
699
+ this.icon = '';
700
+ this.username = '';
701
+ this.menus = [];
702
+ this.config = mergeBisConfig(configService);
703
+ }
704
+ ngOnInit() {
705
+ const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
706
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
707
+ this.username = user.realname ? user.realname : '未命名';
708
+ this.icon = user.avatarId
709
+ ? `${this.config.baseUrl}/filecenter/file/${user.avatarId}`
710
+ : `./assets/tmp/img/avatar.jpg`;
711
+ this.menus = projectInfo.profileList;
712
+ }
713
+ logout() {
714
+ localStorage.clear();
715
+ this.tokenService.clear();
716
+ this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
717
+ }
718
+ to(href) {
719
+ if (href) {
720
+ this.injector.get(WINDOW).open(href);
721
+ }
722
+ else {
723
+ this.msg.error('该菜单没有配置链接!');
724
+ }
725
+ }
726
+ }
727
+ YzHeaderUserComponent.decorators = [
728
+ { type: Component, args: [{
729
+ selector: 'yz-header-user',
731
730
  template: `
732
731
  <div
733
732
  class="yunzai-default__nav-item d-flex align-items-center px-sm"
@@ -751,214 +750,789 @@ YzHeaderUserComponent.decorators = [
751
750
  </div>
752
751
  </div>
753
752
  </nz-dropdown-menu>
754
- `,
755
- changeDetection: ChangeDetectionStrategy.OnPush
756
- },] }
757
- ];
758
- YzHeaderUserComponent.ctorParameters = () => [
759
- { type: Injector },
760
- { type: NzMessageService },
761
- { type: undefined, decorators: [{ type: Inject, args: [YA_SERVICE_TOKEN,] }] },
762
- { type: YunzaiConfigService$1 },
763
- { type: CacheService }
753
+ `,
754
+ changeDetection: ChangeDetectionStrategy.OnPush
755
+ },] }
756
+ ];
757
+ YzHeaderUserComponent.ctorParameters = () => [
758
+ { type: Injector },
759
+ { type: NzMessageService },
760
+ { type: undefined, decorators: [{ type: Inject, args: [YA_SERVICE_TOKEN,] }] },
761
+ { type: YunzaiConfigService$1 },
762
+ { type: CacheService }
764
763
  ];
765
764
 
766
- class YzHeaderClearStorageComponent {
767
- constructor(modalSrv, messageSrv) {
768
- this.modalSrv = modalSrv;
769
- this.messageSrv = messageSrv;
770
- }
771
- _click() {
772
- this.modalSrv.confirm({
773
- nzTitle: 'Make sure clear all local storage?',
774
- nzOnOk: () => {
775
- localStorage.clear();
776
- this.messageSrv.success('Clear Finished!');
777
- }
778
- });
779
- }
780
- }
781
- YzHeaderClearStorageComponent.decorators = [
782
- { type: Component, args: [{
783
- selector: 'yz-header-clear-storage',
765
+ class YzHeaderClearStorageComponent {
766
+ constructor(modalSrv, messageSrv) {
767
+ this.modalSrv = modalSrv;
768
+ this.messageSrv = messageSrv;
769
+ }
770
+ _click() {
771
+ this.modalSrv.confirm({
772
+ nzTitle: 'Make sure clear all local storage?',
773
+ nzOnOk: () => {
774
+ localStorage.clear();
775
+ this.messageSrv.success('Clear Finished!');
776
+ }
777
+ });
778
+ }
779
+ }
780
+ YzHeaderClearStorageComponent.decorators = [
781
+ { type: Component, args: [{
782
+ selector: 'yz-header-clear-storage',
784
783
  template: `
785
784
  <i nz-icon nzType="tool"></i>
786
785
  {{ 'menu.clear.local.storage' | i18n }}
787
- `,
788
- host: {
789
- '[class.d-block]': 'true'
790
- },
791
- changeDetection: ChangeDetectionStrategy.OnPush
792
- },] }
793
- ];
794
- YzHeaderClearStorageComponent.ctorParameters = () => [
795
- { type: NzModalService },
796
- { type: NzMessageService }
797
- ];
798
- YzHeaderClearStorageComponent.propDecorators = {
799
- _click: [{ type: HostListener, args: ['click',] }]
786
+ `,
787
+ host: {
788
+ '[class.d-block]': 'true'
789
+ },
790
+ changeDetection: ChangeDetectionStrategy.OnPush
791
+ },] }
792
+ ];
793
+ YzHeaderClearStorageComponent.ctorParameters = () => [
794
+ { type: NzModalService },
795
+ { type: NzMessageService }
796
+ ];
797
+ YzHeaderClearStorageComponent.propDecorators = {
798
+ _click: [{ type: HostListener, args: ['click',] }]
800
799
  };
801
800
 
802
- class YzHeaderFullScreenComponent {
803
- constructor() {
804
- this.status = false;
805
- }
806
- get sf() {
807
- return screenfull;
808
- }
809
- _resize() {
810
- this.status = this.sf.isFullscreen;
811
- }
812
- _click() {
813
- if (this.sf.isEnabled) {
814
- this.sf.toggle();
815
- }
816
- }
817
- }
818
- YzHeaderFullScreenComponent.decorators = [
819
- { type: Component, args: [{
820
- selector: 'yz-header-fullscreen',
801
+ class YzHeaderFullScreenComponent {
802
+ constructor() {
803
+ this.status = false;
804
+ }
805
+ get sf() {
806
+ return screenfull;
807
+ }
808
+ _resize() {
809
+ this.status = this.sf.isFullscreen;
810
+ }
811
+ _click() {
812
+ if (this.sf.isEnabled) {
813
+ this.sf.toggle();
814
+ }
815
+ }
816
+ }
817
+ YzHeaderFullScreenComponent.decorators = [
818
+ { type: Component, args: [{
819
+ selector: 'yz-header-fullscreen',
821
820
  template: `
822
821
  <i nz-icon [nzType]="status ? 'fullscreen-exit' : 'fullscreen'"></i>
823
822
  {{ (status ? 'menu.fullscreen.exit' : 'menu.fullscreen') | i18n }}
824
- `,
825
- host: {
826
- '[class.d-block]': 'true'
827
- },
828
- changeDetection: ChangeDetectionStrategy.OnPush
829
- },] }
830
- ];
831
- YzHeaderFullScreenComponent.propDecorators = {
832
- _resize: [{ type: HostListener, args: ['window:resize',] }],
833
- _click: [{ type: HostListener, args: ['click',] }]
823
+ `,
824
+ host: {
825
+ '[class.d-block]': 'true'
826
+ },
827
+ changeDetection: ChangeDetectionStrategy.OnPush
828
+ },] }
829
+ ];
830
+ YzHeaderFullScreenComponent.propDecorators = {
831
+ _resize: [{ type: HostListener, args: ['window:resize',] }],
832
+ _click: [{ type: HostListener, args: ['click',] }]
834
833
  };
835
834
 
836
- const ɵ0 = msg => {
837
- log$1(msg);
838
- };
839
- const STOMP_DEFAULT_CONFIG = {
840
- connectHeaders: {
841
- login: 'guest',
842
- passcode: 'guest'
843
- },
844
- brokerURL: '/websocket/ws/',
845
- heartbeatIncoming: 1000 * 60,
846
- heartbeatOutgoing: 1000 * 60,
847
- reconnectDelay: 30000000,
848
- debug: ɵ0
835
+ class ContactService {
836
+ constructor(http, cache) {
837
+ this.http = http;
838
+ this.cache = cache;
839
+ }
840
+ /**
841
+ * 部门树查询
842
+ *
843
+ * @param clas 包含班级
844
+ * @param his 包含历史班级
845
+ * @param grade 系部
846
+ * @param gradeID 系部ID
847
+ * @returns 可观察部门树
848
+ */
849
+ dept(clas, his, grade, gradeID) {
850
+ let baseUrl = `/auth/baseDepartMent/tree?debug=false`;
851
+ if (clas) {
852
+ baseUrl += `&includeClass=true`;
853
+ }
854
+ else {
855
+ baseUrl += `&includeClass=false`;
856
+ }
857
+ if (his) {
858
+ baseUrl += `&includeHisClass=true`;
859
+ }
860
+ else {
861
+ baseUrl += `&includeHisClass=false`;
862
+ }
863
+ if (grade) {
864
+ baseUrl += `&deptTypes=2,class`;
865
+ }
866
+ if (gradeID) {
867
+ baseUrl += `&gradeId=${gradeID}`;
868
+ }
869
+ return this.http.get(baseUrl).pipe(map((response) => {
870
+ return response.data || [];
871
+ }));
872
+ }
873
+ page(uri, page) {
874
+ return this.http.post(`${uri}/queryListForPage`, page);
875
+ }
876
+ pageBaseUser(page) {
877
+ return this.page('/auth/baseUser', page);
878
+ }
879
+ getUserByIds(ids) {
880
+ return this.http
881
+ .post('/auth/baseUser/users', {
882
+ userIds: ids
883
+ })
884
+ .pipe((response) => {
885
+ return response.data || [];
886
+ });
887
+ }
888
+ /**
889
+ * 查询人员信息
890
+ *
891
+ * @param userIds[] 用户id数组,["aaa","bbb","ccc"]
892
+ */
893
+ getUserByUserIds(userIds) {
894
+ return this.http
895
+ .post(`/auth/baseUser/users`, {
896
+ userIds: userIds
897
+ })
898
+ .pipe(map((response) => {
899
+ return response.data ? response.data : [];
900
+ }));
901
+ }
902
+ /**
903
+ * 获取角色组角色
904
+ *
905
+ * @param roleGroupCode 角色组code
906
+ */
907
+ getGroupRole(roleGroupCode) {
908
+ return this.http
909
+ .post(`/auth/baseRole/findGroupRole`, {
910
+ roleGroupCode: roleGroupCode
911
+ })
912
+ .pipe(map((response) => {
913
+ return response.data ? response.data : [];
914
+ }));
915
+ }
916
+ /**
917
+ * 查询当前用户好友分组
918
+ */
919
+ getFriendGroup() {
920
+ return this.http.post(`/contact/appcontact/findGroup`, {}).pipe(map((response) => {
921
+ return response.data ? response.data : [];
922
+ }));
923
+ }
924
+ /**
925
+ * 查询年级
926
+ */
927
+ getGrade() {
928
+ return this.http.get(`/auth/gradeYear/queryListForPage`).pipe(map((response) => {
929
+ return response.data ? response.data : [];
930
+ }));
931
+ }
932
+ /**
933
+ * 查询人员类别列表
934
+ */
935
+ getRylbs() {
936
+ return this.http.post(`/auth/baseTeacher/queryRylbs`, {}).pipe(map((response) => {
937
+ return response.data ? response.data : [];
938
+ }));
939
+ }
940
+ /**
941
+ * 获取学生公寓树
942
+ *
943
+ * @param isPower 是否带有权限,默认false
944
+ * @param treeType 树类型 0:宿舍楼 1:宿舍楼+层 2:宿舍楼+层+房间
945
+ */
946
+ getDormTree(isPower, treeType) {
947
+ const user = this.cache.get('_yz_user', { mode: 'none' });
948
+ let params = {};
949
+ if (isPower) {
950
+ params = {
951
+ isPower: isPower,
952
+ userId: user.userId,
953
+ treeType: treeType
954
+ };
955
+ }
956
+ else {
957
+ params = {
958
+ isPower: isPower,
959
+ treeType: treeType
960
+ };
961
+ }
962
+ return this.http.post(`/auth/dorm/tree`, params).pipe(map((response) => {
963
+ return response.data ? response.data : [];
964
+ }));
965
+ }
966
+ }
967
+ ContactService.ɵprov = i0.ɵɵdefineInjectable({ factory: function ContactService_Factory() { return new ContactService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i2$1.CacheService)); }, token: ContactService, providedIn: "root" });
968
+ ContactService.decorators = [
969
+ { type: Injectable, args: [{
970
+ providedIn: 'root'
971
+ },] }
972
+ ];
973
+ ContactService.ctorParameters = () => [
974
+ { type: _HttpClient },
975
+ { type: CacheService }
976
+ ];
977
+
978
+ class ContactComponent {
979
+ constructor(contact, changeDetectorRef) {
980
+ this.contact = contact;
981
+ this.changeDetectorRef = changeDetectorRef;
982
+ this.subs = [];
983
+ /**
984
+ * tabset
985
+ */
986
+ this.nzTabsetSearch = null;
987
+ this.nzTabsetLoading = false;
988
+ /**
989
+ * 树展开状态
990
+ */
991
+ this.nzExpandAll = true;
992
+ /**
993
+ * 部门树和部门查询的一些选项/可传可不传
994
+ */
995
+ this.nzDepts = [];
996
+ this._nzDeptsCopy = [];
997
+ this.nzDeptTreeVirtualHeight = null;
998
+ this.nzDeptClass = true;
999
+ this.nzDeptClassHistory = true;
1000
+ this.nzDeptGrade = false;
1001
+ /**
1002
+ * 角色树
1003
+ */
1004
+ this.nzRoles = [];
1005
+ this._nzRolesCopy = [];
1006
+ this.nzRoleTreeVirtualHeight = null;
1007
+ /**
1008
+ * 好友分组
1009
+ */
1010
+ this.nzFriendGroups = [];
1011
+ this._nzFriendGroupsCopy = [];
1012
+ /**
1013
+ * 联系人
1014
+ */
1015
+ this.defaultContacts = [];
1016
+ this.nzContacts = [];
1017
+ this.nzContactLoading = false;
1018
+ /**
1019
+ * 提交和提交按钮
1020
+ */
1021
+ this.button = true;
1022
+ this.confirmed = new EventEmitter();
1023
+ }
1024
+ /**
1025
+ * 初始化,首先加载部门树和默认选中的人的数据
1026
+ */
1027
+ ngOnInit() {
1028
+ this.onTabsetDept();
1029
+ this.onContactsInit();
1030
+ }
1031
+ /**
1032
+ * 视图初始化完毕后进行table初始化
1033
+ */
1034
+ ngAfterViewInit() {
1035
+ this.onTableInit();
1036
+ }
1037
+ /**
1038
+ * 初始化默认选中联系人
1039
+ */
1040
+ onContactsInit() {
1041
+ if (this.defaultContacts && this.defaultContacts.length > 0) {
1042
+ this.nzContactLoading = true;
1043
+ this.subs.push(this.contact.getUserByUserIds(this.defaultContacts).subscribe(contacts => {
1044
+ this.nzContacts = contacts;
1045
+ this.nzContactLoading = false;
1046
+ this.refresh();
1047
+ }));
1048
+ }
1049
+ }
1050
+ /**
1051
+ * table初始化
1052
+ */
1053
+ onTableInit() {
1054
+ // 设置表头
1055
+ this.st.resetColumns({
1056
+ columns: [
1057
+ { title: '选择', type: 'checkbox' },
1058
+ { title: '序号', type: 'no' },
1059
+ { title: '姓名', index: 'realName' },
1060
+ { title: '学号/工号', index: 'userCode' },
1061
+ { title: '部门', index: 'dept.deptName' }
1062
+ ]
1063
+ });
1064
+ // 订阅table点击checkbox事件变化
1065
+ this.subs.push(this.st.change.subscribe(e => {
1066
+ if (e.type === 'checkbox') {
1067
+ // 点击checkbox新增联系人
1068
+ const contactIds = this.nzContacts.map(c => c.userId);
1069
+ this.nzContacts = this.nzContacts.concat(e.checkbox.filter(c => !contactIds.includes(c.userId)));
1070
+ // 取消checkbox取消联系人
1071
+ const cancelIds = this.st.list.filter(d => !d.checked).map(d => d.userId);
1072
+ this.nzContacts = this.nzContacts.filter(d => !cancelIds.includes(d.userId));
1073
+ }
1074
+ }));
1075
+ }
1076
+ /**
1077
+ * tabset进入加载状态
1078
+ */
1079
+ onTabsetLoadStart() {
1080
+ this.nzTabsetLoading = true;
1081
+ }
1082
+ /**
1083
+ * tabset取消加载状态
1084
+ */
1085
+ onTabsetLoadEnd() {
1086
+ this.nzTabsetLoading = false;
1087
+ }
1088
+ /**
1089
+ * tabset搜索框清除
1090
+ */
1091
+ onTabsetSearchClean() {
1092
+ this.nzDepts = this._nzDeptsCopy;
1093
+ this.nzRoles = this._nzRolesCopy;
1094
+ this.nzFriendGroups = this._nzFriendGroupsCopy;
1095
+ this.nzTabsetSearch = null;
1096
+ }
1097
+ /**
1098
+ * tabset搜索框输入
1099
+ *
1100
+ * @param type 类型
1101
+ * @param value 值
1102
+ */
1103
+ onTabsetSearchChange(type, value) {
1104
+ this.onTabsetLoadStart();
1105
+ if (!value || value === '') {
1106
+ this.nzDepts = this._nzDeptsCopy;
1107
+ this.nzRoles = this._nzRolesCopy;
1108
+ this.nzFriendGroups = this._nzFriendGroupsCopy;
1109
+ }
1110
+ else {
1111
+ const trees = [];
1112
+ if (type === 'dept') {
1113
+ this.searchTree(value, this._nzDeptsCopy, trees);
1114
+ this.nzDepts = trees;
1115
+ }
1116
+ if (type === 'role') {
1117
+ this.searchTree(value, this._nzRolesCopy, trees);
1118
+ this.nzRoles = trees;
1119
+ }
1120
+ if (type === 'friendGroup') {
1121
+ this.nzFriendGroups = this._nzFriendGroupsCopy.filter(f => {
1122
+ return !f.name.indexOf(value);
1123
+ });
1124
+ }
1125
+ }
1126
+ this.onTabsetLoadEnd();
1127
+ this.refresh();
1128
+ }
1129
+ /**
1130
+ * tabset切换到部门
1131
+ */
1132
+ onTabsetDept() {
1133
+ this.onTabsetSearchClean();
1134
+ if (!this.nzDepts || this.nzDepts.length === 0) {
1135
+ this.onTabsetDeptFlush();
1136
+ }
1137
+ }
1138
+ /**
1139
+ * tabset切换到角色
1140
+ */
1141
+ onTabsetRole() {
1142
+ this.onTabsetSearchClean();
1143
+ if (!this.nzRoles || this.nzRoles.length === 0) {
1144
+ this.onTabsetRoleFlush(null);
1145
+ }
1146
+ }
1147
+ /**
1148
+ * tabset切换到好友分组
1149
+ */
1150
+ onTabsetFriendGroup() {
1151
+ this.onTabsetSearchClean();
1152
+ if (!this.nzFriendGroups || this.nzFriendGroups.length === 0) {
1153
+ this.onTabsetFriendGroupFlush();
1154
+ }
1155
+ }
1156
+ /**
1157
+ * 获取部门树
1158
+ */
1159
+ onTabsetDeptFlush() {
1160
+ this.onTabsetLoadStart();
1161
+ this.subs.push(this.contact
1162
+ .dept(this.nzDeptClass, this.nzDeptClassHistory, this.nzDeptGrade, this.nzDeptGradeID)
1163
+ .subscribe((trees) => {
1164
+ this.expandTree(trees);
1165
+ this.nzDepts = trees;
1166
+ this._nzDeptsCopy = trees;
1167
+ this.onTabsetLoadEnd();
1168
+ this.refresh();
1169
+ }));
1170
+ }
1171
+ // 获取角色树
1172
+ onTabsetRoleFlush(groupRoleCode) {
1173
+ this.onTabsetLoadStart();
1174
+ this.subs.push(this.contact.getGroupRole(groupRoleCode).subscribe((roles) => {
1175
+ this.expandTree(roles);
1176
+ this.nzRoles = roles;
1177
+ this._nzRolesCopy = roles;
1178
+ this.onTabsetLoadEnd();
1179
+ this.refresh();
1180
+ }));
1181
+ }
1182
+ // 获取好友分组列表
1183
+ onTabsetFriendGroupFlush() {
1184
+ this.onTabsetLoadStart();
1185
+ this.subs.push(this.contact.getFriendGroup().subscribe((group) => {
1186
+ this.nzFriendGroups = group;
1187
+ this._nzFriendGroupsCopy = group;
1188
+ this.onTabsetLoadEnd();
1189
+ this.refresh();
1190
+ }));
1191
+ }
1192
+ /**
1193
+ * 部门树点击
1194
+ *
1195
+ * @param e 节点
1196
+ */
1197
+ onDeptClick(e) {
1198
+ var _a;
1199
+ // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1200
+ this.st.data = '/auth/baseUser/queryListForPage';
1201
+ this.st.req = {
1202
+ allInBody: true,
1203
+ method: 'POST',
1204
+ type: 'page',
1205
+ reName: {
1206
+ pi: 'pageNum',
1207
+ ps: 'pageSize'
1208
+ },
1209
+ body: {
1210
+ pageParam: {
1211
+ deptId: (_a = e.keys) === null || _a === void 0 ? void 0 : _a.pop()
1212
+ }
1213
+ }
1214
+ };
1215
+ // table数据预处理
1216
+ this.st.res = {
1217
+ process: data => {
1218
+ this.onTableCheck(data);
1219
+ return data;
1220
+ }
1221
+ };
1222
+ // 加载第一页
1223
+ this.st.load(1);
1224
+ }
1225
+ /**
1226
+ * 角色树点击
1227
+ *
1228
+ * @param e 节点
1229
+ */
1230
+ onRoleClick(e) {
1231
+ var _a;
1232
+ // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1233
+ this.st.data = '/auth/baseUser/queryListForPage';
1234
+ this.st.req = {
1235
+ allInBody: true,
1236
+ method: 'POST',
1237
+ type: 'page',
1238
+ reName: {
1239
+ pi: 'pageNum',
1240
+ ps: 'pageSize'
1241
+ },
1242
+ body: {
1243
+ pageParam: {
1244
+ roleId: (_a = e.keys) === null || _a === void 0 ? void 0 : _a.pop()
1245
+ }
1246
+ }
1247
+ };
1248
+ // table数据预处理
1249
+ this.st.res = {
1250
+ process: data => {
1251
+ this.onTableCheck(data);
1252
+ return data;
1253
+ }
1254
+ };
1255
+ // 加载第一页
1256
+ this.st.load(1);
1257
+ }
1258
+ /**
1259
+ * 好友分组点击
1260
+ *
1261
+ * @param e 分组
1262
+ */
1263
+ onFriendGroupClick(e) {
1264
+ // 构造分页请求,直接传入stTable组件,剩下的所有交给组件自己完成
1265
+ this.st.data = '/auth/baseUser/queryListForPage';
1266
+ this.st.req = {
1267
+ allInBody: true,
1268
+ method: 'POST',
1269
+ type: 'page',
1270
+ reName: {
1271
+ pi: 'pageNum',
1272
+ ps: 'pageSize'
1273
+ },
1274
+ body: {
1275
+ pageParam: {
1276
+ friendGroupId: e.id
1277
+ }
1278
+ }
1279
+ };
1280
+ // table数据预处理
1281
+ this.st.res = {
1282
+ process: data => {
1283
+ this.onTableCheck(data);
1284
+ return data;
1285
+ }
1286
+ };
1287
+ // 加载第一页
1288
+ this.st.load(1);
1289
+ }
1290
+ /**
1291
+ * 点击右侧联系人进行删除
1292
+ *
1293
+ * @param c 点击的联系人
1294
+ */
1295
+ onContactRemove(c) {
1296
+ this.nzContacts = this.nzContacts.filter(contact => {
1297
+ return contact.userId != c.userId;
1298
+ });
1299
+ this.st.reload();
1300
+ }
1301
+ /**
1302
+ * 预处理table当前页数据,和nzContat对比,确定checkbox状态
1303
+ *
1304
+ * @param data 预处理数据
1305
+ */
1306
+ onTableCheck(data) {
1307
+ const ids = this.nzContacts.map(u => u.userId);
1308
+ data.forEach(d => {
1309
+ if (ids.includes(d.userId)) {
1310
+ d.checked = true;
1311
+ }
1312
+ else {
1313
+ d.checked = false;
1314
+ }
1315
+ });
1316
+ }
1317
+ /**
1318
+ * 递归树寻找name相同节点
1319
+ *
1320
+ * @param name 名称
1321
+ * @param trees 需要递归的树
1322
+ * @param list 搜索结果
1323
+ */
1324
+ searchTree(name, trees, list) {
1325
+ if (trees && trees.length && trees.length > 0) {
1326
+ trees.forEach((tree) => {
1327
+ if (tree.title.indexOf(name) != -1) {
1328
+ list.push(tree);
1329
+ }
1330
+ if (tree.children) {
1331
+ this.searchTree(name, tree.children, list);
1332
+ }
1333
+ });
1334
+ }
1335
+ }
1336
+ /**
1337
+ * 递归树展开所有有子节点的节点
1338
+ *
1339
+ * @param trees 需要展开的树
1340
+ */
1341
+ expandTree(trees) {
1342
+ if (trees && trees.length && trees.length > 0) {
1343
+ trees.forEach(tree => {
1344
+ if (!tree.children || tree.children.length === 0) {
1345
+ tree.expanded = false;
1346
+ tree.isLeaf = true;
1347
+ }
1348
+ if (tree.children) {
1349
+ tree.expanded = this.nzExpandAll;
1350
+ tree.isLeaf = false;
1351
+ this.expandTree(tree.children);
1352
+ }
1353
+ });
1354
+ }
1355
+ }
1356
+ /**
1357
+ * 刷新当前页面
1358
+ */
1359
+ refresh() {
1360
+ this.changeDetectorRef.detectChanges();
1361
+ }
1362
+ /**
1363
+ * 确认按钮output数据
1364
+ */
1365
+ confirm() {
1366
+ this.confirmed.next(this.nzContacts);
1367
+ }
1368
+ /**
1369
+ * 销毁函数
1370
+ */
1371
+ ngOnDestroy() {
1372
+ this.nzDepts = [];
1373
+ this.nzRoles = [];
1374
+ this.nzContacts = [];
1375
+ this.subs.forEach(s => s.unsubscribe());
1376
+ }
1377
+ }
1378
+ ContactComponent.decorators = [
1379
+ { type: Component, args: [{
1380
+ selector: 'contact',
1381
+ template: "<nz-row [nzGutter]=\"16\">\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"8\" [nzXl]=\"6\" [nzXXl]=\"6\">\n <nz-tabset nzCentered>\n <nz-tab nzTitle=\"\u90E8\u95E8\" (nzSelect)=\"onTabsetDept()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('dept', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u90E8\u95E8\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onDeptClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzDeptTreeVirtualHeight\"\n [nzData]=\"nzDepts\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u89D2\u8272\" (nzSelect)=\"onTabsetRole()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('role', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-tree\n class=\"nz-tabset-content\"\n (nzClick)=\"onRoleClick($event)\"\n [nzBlockNode]=\"true\"\n [nzShowLine]=\"true\"\n [nzHideUnMatched]=\"true\"\n [nzVirtualHeight]=\"nzRoleTreeVirtualHeight\"\n [nzData]=\"nzRoles\"\n ></nz-tree>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n <nz-tab nzTitle=\"\u597D\u53CB\" (nzSelect)=\"onTabsetFriendGroup()\">\n <div sg-container=\"2\">\n <sg col=\"1\" class=\"nz-tabset-sg\">\n <nz-input-group class=\"nz-tabset-input\" [nzSuffix]=\"searchInputTpl\">\n <input\n nz-input\n [(ngModel)]=\"nzTabsetSearch\"\n (ngModelChange)=\"onTabsetSearchChange('friendGroup', $event)\"\n type=\"text\"\n placeholder=\"\u8BF7\u8F93\u5165\u597D\u53CB\u540D\u79F0\"\n />\n </nz-input-group>\n </sg>\n <sg col=\"1\">\n <nz-spin [nzSpinning]=\"nzTabsetLoading\">\n <nz-list class=\"nz-tabset-content\" nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let group of nzFriendGroups\"\n (click)=\"onFriendGroupClick(group)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ group.name }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </sg>\n </div>\n </nz-tab>\n </nz-tabset>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"16\" [nzXl]=\"13\" [nzXXl]=\"13\">\n <st #st responsiveHideHeaderFooter></st>\n </nz-col>\n\n <nz-col [nzXs]=\"24\" [nzSm]=\"24\" [nzMd]=\"24\" [nzLg]=\"24\" [nzXl]=\"5\" [nzXXl]=\"5\">\n <nz-spin [nzSpinning]=\"nzContactLoading\">\n <nz-list nzItemLayout=\"horizontal\" [nzSplit]=\"false\" nzSize=\"small\">\n <nz-list-item\n class=\"nz-tabset-content-item\"\n *ngFor=\"let contact of nzContacts\"\n (click)=\"onContactRemove(contact)\"\n >\n <nz-list-item-meta>\n <nz-list-item-meta-title>\n {{ contact.realName }}\n </nz-list-item-meta-title>\n </nz-list-item-meta>\n </nz-list-item>\n </nz-list>\n </nz-spin>\n </nz-col>\n</nz-row>\n\n<nz-row *ngIf=\"button\">\n <nz-col [nzSpan]=\"4\" [nzOffset]=\"20\">\n <button nz-button nzType=\"primary\" (click)=\"confirm()\">\u786E\u5B9A</button>\n </nz-col>\n</nz-row>\n\n<ng-template #searchInputTpl>\n <i nz-icon nzType=\"close\" nzTheme=\"outline\" *ngIf=\"nzTabsetSearch\" (click)=\"onTabsetSearchClean()\"></i>\n <i nz-icon nzType=\"search\" nzTheme=\"outline\" *ngIf=\"!nzTabsetSearch\"></i>\n</ng-template>\n",
1382
+ styles: [".nz-tabset-input{width:100%}.nz-tabset-content{padding:20px}.nz-tabset-sg{padding-right:38px!important;padding-left:38px!important}.nz-tabset-content-item:hover{background-color:#f1f1f1;cursor:pointer}\n"]
1383
+ },] }
1384
+ ];
1385
+ ContactComponent.ctorParameters = () => [
1386
+ { type: ContactService },
1387
+ { type: ChangeDetectorRef }
1388
+ ];
1389
+ ContactComponent.propDecorators = {
1390
+ nzTabsetSearch: [{ type: Optional }, { type: Input }],
1391
+ nzTabsetLoading: [{ type: Optional }, { type: Input }],
1392
+ nzExpandAll: [{ type: Optional }, { type: Input }],
1393
+ nzDepts: [{ type: Optional }, { type: Input }],
1394
+ nzDeptTreeVirtualHeight: [{ type: Optional }, { type: Input }],
1395
+ nzDeptClass: [{ type: Optional }, { type: Input }],
1396
+ nzDeptClassHistory: [{ type: Optional }, { type: Input }],
1397
+ nzDeptGrade: [{ type: Optional }, { type: Input }],
1398
+ nzDeptGradeID: [{ type: Optional }, { type: Input }],
1399
+ nzRoles: [{ type: Optional }, { type: Input }],
1400
+ nzRoleTreeVirtualHeight: [{ type: Optional }, { type: Input }],
1401
+ nzFriendGroups: [{ type: Optional }, { type: Input }],
1402
+ st: [{ type: ViewChild, args: ['st', { static: false },] }],
1403
+ defaultContacts: [{ type: Optional }, { type: Input }],
1404
+ nzContacts: [{ type: Optional }, { type: Input }],
1405
+ nzContactLoading: [{ type: Optional }, { type: Input }],
1406
+ button: [{ type: Optional }, { type: Input }],
1407
+ confirmed: [{ type: Output }]
849
1408
  };
850
- function mergeStompConfig(srv) {
851
- return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
852
- }
853
1409
 
854
- class YzStompService {
855
- constructor(csr, cache, injector, notification) {
856
- this.csr = csr;
857
- this.cache = cache;
858
- this.injector = injector;
859
- this.notification = notification;
860
- this.subs = [];
861
- if (!this.user) {
862
- this.user = this.cache.get('_yz_user', { mode: 'none' });
863
- }
864
- if (!this.config) {
865
- this.config = mergeStompConfig(this.csr);
866
- }
867
- if (!this.bisConfig) {
868
- this.bisConfig = mergeBisConfig(csr);
869
- }
870
- if (!this.rxStomp) {
871
- this.rxStomp = new RxStomp();
872
- if (isDevMode()) {
873
- log$1('yz.stomp.service: is dev mode');
874
- log$1('yz.stomp.service: ', `config is ${JSON.stringify(this.config)}`);
875
- this.rxStomp.configure(this.config);
876
- return;
877
- }
878
- const { location } = this.injector.get(DOCUMENT);
879
- const { protocol, host } = location;
880
- log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
881
- if (protocol.includes('http') && !protocol.includes('https')) {
882
- this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
883
- }
884
- if (protocol.includes('https')) {
885
- this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
886
- }
887
- log$1('yz.stomp.service: ', `config is ${this.config}`);
888
- this.rxStomp.configure(this.config);
889
- }
890
- }
891
- listen() {
892
- this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
893
- this.createNotification(JSON.parse(message.body));
894
- }));
895
- this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
896
- this.logoutNotification(JSON.parse(message.body));
897
- }));
898
- this.rxStomp.activate();
899
- }
900
- createNotification(message) {
901
- this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
902
- }
903
- logoutNotification(message) {
904
- this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
905
- setTimeout(() => {
906
- this.cache.clear();
907
- localStorage.clear();
908
- this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
909
- }, 5000);
910
- }
911
- unListen() {
912
- this.subs.forEach(s => s.unsubscribe());
913
- this.rxStomp.deactivate().then();
914
- }
915
- publish(parameters) {
916
- this.rxStomp.publish(parameters);
917
- }
918
- watch(destination, headers) {
919
- return this.rxStomp.watch(destination, headers);
920
- }
1410
+ const ɵ0 = msg => {
1411
+ log$1(msg);
1412
+ };
1413
+ const STOMP_DEFAULT_CONFIG = {
1414
+ connectHeaders: {
1415
+ login: 'guest',
1416
+ passcode: 'guest'
1417
+ },
1418
+ brokerURL: '/websocket/ws/',
1419
+ heartbeatIncoming: 1000 * 60,
1420
+ heartbeatOutgoing: 1000 * 60,
1421
+ reconnectDelay: 30000000,
1422
+ debug: ɵ0
1423
+ };
1424
+ function mergeStompConfig(srv) {
1425
+ return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
921
1426
  }
922
- YzStompService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzStompService_Factory() { return new YzStompService(i0.ɵɵinject(i4.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i3$1.NzNotificationService)); }, token: YzStompService, providedIn: "root" });
923
- YzStompService.decorators = [
924
- { type: Injectable, args: [{ providedIn: 'root' },] }
925
- ];
926
- YzStompService.ctorParameters = () => [
927
- { type: YunzaiConfigService$1 },
928
- { type: CacheService },
929
- { type: Injector },
930
- { type: NzNotificationService }
1427
+
1428
+ class YzStompService {
1429
+ constructor(csr, cache, injector, notification) {
1430
+ this.csr = csr;
1431
+ this.cache = cache;
1432
+ this.injector = injector;
1433
+ this.notification = notification;
1434
+ this.subs = [];
1435
+ if (!this.user) {
1436
+ this.user = this.cache.get('_yz_user', { mode: 'none' });
1437
+ }
1438
+ if (!this.config) {
1439
+ this.config = mergeStompConfig(this.csr);
1440
+ }
1441
+ if (!this.bisConfig) {
1442
+ this.bisConfig = mergeBisConfig(csr);
1443
+ }
1444
+ if (!this.rxStomp) {
1445
+ this.rxStomp = new RxStomp();
1446
+ if (isDevMode()) {
1447
+ log$1('yz.stomp.service: is dev mode');
1448
+ log$1('yz.stomp.service: ', `config is ${JSON.stringify(this.config)}`);
1449
+ this.rxStomp.configure(this.config);
1450
+ return;
1451
+ }
1452
+ const { location } = this.injector.get(DOCUMENT);
1453
+ const { protocol, host } = location;
1454
+ log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
1455
+ if (protocol.includes('http') && !protocol.includes('https')) {
1456
+ this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
1457
+ }
1458
+ if (protocol.includes('https')) {
1459
+ this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
1460
+ }
1461
+ log$1('yz.stomp.service: ', `config is ${this.config}`);
1462
+ this.rxStomp.configure(this.config);
1463
+ }
1464
+ }
1465
+ listen() {
1466
+ this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
1467
+ this.createNotification(JSON.parse(message.body));
1468
+ }));
1469
+ this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
1470
+ this.logoutNotification(JSON.parse(message.body));
1471
+ }));
1472
+ this.rxStomp.activate();
1473
+ }
1474
+ createNotification(message) {
1475
+ this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
1476
+ }
1477
+ logoutNotification(message) {
1478
+ this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
1479
+ setTimeout(() => {
1480
+ this.cache.clear();
1481
+ localStorage.clear();
1482
+ this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
1483
+ }, 5000);
1484
+ }
1485
+ unListen() {
1486
+ this.subs.forEach(s => s.unsubscribe());
1487
+ this.rxStomp.deactivate().then();
1488
+ }
1489
+ publish(parameters) {
1490
+ this.rxStomp.publish(parameters);
1491
+ }
1492
+ watch(destination, headers) {
1493
+ return this.rxStomp.watch(destination, headers);
1494
+ }
1495
+ }
1496
+ YzStompService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzStompService_Factory() { return new YzStompService(i0.ɵɵinject(i1$1.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i3$1.NzNotificationService)); }, token: YzStompService, providedIn: "root" });
1497
+ YzStompService.decorators = [
1498
+ { type: Injectable, args: [{ providedIn: 'root' },] }
1499
+ ];
1500
+ YzStompService.ctorParameters = () => [
1501
+ { type: YunzaiConfigService$1 },
1502
+ { type: CacheService },
1503
+ { type: Injector },
1504
+ { type: NzNotificationService }
931
1505
  ];
932
1506
 
933
- class YzLayoutBasicComponent {
934
- constructor(cacheService, yzStompService) {
935
- this.cacheService = cacheService;
936
- this.yzStompService = yzStompService;
937
- this.options = {
938
- logoExpanded: `./assets/logo-full.svg`,
939
- logoCollapsed: `./assets/logo.svg`
940
- };
941
- this.intro = '';
942
- this.text = '';
943
- this.icon = '';
944
- }
945
- ngOnInit() {
946
- const current = this.cacheService.get('_yz_current', { mode: 'none' });
947
- const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
948
- this.text = current.text ? current.text : '应用名称';
949
- this.intro = current.intro ? current.intro : '应用描述';
950
- this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
951
- this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
952
- this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
953
- this.yzStompService.listen();
954
- }
955
- ngOnDestroy() {
956
- this.yzStompService.unListen();
957
- }
958
- }
959
- YzLayoutBasicComponent.decorators = [
960
- { type: Component, args: [{
961
- selector: 'yz-layout-basic',
1507
+ class YzLayoutBasicComponent {
1508
+ constructor(cacheService, yzStompService) {
1509
+ this.cacheService = cacheService;
1510
+ this.yzStompService = yzStompService;
1511
+ this.options = {
1512
+ logoExpanded: `./assets/logo-full.svg`,
1513
+ logoCollapsed: `./assets/logo.svg`
1514
+ };
1515
+ this.intro = '';
1516
+ this.text = '';
1517
+ this.icon = '';
1518
+ }
1519
+ ngOnInit() {
1520
+ const current = this.cacheService.get('_yz_current', { mode: 'none' });
1521
+ const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
1522
+ this.text = current.text ? current.text : '应用名称';
1523
+ this.intro = current.intro ? current.intro : '应用描述';
1524
+ this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
1525
+ this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
1526
+ this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
1527
+ this.yzStompService.listen();
1528
+ }
1529
+ ngOnDestroy() {
1530
+ this.yzStompService.unListen();
1531
+ }
1532
+ }
1533
+ YzLayoutBasicComponent.decorators = [
1534
+ { type: Component, args: [{
1535
+ selector: 'yz-layout-basic',
962
1536
  template: `
963
1537
  <layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl">
964
1538
  <layout-default-header-item direction="left">
@@ -1019,509 +1593,862 @@ YzLayoutBasicComponent.decorators = [
1019
1593
  <router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
1020
1594
  </ng-template>
1021
1595
  </layout-default>
1022
- `,
1023
- changeDetection: ChangeDetectionStrategy.OnPush
1024
- },] }
1025
- ];
1026
- YzLayoutBasicComponent.ctorParameters = () => [
1027
- { type: CacheService },
1028
- { type: YzStompService }
1596
+ `,
1597
+ changeDetection: ChangeDetectionStrategy.OnPush
1598
+ },] }
1599
+ ];
1600
+ YzLayoutBasicComponent.ctorParameters = () => [
1601
+ { type: CacheService },
1602
+ { type: YzStompService }
1029
1603
  ];
1030
1604
 
1031
- const COMPONENTS = [
1032
- YzLayoutBasicComponent,
1033
- YzHeaderApplicationComponent,
1034
- YzHeaderNotifyComponent,
1035
- YzHeaderThemBtnComponent,
1036
- YzHeaderUserComponent,
1037
- YzHeaderFullScreenComponent,
1038
- YzHeaderClearStorageComponent,
1039
- YzHeaderI18NComponent
1040
- ];
1041
- class YunzaiLayoutModule {
1042
- }
1043
- YunzaiLayoutModule.decorators = [
1044
- { type: NgModule, args: [{
1045
- imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
1046
- providers: [
1047
- {
1048
- provide: YUNZAI_THEME_BTN_KEYS,
1049
- useValue: 'site-theme'
1050
- }
1051
- ],
1052
- declarations: [...COMPONENTS],
1053
- exports: [...COMPONENTS]
1054
- },] }
1605
+ /*
1606
+ * @Author: cui <devcui@outlook.com>
1607
+ * @Editor: microsoft vscode
1608
+ * @Date: 2021-11-27 11:30:50
1609
+ * @LastEditTime: 2021-11-27 14:38:46
1610
+ * @LastEditors: cui <devcui@outlook.com>
1611
+ * @Description: empty description
1612
+ * @FilePath: \yelon\packages\bis\layout\layout.module.ts
1613
+ * LICENSE HERE
1614
+ */
1615
+ const COMPONENTS = [
1616
+ ContactComponent,
1617
+ YzLayoutBasicComponent,
1618
+ YzHeaderApplicationComponent,
1619
+ YzHeaderNotifyComponent,
1620
+ YzHeaderThemBtnComponent,
1621
+ YzHeaderUserComponent,
1622
+ YzHeaderFullScreenComponent,
1623
+ YzHeaderClearStorageComponent,
1624
+ YzHeaderI18NComponent
1625
+ ];
1626
+ class YunzaiLayoutModule {
1627
+ }
1628
+ YunzaiLayoutModule.decorators = [
1629
+ { type: NgModule, args: [{
1630
+ imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
1631
+ providers: [
1632
+ {
1633
+ provide: YUNZAI_THEME_BTN_KEYS,
1634
+ useValue: 'site-theme'
1635
+ }
1636
+ ],
1637
+ declarations: [...COMPONENTS],
1638
+ exports: [...COMPONENTS]
1639
+ },] }
1055
1640
  ];
1056
1641
 
1057
- class YzAuthService {
1058
- constructor(injector) {
1059
- this.injector = injector;
1060
- this.option = mergeConfig(this.csr);
1061
- this.bis = mergeBisConfig(this.csr);
1062
- }
1063
- get csr() {
1064
- return this.injector.get(YunzaiConfigService);
1065
- }
1066
- get tokenService() {
1067
- return this.injector.get(YA_SERVICE_TOKEN);
1068
- }
1069
- get httpClient() {
1070
- return this.injector.get(_HttpClient);
1071
- }
1072
- get cacheService() {
1073
- return this.injector.get(CacheService);
1074
- }
1075
- askToken() {
1076
- var _a;
1077
- log('yz.auth.service: ', 'askToken');
1078
- if ((_a = this.tokenService.get()) === null || _a === void 0 ? void 0 : _a.token) {
1079
- return of(this.tokenService.get());
1080
- }
1081
- else {
1082
- if (this.bis.loginForm) {
1083
- return this.fetchTokenByUP();
1084
- }
1085
- else {
1086
- return this.fetchTokenByCas();
1087
- }
1088
- }
1089
- }
1090
- fetchTokenByUP() {
1091
- log('yz.auth.service: ', 'fetchTokenByUP');
1092
- return this.httpClient.post(`/auth/oauth/token?_allow_anonymous=true`, this.bis.loginForm).pipe(map((response) => {
1093
- const { access_token, expires_in, refresh_token, scope, token_type } = response;
1094
- return {
1095
- token: access_token,
1096
- expired: expires_in,
1097
- refreshToken: refresh_token,
1098
- tokenType: token_type,
1099
- scope
1100
- };
1101
- }));
1102
- }
1103
- fetchTokenByCas() {
1104
- log('yz.auth.service: ', 'fetchTokenByCas');
1105
- const uri = encodeURIComponent(this.injector.get(WINDOW).location.href);
1106
- return this.httpClient
1107
- .get(`/cas-proxy/app/validate_full?callback=${uri}&_allow_anonymous=true&timestamp=${new Date().getTime()}`)
1108
- .pipe(map((response) => {
1109
- switch (response.errcode) {
1110
- case 2000:
1111
- const { access_token, expires_in, refresh_token, scope, token_type } = response.data;
1112
- return {
1113
- token: access_token,
1114
- expired: expires_in,
1115
- refreshToken: refresh_token,
1116
- tokenType: token_type,
1117
- scope
1118
- };
1119
- case 2001:
1120
- this.injector.get(WINDOW).location.href = response.msg;
1121
- throw Error("Cookie Error: Can't find Cas Cookie,So jump to login!");
1122
- default:
1123
- if (response.data) {
1124
- console.error(response.data);
1125
- throw Error(response.data);
1126
- }
1127
- else if (response.msg) {
1128
- console.error(response.msg);
1129
- throw Error(response.msg);
1130
- }
1131
- else {
1132
- console.error('cas unknown error');
1133
- throw Error('Unknown Error: Cas auth exception!');
1134
- }
1135
- }
1136
- }));
1137
- }
1138
- login() {
1139
- log('yz.auth.service: ', 'login white login form->', this.bis.loginForm);
1140
- return this.askToken().pipe(mergeMap(token => {
1141
- log('yz.auth.service: get token->', token);
1142
- this.csr.set('auth', {
1143
- token_send_key: 'Authorization',
1144
- token_send_template: `${token.tokenType} \${token}`,
1145
- token_send_place: 'header'
1146
- });
1147
- log('yz.auth.service: ', 'set token');
1148
- this.tokenService.set(token);
1149
- return this.cacheInit();
1150
- }), mergeAll());
1151
- }
1152
- cacheInit() {
1153
- log('yz.auth.service: ', 'cacheInit');
1154
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
1155
- const header = this.cacheService.get('_yz_header', { mode: 'none' });
1156
- const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
1157
- return forkJoin(of(user), of(header), of(project)).pipe(mergeMap(([u, h, p]) => {
1158
- let list = [];
1159
- // user cache
1160
- if (!u) {
1161
- log('yz.auth.service: ', 'fetch user cache');
1162
- list.push(this.httpClient.get(`/auth/user`).pipe(map((user) => {
1163
- this.cacheService.set('_yz_user', user.principal);
1164
- })));
1165
- }
1166
- else {
1167
- log('yz.auth.service: ', 'user recache');
1168
- list.push(of(() => { }));
1169
- }
1170
- // header cache
1171
- if (!h) {
1172
- log('yz.auth.service: ', 'fetch header cache');
1173
- list.push(this.httpClient.get(`/auth/allheader/v2`).pipe(map((header) => {
1174
- this.cacheService.set('_yz_header', header.data);
1175
- })));
1176
- }
1177
- else {
1178
- log('yz.auth.service: ', 'header recache');
1179
- list.push(of(() => { }));
1180
- }
1181
- // project cache
1182
- if (!p) {
1183
- log('yz.auth.service: ', 'fetch project cache');
1184
- list.push(this.httpClient.get(`/app-manager/project/info`).pipe(map((info) => {
1185
- this.cacheService.set('_yz_project_info', info.data);
1186
- })));
1187
- }
1188
- else {
1189
- log('yz.auth.service: ', 'project recache');
1190
- list.push(of(() => { }));
1191
- }
1192
- return forkJoin(list);
1193
- }));
1194
- }
1195
- }
1196
- YzAuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzAuthService_Factory() { return new YzAuthService(i0.ɵɵinject(i0.INJECTOR)); }, token: YzAuthService, providedIn: "root" });
1197
- YzAuthService.decorators = [
1198
- { type: Injectable, args: [{ providedIn: 'root' },] }
1199
- ];
1200
- YzAuthService.ctorParameters = () => [
1201
- { type: Injector }
1642
+ class YzAuthService {
1643
+ constructor(injector) {
1644
+ this.injector = injector;
1645
+ this.option = mergeConfig(this.csr);
1646
+ this.bis = mergeBisConfig(this.csr);
1647
+ }
1648
+ get csr() {
1649
+ return this.injector.get(YunzaiConfigService);
1650
+ }
1651
+ get tokenService() {
1652
+ return this.injector.get(YA_SERVICE_TOKEN);
1653
+ }
1654
+ get httpClient() {
1655
+ return this.injector.get(_HttpClient);
1656
+ }
1657
+ get cacheService() {
1658
+ return this.injector.get(CacheService);
1659
+ }
1660
+ askToken() {
1661
+ var _a;
1662
+ log('yz.auth.service: ', 'askToken');
1663
+ if ((_a = this.tokenService.get()) === null || _a === void 0 ? void 0 : _a.token) {
1664
+ return of(this.tokenService.get());
1665
+ }
1666
+ else {
1667
+ if (this.bis.loginForm) {
1668
+ return this.fetchTokenByUP();
1669
+ }
1670
+ else {
1671
+ return this.fetchTokenByCas();
1672
+ }
1673
+ }
1674
+ }
1675
+ fetchTokenByUP() {
1676
+ log('yz.auth.service: ', 'fetchTokenByUP');
1677
+ return this.httpClient.post(`/auth/oauth/token?_allow_anonymous=true`, this.bis.loginForm).pipe(map((response) => {
1678
+ const { access_token, expires_in, refresh_token, scope, token_type } = response;
1679
+ return {
1680
+ token: access_token,
1681
+ expired: expires_in,
1682
+ refreshToken: refresh_token,
1683
+ tokenType: token_type,
1684
+ scope
1685
+ };
1686
+ }));
1687
+ }
1688
+ fetchTokenByCas() {
1689
+ log('yz.auth.service: ', 'fetchTokenByCas');
1690
+ const uri = encodeURIComponent(this.injector.get(WINDOW).location.href);
1691
+ return this.httpClient
1692
+ .get(`/cas-proxy/app/validate_full?callback=${uri}&_allow_anonymous=true&timestamp=${new Date().getTime()}`)
1693
+ .pipe(map((response) => {
1694
+ switch (response.errcode) {
1695
+ case 2000:
1696
+ const { access_token, expires_in, refresh_token, scope, token_type } = response.data;
1697
+ return {
1698
+ token: access_token,
1699
+ expired: expires_in,
1700
+ refreshToken: refresh_token,
1701
+ tokenType: token_type,
1702
+ scope
1703
+ };
1704
+ case 2001:
1705
+ this.injector.get(WINDOW).location.href = response.msg;
1706
+ throw Error("Cookie Error: Can't find Cas Cookie,So jump to login!");
1707
+ default:
1708
+ if (response.data) {
1709
+ console.error(response.data);
1710
+ throw Error(response.data);
1711
+ }
1712
+ else if (response.msg) {
1713
+ console.error(response.msg);
1714
+ throw Error(response.msg);
1715
+ }
1716
+ else {
1717
+ console.error('cas unknown error');
1718
+ throw Error('Unknown Error: Cas auth exception!');
1719
+ }
1720
+ }
1721
+ }));
1722
+ }
1723
+ login() {
1724
+ log('yz.auth.service: ', 'login white login form->', this.bis.loginForm);
1725
+ return this.askToken().pipe(mergeMap(token => {
1726
+ log('yz.auth.service: get token->', token);
1727
+ this.csr.set('auth', {
1728
+ token_send_key: 'Authorization',
1729
+ token_send_template: `${token.tokenType} \${token}`,
1730
+ token_send_place: 'header'
1731
+ });
1732
+ log('yz.auth.service: ', 'set token');
1733
+ this.tokenService.set(token);
1734
+ return this.cacheInit();
1735
+ }), mergeAll());
1736
+ }
1737
+ cacheInit() {
1738
+ log('yz.auth.service: ', 'cacheInit');
1739
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
1740
+ const header = this.cacheService.get('_yz_header', { mode: 'none' });
1741
+ const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
1742
+ return forkJoin(of(user), of(header), of(project)).pipe(mergeMap(([u, h, p]) => {
1743
+ let list = [];
1744
+ // user cache
1745
+ if (!u) {
1746
+ log('yz.auth.service: ', 'fetch user cache');
1747
+ list.push(this.httpClient.get(`/auth/user`).pipe(map((user) => {
1748
+ this.cacheService.set('_yz_user', user.principal);
1749
+ })));
1750
+ }
1751
+ else {
1752
+ log('yz.auth.service: ', 'user recache');
1753
+ list.push(of(() => { }));
1754
+ }
1755
+ // header cache
1756
+ if (!h) {
1757
+ log('yz.auth.service: ', 'fetch header cache');
1758
+ list.push(this.httpClient.get(`/auth/allheader/v2`).pipe(map((header) => {
1759
+ this.cacheService.set('_yz_header', header.data);
1760
+ })));
1761
+ }
1762
+ else {
1763
+ log('yz.auth.service: ', 'header recache');
1764
+ list.push(of(() => { }));
1765
+ }
1766
+ // project cache
1767
+ if (!p) {
1768
+ log('yz.auth.service: ', 'fetch project cache');
1769
+ list.push(this.httpClient.get(`/app-manager/project/info`).pipe(map((info) => {
1770
+ this.cacheService.set('_yz_project_info', info.data);
1771
+ })));
1772
+ }
1773
+ else {
1774
+ log('yz.auth.service: ', 'project recache');
1775
+ list.push(of(() => { }));
1776
+ }
1777
+ return forkJoin(list);
1778
+ }));
1779
+ }
1780
+ }
1781
+ YzAuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzAuthService_Factory() { return new YzAuthService(i0.ɵɵinject(i0.INJECTOR)); }, token: YzAuthService, providedIn: "root" });
1782
+ YzAuthService.decorators = [
1783
+ { type: Injectable, args: [{ providedIn: 'root' },] }
1784
+ ];
1785
+ YzAuthService.ctorParameters = () => [
1786
+ { type: Injector }
1202
1787
  ];
1203
1788
 
1204
- const CODEMESSAGE = {
1205
- 200: '服务器成功返回请求的数据。',
1206
- 201: '新建或修改数据成功。',
1207
- 202: '一个请求已经进入后台排队(异步任务)。',
1208
- 204: '删除数据成功。',
1209
- 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
1210
- 401: '用户没有权限(令牌、用户名、密码错误)。',
1211
- 403: '用户得到授权,但是访问是被禁止的。',
1212
- 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
1213
- 406: '请求的格式不可得。',
1214
- 410: '请求的资源被永久删除,且不会再得到的。',
1215
- 422: '当创建一个对象时,发生一个验证错误。',
1216
- 500: '服务器发生错误,请检查服务器。',
1217
- 502: '网关错误。',
1218
- 503: '服务不可用,服务器暂时过载或维护。',
1219
- 504: '网关超时。'
1220
- };
1221
- /**
1222
- * 默认HTTP拦截器,其注册细节见 `app.module.ts`
1223
- */
1224
- class YzDefaultInterceptor {
1225
- constructor(injector) {
1226
- this.injector = injector;
1227
- this.jump = false;
1228
- this.refreshToking = false;
1229
- this.refreshToken$ = new BehaviorSubject(null);
1230
- if (this.config.refreshTokenType === 'auth-refresh') {
1231
- console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
1232
- }
1233
- }
1234
- get notification() {
1235
- return this.injector.get(NzNotificationService);
1236
- }
1237
- get tokenSrv() {
1238
- return this.injector.get(YA_SERVICE_TOKEN);
1239
- }
1240
- get http() {
1241
- return this.injector.get(_HttpClient);
1242
- }
1243
- get config() {
1244
- return mergeBisConfig(this.injector.get(YunzaiConfigService));
1245
- }
1246
- goTo(url) {
1247
- setTimeout(() => this.injector.get(Router).navigateByUrl(url));
1248
- }
1249
- checkStatus(ev) {
1250
- if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
1251
- return;
1252
- }
1253
- if (ev instanceof HttpErrorResponse && (ev.error.message || ev.error.errorMessage)) {
1254
- if (ev.error.errorMessage) {
1255
- this.notification.error(`发生了一些错误 `, ev.error.errorMessage);
1256
- }
1257
- else {
1258
- this.notification.error(`发生了一些错误 `, ev.error.message);
1259
- }
1260
- return;
1261
- }
1262
- if (ev instanceof HttpResponse && ev.body.errorMessage) {
1263
- this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
1264
- return;
1265
- }
1266
- const errortext = CODEMESSAGE[ev.status] || ev.statusText;
1267
- this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
1268
- }
1269
- ToLogin() {
1270
- this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
1271
- setTimeout(() => {
1272
- localStorage.clear();
1273
- this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
1274
- }, 5000);
1275
- }
1276
- reAttachToken(req) {
1277
- var _a;
1278
- const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
1279
- return req.clone({
1280
- setHeaders: {
1281
- Authorization: `Bearer ${token}`
1282
- }
1283
- });
1284
- }
1285
- refreshTokenRequest() {
1286
- const model = this.tokenSrv.get();
1287
- const form = new FormData();
1288
- form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
1289
- log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
1290
- return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
1291
- }
1292
- tryRefreshToken(ev, req, next) {
1293
- // 连刷新Token的请求都错了,那就是真错了
1294
- if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
1295
- this.ToLogin();
1296
- return throwError(ev);
1297
- }
1298
- // 正在刷新token,所有其他请求排队
1299
- if (this.refreshToking) {
1300
- return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
1301
- }
1302
- //尝试调用刷新 Token
1303
- this.refreshToking = true;
1304
- this.refreshToken$.next(null);
1305
- // 处理Token
1306
- return this.refreshTokenRequest().pipe(switchMap(res => {
1307
- log('yz.default.interceptor: refresh token accessed -> ', res);
1308
- // 重新保存新 token
1309
- const { access_token, expires_in, refresh_token, scope, token_type } = res;
1310
- this.tokenSrv.set({
1311
- token: access_token,
1312
- expired: expires_in,
1313
- refreshToken: refresh_token,
1314
- tokenType: token_type,
1315
- scope
1316
- });
1317
- // 通知后续请求继续执行
1318
- this.refreshToking = false;
1319
- this.refreshToken$.next(res);
1320
- // 重新发起请求
1321
- return next.handle(this.reAttachToken(req));
1322
- }), catchError(err => {
1323
- this.refreshToking = false;
1324
- this.ToLogin();
1325
- return throwError(err);
1326
- }));
1327
- }
1328
- getAdditionalHeaders(headers) {
1329
- const res = {};
1330
- const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
1331
- if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
1332
- res['Accept-Language'] = lang;
1333
- }
1334
- return res;
1335
- }
1336
- handleData(ev, req, next) {
1337
- this.checkStatus(ev);
1338
- switch (ev.status) {
1339
- case 200:
1340
- return of(ev);
1341
- case 401:
1342
- if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
1343
- return this.tryRefreshToken(ev, req, next);
1344
- }
1345
- this.ToLogin();
1346
- break;
1347
- case 403:
1348
- case 404:
1349
- case 500:
1350
- if (this.jump) {
1351
- this.goTo(`/exception/${ev.status}`);
1352
- }
1353
- break;
1354
- default:
1355
- if (ev instanceof HttpErrorResponse) {
1356
- console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
1357
- }
1358
- break;
1359
- }
1360
- if (ev instanceof HttpErrorResponse) {
1361
- return throwError(ev);
1362
- }
1363
- else {
1364
- return of(ev);
1365
- }
1366
- }
1367
- intercept(req, next) {
1368
- log('yz.default.interceptor.ts: ', 'request ', req);
1369
- // 统一加前缀
1370
- let url = req.url;
1371
- if (!url.startsWith('https://') && !url.startsWith('http://')) {
1372
- url = this.config.baseUrl + url;
1373
- }
1374
- if (url.includes('.json') && url.includes('assets')) {
1375
- url = req.url;
1376
- }
1377
- // 加入语言头
1378
- const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
1379
- return next.handle(newReq).pipe(mergeMap(ev => {
1380
- // 允许统一对请求错误处理
1381
- if (ev instanceof HttpResponseBase) {
1382
- return this.handleData(ev, newReq, next);
1383
- }
1384
- // 若一切都正常,则后续操作
1385
- return of(ev);
1386
- }), catchError((err) => this.handleData(err, newReq, next)));
1387
- }
1388
- }
1389
- YzDefaultInterceptor.decorators = [
1390
- { type: Injectable }
1391
- ];
1392
- YzDefaultInterceptor.ctorParameters = () => [
1393
- { type: Injector }
1789
+ const CODEMESSAGE = {
1790
+ 200: '服务器成功返回请求的数据。',
1791
+ 201: '新建或修改数据成功。',
1792
+ 202: '一个请求已经进入后台排队(异步任务)。',
1793
+ 204: '删除数据成功。',
1794
+ 400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
1795
+ 401: '用户没有权限(令牌、用户名、密码错误)。',
1796
+ 403: '用户得到授权,但是访问是被禁止的。',
1797
+ 404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
1798
+ 406: '请求的格式不可得。',
1799
+ 410: '请求的资源被永久删除,且不会再得到的。',
1800
+ 422: '当创建一个对象时,发生一个验证错误。',
1801
+ 500: '服务器发生错误,请检查服务器。',
1802
+ 502: '网关错误。',
1803
+ 503: '服务不可用,服务器暂时过载或维护。',
1804
+ 504: '网关超时。'
1805
+ };
1806
+ /**
1807
+ * 默认HTTP拦截器,其注册细节见 `app.module.ts`
1808
+ */
1809
+ class YzDefaultInterceptor {
1810
+ constructor(injector) {
1811
+ this.injector = injector;
1812
+ this.jump = false;
1813
+ this.refreshToking = false;
1814
+ this.refreshToken$ = new BehaviorSubject(null);
1815
+ if (this.config.refreshTokenType === 'auth-refresh') {
1816
+ console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
1817
+ }
1818
+ }
1819
+ get notification() {
1820
+ return this.injector.get(NzNotificationService);
1821
+ }
1822
+ get tokenSrv() {
1823
+ return this.injector.get(YA_SERVICE_TOKEN);
1824
+ }
1825
+ get http() {
1826
+ return this.injector.get(_HttpClient);
1827
+ }
1828
+ get config() {
1829
+ return mergeBisConfig(this.injector.get(YunzaiConfigService));
1830
+ }
1831
+ goTo(url) {
1832
+ setTimeout(() => this.injector.get(Router).navigateByUrl(url));
1833
+ }
1834
+ checkStatus(ev) {
1835
+ if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
1836
+ return;
1837
+ }
1838
+ if (ev instanceof HttpErrorResponse && (ev.error.message || ev.error.errorMessage)) {
1839
+ if (ev.error.errorMessage) {
1840
+ this.notification.error(`发生了一些错误 `, ev.error.errorMessage);
1841
+ }
1842
+ else {
1843
+ this.notification.error(`发生了一些错误 `, ev.error.message);
1844
+ }
1845
+ return;
1846
+ }
1847
+ if (ev instanceof HttpResponse && ev.body.errorMessage) {
1848
+ this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
1849
+ return;
1850
+ }
1851
+ const errortext = CODEMESSAGE[ev.status] || ev.statusText;
1852
+ this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
1853
+ }
1854
+ ToLogin() {
1855
+ this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
1856
+ setTimeout(() => {
1857
+ localStorage.clear();
1858
+ this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
1859
+ }, 5000);
1860
+ }
1861
+ reAttachToken(req) {
1862
+ var _a;
1863
+ const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
1864
+ return req.clone({
1865
+ setHeaders: {
1866
+ Authorization: `Bearer ${token}`
1867
+ }
1868
+ });
1869
+ }
1870
+ refreshTokenRequest() {
1871
+ const model = this.tokenSrv.get();
1872
+ const form = new FormData();
1873
+ form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
1874
+ log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
1875
+ return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
1876
+ }
1877
+ tryRefreshToken(ev, req, next) {
1878
+ // 连刷新Token的请求都错了,那就是真错了
1879
+ if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
1880
+ this.ToLogin();
1881
+ return throwError(ev);
1882
+ }
1883
+ // 正在刷新token,所有其他请求排队
1884
+ if (this.refreshToking) {
1885
+ return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
1886
+ }
1887
+ //尝试调用刷新 Token
1888
+ this.refreshToking = true;
1889
+ this.refreshToken$.next(null);
1890
+ // 处理Token
1891
+ return this.refreshTokenRequest().pipe(switchMap(res => {
1892
+ log('yz.default.interceptor: refresh token accessed -> ', res);
1893
+ // 重新保存新 token
1894
+ const { access_token, expires_in, refresh_token, scope, token_type } = res;
1895
+ this.tokenSrv.set({
1896
+ token: access_token,
1897
+ expired: expires_in,
1898
+ refreshToken: refresh_token,
1899
+ tokenType: token_type,
1900
+ scope
1901
+ });
1902
+ // 通知后续请求继续执行
1903
+ this.refreshToking = false;
1904
+ this.refreshToken$.next(res);
1905
+ // 重新发起请求
1906
+ return next.handle(this.reAttachToken(req));
1907
+ }), catchError(err => {
1908
+ this.refreshToking = false;
1909
+ this.ToLogin();
1910
+ return throwError(err);
1911
+ }));
1912
+ }
1913
+ getAdditionalHeaders(headers) {
1914
+ const res = {};
1915
+ const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
1916
+ if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
1917
+ res['Accept-Language'] = lang;
1918
+ }
1919
+ return res;
1920
+ }
1921
+ handleData(ev, req, next) {
1922
+ this.checkStatus(ev);
1923
+ switch (ev.status) {
1924
+ case 200:
1925
+ return of(ev);
1926
+ case 401:
1927
+ if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
1928
+ return this.tryRefreshToken(ev, req, next);
1929
+ }
1930
+ this.ToLogin();
1931
+ break;
1932
+ case 403:
1933
+ case 404:
1934
+ case 500:
1935
+ if (this.jump) {
1936
+ this.goTo(`/exception/${ev.status}`);
1937
+ }
1938
+ break;
1939
+ default:
1940
+ if (ev instanceof HttpErrorResponse) {
1941
+ console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
1942
+ }
1943
+ break;
1944
+ }
1945
+ if (ev instanceof HttpErrorResponse) {
1946
+ return throwError(ev);
1947
+ }
1948
+ else {
1949
+ return of(ev);
1950
+ }
1951
+ }
1952
+ intercept(req, next) {
1953
+ log('yz.default.interceptor.ts: ', 'request ', req);
1954
+ // 统一加前缀
1955
+ let url = req.url;
1956
+ if (!url.startsWith('https://') && !url.startsWith('http://')) {
1957
+ url = this.config.baseUrl + url;
1958
+ }
1959
+ if (url.includes('.json') && url.includes('assets')) {
1960
+ url = req.url;
1961
+ }
1962
+ // 加入语言头
1963
+ const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
1964
+ return next.handle(newReq).pipe(mergeMap(ev => {
1965
+ // 允许统一对请求错误处理
1966
+ if (ev instanceof HttpResponseBase) {
1967
+ return this.handleData(ev, newReq, next);
1968
+ }
1969
+ // 若一切都正常,则后续操作
1970
+ return of(ev);
1971
+ }), catchError((err) => this.handleData(err, newReq, next)));
1972
+ }
1973
+ }
1974
+ YzDefaultInterceptor.decorators = [
1975
+ { type: Injectable }
1976
+ ];
1977
+ YzDefaultInterceptor.ctorParameters = () => [
1978
+ { type: Injector }
1394
1979
  ];
1395
1980
 
1396
- function mapYzSideToYelonMenu(menus) {
1397
- menus.forEach(menu => {
1398
- menu.badgeDot = menu.badge_dot || null;
1399
- menu.badgeStatus = menu.badge_status || null;
1400
- menu.shortcutRoot = menu.shortcut_root || null;
1401
- menu.reuse = true;
1402
- if (menu.children) {
1403
- mapYzSideToYelonMenu(menu.children);
1404
- }
1405
- });
1406
- }
1407
- function generateAbility(menus, abilities, prefix) {
1408
- menus.forEach(menu => {
1409
- if (menu.link) {
1410
- prefix += menu.link;
1411
- }
1412
- else {
1413
- prefix += '';
1414
- }
1415
- if (menu.menuAuths) {
1416
- menu.menuAuths.forEach((a) => {
1417
- abilities.push(`${prefix}:${a}`);
1418
- abilities.push(a);
1419
- });
1420
- }
1421
- if (menu.children) {
1422
- generateAbility(menu.children, abilities, prefix);
1423
- }
1424
- });
1425
- }
1426
- class YzStartupService {
1427
- constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
1428
- this.menuService = menuService;
1429
- this.i18n = i18n;
1430
- this.settingService = settingService;
1431
- this.aclService = aclService;
1432
- this.titleService = titleService;
1433
- this.yzAuthService = yzAuthService;
1434
- this.cacheService = cacheService;
1435
- this.configService = configService;
1436
- this.bis = BUSINESS_DEFAULT_CONFIG;
1437
- this.bis = mergeBisConfig(this.configService);
1438
- iconSrv.addIcon(...ICONS);
1439
- }
1440
- load() {
1441
- log$1('startup.service: ', 'load');
1442
- const defaultLang = this.i18n.defaultLang;
1443
- return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
1444
- log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
1445
- this.i18n.use(defaultLang, langData);
1446
- return of(null);
1447
- }), mergeMap(() => {
1448
- return this.yzAuthService.login();
1449
- }), mergeMap(v => {
1450
- // preloader finish
1451
- this.systemInit();
1452
- log$1('startup.service: preloader finish');
1453
- const win = window;
1454
- if (win && win.appBootstrap) {
1455
- win.appBootstrap();
1456
- }
1457
- return of(v);
1458
- }));
1459
- }
1460
- systemInit() {
1461
- log$1('startup.service: system init');
1462
- // user
1463
- const user = this.cacheService.get('_yz_user', { mode: 'none' });
1464
- // menu
1465
- const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
1466
- mapYzSideToYelonMenu(ms);
1467
- const currentMenu = ms.pop();
1468
- this.menuService.add([currentMenu]);
1469
- // logo app
1470
- this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
1471
- this.settingService.setUser({
1472
- name: user.realname || 'no name',
1473
- avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
1474
- email: user.email || 'no email'
1475
- });
1476
- // title
1477
- this.titleService.default = currentMenu.text || 'default application name';
1478
- this.titleService.setTitle(currentMenu.text || 'no title');
1479
- // acl
1480
- const abilities = [];
1481
- generateAbility([currentMenu], abilities, '');
1482
- this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
1483
- return role.roleValue;
1484
- }).filter((a) => !!a)) || []);
1485
- this.aclService.attachAbility(abilities);
1486
- // cache current
1487
- this.cacheService.set('_yz_current', {
1488
- text: currentMenu.text,
1489
- intro: currentMenu.intro,
1490
- icon: currentMenu.appIconUrl
1491
- });
1492
- }
1493
- }
1494
- YzStartupService.decorators = [
1495
- { type: Injectable }
1496
- ];
1497
- YzStartupService.ctorParameters = () => [
1498
- { type: NzIconService },
1499
- { type: MenuService },
1500
- { type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
1501
- { type: SettingsService },
1502
- { type: ACLService },
1503
- { type: TitleService },
1504
- { type: YzAuthService },
1505
- { type: CacheService },
1506
- { type: YunzaiConfigService$1 }
1981
+ function mapYzSideToYelonMenu(menus) {
1982
+ menus.forEach(menu => {
1983
+ menu.badgeDot = menu.badge_dot || null;
1984
+ menu.badgeStatus = menu.badge_status || null;
1985
+ menu.shortcutRoot = menu.shortcut_root || null;
1986
+ menu.reuse = true;
1987
+ if (menu.children) {
1988
+ mapYzSideToYelonMenu(menu.children);
1989
+ }
1990
+ });
1991
+ }
1992
+ function generateAbility(menus, abilities, prefix) {
1993
+ menus.forEach(menu => {
1994
+ if (menu.link) {
1995
+ prefix += menu.link;
1996
+ }
1997
+ else {
1998
+ prefix += '';
1999
+ }
2000
+ if (menu.menuAuths) {
2001
+ menu.menuAuths.forEach((a) => {
2002
+ abilities.push(`${prefix}:${a}`);
2003
+ abilities.push(a);
2004
+ });
2005
+ }
2006
+ if (menu.children) {
2007
+ generateAbility(menu.children, abilities, prefix);
2008
+ }
2009
+ });
2010
+ }
2011
+ class YzStartupService {
2012
+ constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
2013
+ this.menuService = menuService;
2014
+ this.i18n = i18n;
2015
+ this.settingService = settingService;
2016
+ this.aclService = aclService;
2017
+ this.titleService = titleService;
2018
+ this.yzAuthService = yzAuthService;
2019
+ this.cacheService = cacheService;
2020
+ this.configService = configService;
2021
+ this.bis = BUSINESS_DEFAULT_CONFIG;
2022
+ this.bis = mergeBisConfig(this.configService);
2023
+ iconSrv.addIcon(...ICONS);
2024
+ }
2025
+ load() {
2026
+ log$1('startup.service: ', 'load');
2027
+ const defaultLang = this.i18n.defaultLang;
2028
+ return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
2029
+ log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
2030
+ this.i18n.use(defaultLang, langData);
2031
+ return of(null);
2032
+ }), mergeMap(() => {
2033
+ return this.yzAuthService.login();
2034
+ }), mergeMap(v => {
2035
+ // preloader finish
2036
+ this.systemInit();
2037
+ log$1('startup.service: preloader finish');
2038
+ const win = window;
2039
+ if (win && win.appBootstrap) {
2040
+ win.appBootstrap();
2041
+ }
2042
+ return of(v);
2043
+ }));
2044
+ }
2045
+ systemInit() {
2046
+ log$1('startup.service: system init');
2047
+ // user
2048
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
2049
+ // menu
2050
+ const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
2051
+ mapYzSideToYelonMenu(ms);
2052
+ const currentMenu = ms.pop();
2053
+ this.menuService.add([currentMenu]);
2054
+ // logo app
2055
+ this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
2056
+ this.settingService.setUser({
2057
+ name: user.realname || 'no name',
2058
+ avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
2059
+ email: user.email || 'no email'
2060
+ });
2061
+ // title
2062
+ this.titleService.default = currentMenu.text || 'default application name';
2063
+ this.titleService.setTitle(currentMenu.text || 'no title');
2064
+ // acl
2065
+ const abilities = [];
2066
+ generateAbility([currentMenu], abilities, '');
2067
+ this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
2068
+ return role.roleValue;
2069
+ }).filter((a) => !!a)) || []);
2070
+ this.aclService.attachAbility(abilities);
2071
+ // cache current
2072
+ this.cacheService.set('_yz_current', {
2073
+ text: currentMenu.text,
2074
+ intro: currentMenu.intro,
2075
+ icon: currentMenu.appIconUrl
2076
+ });
2077
+ }
2078
+ }
2079
+ YzStartupService.decorators = [
2080
+ { type: Injectable }
2081
+ ];
2082
+ YzStartupService.ctorParameters = () => [
2083
+ { type: NzIconService },
2084
+ { type: MenuService },
2085
+ { type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
2086
+ { type: SettingsService },
2087
+ { type: ACLService },
2088
+ { type: TitleService },
2089
+ { type: YzAuthService },
2090
+ { type: CacheService },
2091
+ { type: YunzaiConfigService$1 }
2092
+ ];
2093
+ function YzStartupServiceFactory(startupService) {
2094
+ return () => startupService.load();
2095
+ }
2096
+ //@ts-ignore
2097
+ const YZ_APPINIT_PROVIDES = [
2098
+ YzStartupService,
2099
+ {
2100
+ provide: APP_INITIALIZER,
2101
+ useFactory: YzStartupServiceFactory,
2102
+ deps: [YzStartupService],
2103
+ multi: true
2104
+ }
1507
2105
  ];
1508
- function YzStartupServiceFactory(startupService) {
1509
- return () => startupService.load();
1510
- }
1511
- //@ts-ignore
1512
- const YZ_APPINIT_PROVIDES = [
1513
- YzStartupService,
1514
- {
1515
- provide: APP_INITIALIZER,
1516
- useFactory: YzStartupServiceFactory,
1517
- deps: [YzStartupService],
1518
- multi: true
1519
- }
2106
+
2107
+ class PathToRegexpService {
2108
+ constructor() {
2109
+ this.DEFAULT_DELIMITER = '/';
2110
+ this.PATH_REGEXP = new RegExp(['(\\\\.)', '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'].join('|'), 'g');
2111
+ }
2112
+ parse(str, options) {
2113
+ const tokens = [];
2114
+ let key = 0;
2115
+ let index = 0;
2116
+ let path = '';
2117
+ const defaultDelimiter = (options && options.delimiter) || this.DEFAULT_DELIMITER;
2118
+ const whitelist = (options && options.whitelist) || undefined;
2119
+ let pathEscaped = false;
2120
+ let res;
2121
+ while ((res = this.PATH_REGEXP.exec(str)) !== null) {
2122
+ const m = res[0];
2123
+ const escaped = res[1];
2124
+ const offset = res.index;
2125
+ path += str.slice(index, offset);
2126
+ index = offset + m.length;
2127
+ // Ignore already escaped sequences.
2128
+ if (escaped) {
2129
+ path += escaped[1];
2130
+ pathEscaped = true;
2131
+ continue;
2132
+ }
2133
+ let prev = '';
2134
+ const name = res[2];
2135
+ const capture = res[3];
2136
+ const group = res[4];
2137
+ const modifier = res[5];
2138
+ if (!pathEscaped && path.length) {
2139
+ const k = path.length - 1;
2140
+ const c = path[k];
2141
+ const matches = whitelist ? whitelist.indexOf(c) > -1 : true;
2142
+ if (matches) {
2143
+ prev = c;
2144
+ path = path.slice(0, k);
2145
+ }
2146
+ }
2147
+ // Push the current path onto the tokens.
2148
+ if (path) {
2149
+ tokens.push(path);
2150
+ path = '';
2151
+ pathEscaped = false;
2152
+ }
2153
+ const repeat = modifier === '+' || modifier === '*';
2154
+ const optional = modifier === '?' || modifier === '*';
2155
+ const pattern = capture || group;
2156
+ const delimiter = prev || defaultDelimiter;
2157
+ tokens.push({
2158
+ name: name || key++,
2159
+ prefix: prev,
2160
+ delimiter: delimiter,
2161
+ optional: optional,
2162
+ repeat: repeat,
2163
+ pattern: pattern
2164
+ ? this.escapeGroup(pattern)
2165
+ : `[^${this.escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter)}]+?`
2166
+ });
2167
+ }
2168
+ // Push any remaining characters.
2169
+ if (path || index < str.length) {
2170
+ tokens.push(path + str.substr(index));
2171
+ }
2172
+ return tokens;
2173
+ }
2174
+ compile(str, options) {
2175
+ return this.tokensToFunction(this.parse(str, options), options);
2176
+ }
2177
+ tokensToFunction(tokens, options) {
2178
+ const matches = new Array(tokens.length);
2179
+ for (let i = 0; i < tokens.length; i++) {
2180
+ if (typeof tokens[i] === 'object') {
2181
+ matches[i] = new RegExp(`^(?:${tokens[i].pattern})$`, this.flags(options));
2182
+ }
2183
+ }
2184
+ return function (data, options) {
2185
+ let path = '';
2186
+ const encode = (options && options.encode) || encodeURIComponent;
2187
+ const validate = options ? options.validate !== false : true;
2188
+ for (let i = 0; i < tokens.length; i++) {
2189
+ const token = tokens[i];
2190
+ if (typeof token === 'string') {
2191
+ path += token;
2192
+ continue;
2193
+ }
2194
+ const value = data ? data[token.name] : undefined;
2195
+ let segment;
2196
+ if (Array.isArray(value)) {
2197
+ if (!token.repeat) {
2198
+ throw new TypeError(`Expected "${token.name}" to not repeat, but got array`);
2199
+ }
2200
+ if (value.length === 0) {
2201
+ if (token.optional) {
2202
+ continue;
2203
+ }
2204
+ throw new TypeError(`Expected "${token.name}" to not be empty`);
2205
+ }
2206
+ for (let j = 0; j < value.length; j++) {
2207
+ segment = encode(value[j], token);
2208
+ if (validate && !matches[i].test(segment)) {
2209
+ throw new TypeError(`Expected all "${token.name}" to match "${token.pattern}"`);
2210
+ }
2211
+ path += (j === 0 ? token.prefix : token.delimiter) + segment;
2212
+ }
2213
+ continue;
2214
+ }
2215
+ if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
2216
+ segment = encode(String(value), token);
2217
+ if (validate && !matches[i].test(segment)) {
2218
+ throw new TypeError(`Expected "${token.name}" to match "${token.pattern}", but got "${segment}"`);
2219
+ }
2220
+ path += token.prefix + segment;
2221
+ continue;
2222
+ }
2223
+ if (token.optional) {
2224
+ continue;
2225
+ }
2226
+ throw new TypeError(`Expected "${token.name}" to be ${token.repeat ? 'an array' : 'a string'}`);
2227
+ }
2228
+ return path;
2229
+ };
2230
+ }
2231
+ escapeString(str) {
2232
+ return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
2233
+ }
2234
+ escapeGroup(group) {
2235
+ return group.replace(/([=!:$/()])/g, '\\$1');
2236
+ }
2237
+ flags(options) {
2238
+ return options && options.sensitive ? '' : 'i';
2239
+ }
2240
+ regexpToRegexp(path, keys) {
2241
+ if (!keys) {
2242
+ return path;
2243
+ }
2244
+ const groups = path.source.match(/\((?!\?)/g);
2245
+ if (groups) {
2246
+ for (let i = 0; i < groups.length; i++) {
2247
+ keys.push({
2248
+ name: i,
2249
+ prefix: null,
2250
+ delimiter: null,
2251
+ optional: false,
2252
+ repeat: false,
2253
+ pattern: null
2254
+ });
2255
+ }
2256
+ }
2257
+ return path;
2258
+ }
2259
+ arrayToRegexp(path, keys, options) {
2260
+ const parts = [];
2261
+ for (let i = 0; i < path.length; i++) {
2262
+ parts.push(this.pathToRegexp(path[i], keys, options).source);
2263
+ }
2264
+ return new RegExp(`(?:${parts.join('|')})`, this.flags(options));
2265
+ }
2266
+ stringToRegexp(path, keys, options) {
2267
+ return this.tokensToRegExp(this.parse(path, options), keys, options);
2268
+ }
2269
+ tokensToRegExp(tokens, keys, options) {
2270
+ options = options || {};
2271
+ const strict = options.strict;
2272
+ const start = options.start !== false;
2273
+ const end = options.end !== false;
2274
+ const delimiter = options.delimiter || this.DEFAULT_DELIMITER;
2275
+ const endsWith = []
2276
+ .concat(options.endsWith || [])
2277
+ .map(this.escapeString)
2278
+ .concat('$')
2279
+ .join('|');
2280
+ let route = start ? '^' : '';
2281
+ for (let i = 0; i < tokens.length; i++) {
2282
+ const token = tokens[i];
2283
+ if (typeof token === 'string') {
2284
+ route += this.escapeString(token);
2285
+ }
2286
+ else {
2287
+ const capture = token.repeat
2288
+ ? `(?:${token.pattern})(?:${this.escapeString(token.delimiter)}(?:${token.pattern}))*`
2289
+ : token.pattern;
2290
+ if (keys) {
2291
+ keys.push(token);
2292
+ }
2293
+ if (token.optional) {
2294
+ if (!token.prefix) {
2295
+ route += `(${capture})?`;
2296
+ }
2297
+ else {
2298
+ route += `(?:${this.escapeString(token.prefix)}(${capture}))?`;
2299
+ }
2300
+ }
2301
+ else {
2302
+ route += `${this.escapeString(token.prefix)}(${capture})`;
2303
+ }
2304
+ }
2305
+ }
2306
+ if (end) {
2307
+ if (!strict) {
2308
+ route += `(?:${this.escapeString(delimiter)})?`;
2309
+ }
2310
+ route += endsWith === '$' ? '$' : `(?=${endsWith})`;
2311
+ }
2312
+ else {
2313
+ const endToken = tokens[tokens.length - 1];
2314
+ const isEndDelimited = typeof endToken === 'string' ? endToken[endToken.length - 1] === delimiter : endToken === undefined;
2315
+ if (!strict) {
2316
+ route += `(?:${this.escapeString(delimiter)}(?=${endsWith}))?`;
2317
+ }
2318
+ if (!isEndDelimited) {
2319
+ route += `(?=${this.escapeString(delimiter)}|${endsWith})`;
2320
+ }
2321
+ }
2322
+ return new RegExp(route, this.flags(options));
2323
+ }
2324
+ pathToRegexp(path, keys, options) {
2325
+ if (path instanceof RegExp) {
2326
+ return this.regexpToRegexp(path, keys);
2327
+ }
2328
+ if (Array.isArray(path)) {
2329
+ return this.arrayToRegexp(/** @type {!Array} */ path, keys, options);
2330
+ }
2331
+ return this.stringToRegexp(/** @type {string} */ path, keys, options);
2332
+ }
2333
+ }
2334
+ PathToRegexpService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PathToRegexpService_Factory() { return new PathToRegexpService(); }, token: PathToRegexpService, providedIn: "root" });
2335
+ PathToRegexpService.decorators = [
2336
+ { type: Injectable, args: [{
2337
+ providedIn: 'root'
2338
+ },] }
2339
+ ];
2340
+ PathToRegexpService.ctorParameters = () => [];
2341
+
2342
+ class ActGuard {
2343
+ constructor(configService, cacheService, pathToRegexp, router) {
2344
+ this.configService = configService;
2345
+ this.cacheService = cacheService;
2346
+ this.pathToRegexp = pathToRegexp;
2347
+ this.router = router;
2348
+ this.bis = BUSINESS_DEFAULT_CONFIG;
2349
+ this.menus = [];
2350
+ this.links = [];
2351
+ log$1('act: ');
2352
+ this.bis = mergeBisConfig(this.configService);
2353
+ log$1('act: config ', this.bis);
2354
+ const user = this.cacheService.get('_yz_user', { mode: 'none' });
2355
+ log$1('act: user ', user);
2356
+ this.menus = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
2357
+ log$1('act: menus ', this.menus);
2358
+ this.getAllLinks(this.menus, this.links);
2359
+ log$1('act: links ', this.links);
2360
+ }
2361
+ canActivate(_, state) {
2362
+ log$1('act: can activate ', state);
2363
+ if (this.preHandle(state)) {
2364
+ return true;
2365
+ }
2366
+ log$1('act: can activate child prehandle success');
2367
+ let canactivate = false;
2368
+ this.links.forEach((link) => {
2369
+ const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
2370
+ log$1(`act: ${link} test ${state.url.split('?')[0]}`);
2371
+ if (regexp.test(state.url.split('?')[0])) {
2372
+ canactivate = true;
2373
+ log$1(`act: test value ${canactivate}`);
2374
+ return;
2375
+ }
2376
+ });
2377
+ if (canactivate) {
2378
+ log$1(`act: test sucess`);
2379
+ return true;
2380
+ }
2381
+ else {
2382
+ log$1(`act: test error`);
2383
+ this.router.navigate(['displayIndex']);
2384
+ return false;
2385
+ }
2386
+ }
2387
+ canActivateChild(_, state) {
2388
+ log$1('act: can activate child ', state);
2389
+ if (this.preHandle(state)) {
2390
+ return true;
2391
+ }
2392
+ log$1('act: can activate child prehandle success');
2393
+ let canactivate = false;
2394
+ this.links.forEach((link) => {
2395
+ const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
2396
+ if (regexp.test(state.url.split('?')[0])) {
2397
+ log$1(`act: ${link} test ${state.url.split('?')[0]}`);
2398
+ canactivate = true;
2399
+ log$1(`act: test value ${canactivate}`);
2400
+ return;
2401
+ }
2402
+ });
2403
+ if (canactivate) {
2404
+ log$1(`act: test sucess`);
2405
+ return true;
2406
+ }
2407
+ else {
2408
+ log$1(`act: test error`);
2409
+ this.router.navigate(['displayIndex']);
2410
+ return false;
2411
+ }
2412
+ }
2413
+ preHandle(state) {
2414
+ return (state.url.includes('error') ||
2415
+ state.url.includes('exception') ||
2416
+ state.url.includes('displayIndex') ||
2417
+ state.url === '' ||
2418
+ state.url === null ||
2419
+ state.url === '/' ||
2420
+ state.url.includes('iframePage'));
2421
+ }
2422
+ getAllLinks(menu, links) {
2423
+ menu.forEach((sider) => {
2424
+ if (sider.link) {
2425
+ links.push(sider.link);
2426
+ }
2427
+ if (sider.children && sider.children.length > 0) {
2428
+ this.getAllLinks(sider.children, links);
2429
+ }
2430
+ });
2431
+ }
2432
+ }
2433
+ ActGuard.ɵprov = i0.ɵɵdefineInjectable({ factory: function ActGuard_Factory() { return new ActGuard(i0.ɵɵinject(i1$1.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(PathToRegexpService), i0.ɵɵinject(i4.Router)); }, token: ActGuard, providedIn: "root" });
2434
+ ActGuard.decorators = [
2435
+ { type: Injectable, args: [{
2436
+ providedIn: 'root'
2437
+ },] }
2438
+ ];
2439
+ ActGuard.ctorParameters = () => [
2440
+ { type: YunzaiConfigService$1 },
2441
+ { type: CacheService },
2442
+ { type: PathToRegexpService },
2443
+ { type: Router }
1520
2444
  ];
1521
2445
 
1522
- /**
1523
- * Generated bundle index. Do not edit.
2446
+ // export * from './contact/contact.component';
2447
+ // export * from './contact/contact.service';
2448
+
2449
+ /**
2450
+ * Generated bundle index. Do not edit.
1524
2451
  */
1525
2452
 
1526
- export { BUSINESS_DEFAULT_CONFIG, STOMP_DEFAULT_CONFIG, TOPIC, YZ_APPINIT_PROVIDES, YunzaiLayoutModule, YzAuthService, YzDefaultInterceptor, YzHeaderApplicationComponent, YzHeaderClearStorageComponent, YzHeaderFullScreenComponent, YzHeaderI18NComponent, YzHeaderNotifyComponent, YzHeaderThemBtnComponent, YzHeaderUserComponent, YzI18NService, YzLayoutBasicComponent, YzStartupService, YzStartupServiceFactory, YzStompService, generateAbility, mapYzSideToYelonMenu, mergeBisConfig, mergeStompConfig, ɵ0, YzHeaderApplicationComponent as ɵa, YzHeaderNotifyComponent as ɵb, YzHeaderThemBtnComponent as ɵc, YzHeaderUserComponent as ɵd, YzHeaderFullScreenComponent as ɵe, YzHeaderClearStorageComponent as ɵf, YzHeaderI18NComponent as ɵg };
2453
+ export { ActGuard, BUSINESS_DEFAULT_CONFIG, PathToRegexpService, STOMP_DEFAULT_CONFIG, TOPIC, YZ_APPINIT_PROVIDES, YunzaiLayoutModule, YzAuthService, YzDefaultInterceptor, YzHeaderApplicationComponent, YzHeaderClearStorageComponent, YzHeaderFullScreenComponent, YzHeaderI18NComponent, YzHeaderNotifyComponent, YzHeaderThemBtnComponent, YzHeaderUserComponent, YzI18NService, YzLayoutBasicComponent, YzStartupService, YzStartupServiceFactory, YzStompService, generateAbility, mapYzSideToYelonMenu, mergeBisConfig, mergeStompConfig, ɵ0, ContactComponent as ɵa, ContactService as ɵb, YzHeaderApplicationComponent as ɵc, YzHeaderNotifyComponent as ɵd, YzHeaderThemBtnComponent as ɵe, YzHeaderUserComponent as ɵf, YzHeaderFullScreenComponent as ɵg, YzHeaderClearStorageComponent as ɵh, YzHeaderI18NComponent as ɵi };
1527
2454
  //# sourceMappingURL=layout.js.map