@yelon/bis 12.0.17 → 12.0.18

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