@yelon/bis 12.0.16 → 13.0.0-beta.1
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.
- package/bis.d.ts +1 -0
- package/{esm2015/bis.js → esm2020/bis.mjs} +0 -0
- package/esm2020/layout/act.guard.mjs +108 -0
- package/{esm2015/layout/bis.config.js → esm2020/layout/bis.config.mjs} +0 -0
- package/esm2020/layout/contact/contact.component.mjs +492 -0
- package/esm2020/layout/contact/contact.service.mjs +146 -0
- package/esm2020/layout/layout.mjs +5 -0
- package/esm2020/layout/layout.module.mjs +73 -0
- package/{esm2015/layout/path-to-regexp.service.js → esm2020/layout/path-to-regexp.service.mjs} +9 -8
- package/{esm2015/layout/public_api.js → esm2020/layout/public_api.mjs} +3 -3
- package/esm2020/layout/stomp.config.mjs +18 -0
- package/{esm2015/layout/widgets/index.js → esm2020/layout/widgets/index.mjs} +0 -0
- package/esm2020/layout/widgets/yz.application.component.mjs +271 -0
- package/esm2020/layout/widgets/yz.clear-storage.component.mjs +45 -0
- package/esm2020/layout/widgets/yz.fullscreen.component.mjs +45 -0
- package/esm2020/layout/widgets/yz.i18n.component.mjs +115 -0
- package/esm2020/layout/widgets/yz.notify.component.mjs +184 -0
- package/esm2020/layout/widgets/yz.them-btn.component.mjs +196 -0
- package/esm2020/layout/widgets/yz.user.component.mjs +112 -0
- package/esm2020/layout/yz.auth.service.mjs +156 -0
- package/esm2020/layout/yz.basic.component.mjs +207 -0
- package/esm2020/layout/yz.default.interceptor.mjs +203 -0
- package/esm2020/layout/yz.i18n.service.mjs +93 -0
- package/esm2020/layout/yz.startup.service.mjs +137 -0
- package/esm2020/layout/yz.stomp.service.mjs +88 -0
- package/{esm2015/public_api.js → esm2020/public_api.mjs} +0 -0
- package/{esm2015/shared/public_api.js → esm2020/shared/public_api.mjs} +0 -0
- package/esm2020/shared/shared-yelon.module.mjs +108 -0
- package/{esm2015/shared/shared-zorro.module.js → esm2020/shared/shared-zorro.module.mjs} +0 -0
- package/{esm2015/shared/shared.js → esm2020/shared/shared.mjs} +0 -0
- package/esm2020/shared/shared.module.mjs +116 -0
- package/{esm2015/shared/style-icons.js → esm2020/shared/style-icons.mjs} +0 -0
- package/fesm2015/{bis.js → bis.mjs} +1 -1
- package/fesm2015/bis.mjs.map +1 -0
- package/fesm2015/layout.mjs +2787 -0
- package/fesm2015/layout.mjs.map +1 -0
- package/fesm2015/{shared.js → shared.mjs} +113 -12
- package/fesm2015/shared.mjs.map +1 -0
- package/fesm2020/bis.mjs +6 -0
- package/fesm2020/bis.mjs.map +1 -0
- package/fesm2020/layout.mjs +2796 -0
- package/fesm2020/layout.mjs.map +1 -0
- package/fesm2020/shared.mjs +1106 -0
- package/fesm2020/shared.mjs.map +1 -0
- package/layout/act.guard.d.ts +3 -0
- package/layout/contact/contact.component.d.ts +169 -0
- package/layout/contact/contact.service.d.ts +118 -0
- package/layout/layout.d.ts +1 -1
- package/layout/layout.module.d.ts +18 -0
- package/layout/package.json +5 -6
- package/layout/path-to-regexp.service.d.ts +3 -0
- package/layout/public_api.d.ts +2 -0
- package/layout/widgets/yz.application.component.d.ts +3 -0
- package/layout/widgets/yz.clear-storage.component.d.ts +3 -0
- package/layout/widgets/yz.fullscreen.component.d.ts +3 -1
- package/layout/widgets/yz.i18n.component.d.ts +3 -0
- package/layout/widgets/yz.notify.component.d.ts +8 -3
- package/layout/widgets/yz.them-btn.component.d.ts +3 -0
- package/layout/widgets/yz.user.component.d.ts +3 -0
- package/layout/yz.auth.service.d.ts +3 -0
- package/layout/yz.basic.component.d.ts +11 -2
- package/layout/yz.default.interceptor.d.ts +3 -0
- package/layout/yz.i18n.service.d.ts +3 -0
- package/layout/yz.startup.service.d.ts +4 -1
- package/layout/yz.stomp.service.d.ts +6 -3
- package/package.json +46 -18
- package/shared/package.json +5 -6
- package/shared/shared-zorro.module.d.ts +2 -2
- package/shared/shared.d.ts +1 -0
- package/shared/shared.module.d.ts +93 -0
- package/bis.metadata.json +0 -1
- package/bundles/bis.umd.js +0 -18
- package/bundles/bis.umd.js.map +0 -1
- package/bundles/layout.umd.js +0 -2080
- package/bundles/layout.umd.js.map +0 -1
- package/bundles/shared.umd.js +0 -1253
- package/bundles/shared.umd.js.map +0 -1
- package/esm2015/layout/act.guard.js +0 -115
- package/esm2015/layout/layout.js +0 -6
- package/esm2015/layout/layout.module.js +0 -37
- package/esm2015/layout/stomp.config.js +0 -20
- package/esm2015/layout/widgets/yz.application.component.js +0 -200
- package/esm2015/layout/widgets/yz.clear-storage.component.js +0 -39
- package/esm2015/layout/widgets/yz.fullscreen.component.js +0 -36
- package/esm2015/layout/widgets/yz.i18n.component.js +0 -78
- package/esm2015/layout/widgets/yz.notify.component.js +0 -154
- package/esm2015/layout/widgets/yz.them-btn.component.js +0 -146
- package/esm2015/layout/widgets/yz.user.component.js +0 -81
- package/esm2015/layout/yz.auth.service.js +0 -158
- package/esm2015/layout/yz.basic.component.js +0 -101
- package/esm2015/layout/yz.default.interceptor.js +0 -204
- package/esm2015/layout/yz.i18n.service.js +0 -102
- package/esm2015/layout/yz.startup.service.js +0 -138
- package/esm2015/layout/yz.stomp.service.js +0 -91
- package/esm2015/shared/shared-yelon.module.js +0 -108
- package/esm2015/shared/shared.module.js +0 -16
- package/fesm2015/bis.js.map +0 -1
- package/fesm2015/layout.js +0 -1869
- package/fesm2015/layout.js.map +0 -1
- package/fesm2015/shared.js.map +0 -1
- package/layout/layout.metadata.json +0 -1
- package/shared/shared.metadata.json +0 -1
package/fesm2015/layout.js
DELETED
|
@@ -1,1869 +0,0 @@
|
|
|
1
|
-
import * as i0 from '@angular/core';
|
|
2
|
-
import { Injectable, Component, ChangeDetectionStrategy, Injector, Inject, Input, ChangeDetectorRef, Renderer2, Optional, HostListener, isDevMode, NgModule, APP_INITIALIZER } from '@angular/core';
|
|
3
|
-
import * as i2$1 from '@yelon/cache';
|
|
4
|
-
import { CacheService } from '@yelon/cache';
|
|
5
|
-
import * as i1 from '@yelon/theme';
|
|
6
|
-
import { zh_CN as zh_CN$1, zh_TW as zh_TW$1, en_US as en_US$1, YunzaiI18nBaseService, _HttpClient, SettingsService, YelonLocaleService, YUNZAI_I18N_TOKEN, MenuService, TitleService } from '@yelon/theme';
|
|
7
|
-
import { WINDOW, YunzaiConfigService as YunzaiConfigService$1, log as log$1, deepCopy } from '@yelon/util';
|
|
8
|
-
import * as i3 from '@angular/cdk/platform';
|
|
9
|
-
import { Platform } from '@angular/cdk/platform';
|
|
10
|
-
import { registerLocaleData, DOCUMENT, CommonModule } from '@angular/common';
|
|
11
|
-
import ngEn from '@angular/common/locales/en';
|
|
12
|
-
import ngZh from '@angular/common/locales/zh';
|
|
13
|
-
import ngZhTw from '@angular/common/locales/zh-Hant';
|
|
14
|
-
import { zhCN, zhTW, enUS } from 'date-fns/locale';
|
|
15
|
-
import * as i1$1 from '@yelon/util/config';
|
|
16
|
-
import { YunzaiConfigService } from '@yelon/util/config';
|
|
17
|
-
import * as i2 from 'ng-zorro-antd/i18n';
|
|
18
|
-
import { zh_CN, zh_TW, en_US, NzI18nService } from 'ng-zorro-antd/i18n';
|
|
19
|
-
import { __decorate } from 'tslib';
|
|
20
|
-
import { InputBoolean } from '@yelon/util/decorator';
|
|
21
|
-
import { forkJoin, Subject, of, BehaviorSubject, throwError } from 'rxjs';
|
|
22
|
-
import { map, takeUntil, mergeMap, mergeAll, filter, take, switchMap, catchError } from 'rxjs/operators';
|
|
23
|
-
import { formatDistanceToNow } from 'date-fns';
|
|
24
|
-
import { NzMessageService } from 'ng-zorro-antd/message';
|
|
25
|
-
import { log } from '@yelon/util/other';
|
|
26
|
-
import { Directionality } from '@angular/cdk/bidi';
|
|
27
|
-
import { YUNZAI_THEME_BTN_KEYS } from '@yelon/theme/theme-btn';
|
|
28
|
-
import { YA_SERVICE_TOKEN, mergeConfig } from '@yelon/auth';
|
|
29
|
-
import { NzModalService } from 'ng-zorro-antd/modal';
|
|
30
|
-
import * as screenfull from 'screenfull';
|
|
31
|
-
import { HttpClientModule, HttpErrorResponse, HttpResponse, HttpResponseBase } from '@angular/common/http';
|
|
32
|
-
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|
33
|
-
import * as i4 from '@angular/router';
|
|
34
|
-
import { RouterModule, Router } from '@angular/router';
|
|
35
|
-
import { YzSharedModule, ICONS } from '@yelon/bis/shared';
|
|
36
|
-
import { RxStomp } from '@stomp/rx-stomp';
|
|
37
|
-
import * as i3$1 from 'ng-zorro-antd/notification';
|
|
38
|
-
import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
39
|
-
import { NzIconService } from 'ng-zorro-antd/icon';
|
|
40
|
-
import { ACLService } from '@yelon/acl';
|
|
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 }
|
|
127
|
-
];
|
|
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',
|
|
246
|
-
template: `
|
|
247
|
-
<!-- template start-->
|
|
248
|
-
<ng-template #search>
|
|
249
|
-
<div nz-row class="yz-application-list-search">
|
|
250
|
-
<nz-input-group [nzPrefix]="prefixTemplate">
|
|
251
|
-
<input
|
|
252
|
-
type="text"
|
|
253
|
-
nz-input
|
|
254
|
-
placeholder="{{ 'application.search' | i18n }}"
|
|
255
|
-
[(ngModel)]="searchValue"
|
|
256
|
-
(ngModelChange)="onSearch()"
|
|
257
|
-
/>
|
|
258
|
-
<ng-template #prefixTemplate>
|
|
259
|
-
<i nz-icon nzType="search" nzTheme="outline"></i>
|
|
260
|
-
</ng-template>
|
|
261
|
-
</nz-input-group>
|
|
262
|
-
</div>
|
|
263
|
-
</ng-template>
|
|
264
|
-
<ng-template #ld>
|
|
265
|
-
<div class="yz-application-list">
|
|
266
|
-
<ul>
|
|
267
|
-
<li *ngFor="let d of listData">
|
|
268
|
-
<h5>{{ d.name }}</h5>
|
|
269
|
-
<a href="javascript:;" *ngFor="let cd of d.children" (click)="open(cd)">{{ cd.name }}</a>
|
|
270
|
-
</li>
|
|
271
|
-
</ul>
|
|
272
|
-
</div>
|
|
273
|
-
</ng-template>
|
|
274
|
-
<!-- template end-->
|
|
275
|
-
|
|
276
|
-
<!-- button start-->
|
|
277
|
-
<div class="yunzai-default__nav-item" (click)="diffChange()"> {{ 'application.button' | i18n }}</div>
|
|
278
|
-
<!-- button end-->
|
|
279
|
-
|
|
280
|
-
<!-- header start-->
|
|
281
|
-
<div class="yz-application" nz-row *ngIf="active">
|
|
282
|
-
<div nz-col [nzSpan]="3" class="yz-application-topic">
|
|
283
|
-
<div class="yz-application-text" (click)="full()">{{ 'application.all' | i18n }}</div>
|
|
284
|
-
<div class="yz-application-text" (click)="own()">{{ 'application.mine' | i18n }}</div>
|
|
285
|
-
<div class="yz-application-text" *ngFor="let d of topicData" (click)="every(d)">
|
|
286
|
-
{{ d.name }}
|
|
287
|
-
</div>
|
|
288
|
-
</div>
|
|
289
|
-
<div nz-col [nzSpan]="21" [ngSwitch]="topic" class="yz-application-container">
|
|
290
|
-
<div *ngSwitchCase="T.FULL">
|
|
291
|
-
<ng-template [ngTemplateOutlet]="search"></ng-template>
|
|
292
|
-
<ng-template [ngTemplateOutlet]="ld"></ng-template>
|
|
293
|
-
</div>
|
|
294
|
-
<div *ngSwitchCase="T.OWN">
|
|
295
|
-
<ng-template [ngTemplateOutlet]="search"></ng-template>
|
|
296
|
-
<ng-template [ngTemplateOutlet]="ld"></ng-template>
|
|
297
|
-
</div>
|
|
298
|
-
<div *ngSwitchCase="T.EVERY" class="yz-application-list">
|
|
299
|
-
<div class="yz-application-list-item">
|
|
300
|
-
<ul>
|
|
301
|
-
<li *ngFor="let d of listData" (click)="open(d)">
|
|
302
|
-
<a href="javascript:;">
|
|
303
|
-
<h4>{{ d.name }}</h4>
|
|
304
|
-
<p>{{ d.intro }}</p>
|
|
305
|
-
</a>
|
|
306
|
-
</li>
|
|
307
|
-
</ul>
|
|
308
|
-
</div>
|
|
309
|
-
</div>
|
|
310
|
-
</div>
|
|
311
|
-
</div>
|
|
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 }
|
|
322
|
-
];
|
|
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',
|
|
353
|
-
template: `
|
|
354
|
-
<div *ngIf="showLangText" nz-dropdown [nzDropdownMenu]="langMenu" nzPlacement="bottomRight">
|
|
355
|
-
<i nz-icon nzType="global"></i>
|
|
356
|
-
{{ 'menu.lang' | i18n }}
|
|
357
|
-
<i nz-icon nzType="down"></i>
|
|
358
|
-
</div>
|
|
359
|
-
<i
|
|
360
|
-
*ngIf="!showLangText"
|
|
361
|
-
nz-dropdown
|
|
362
|
-
[nzDropdownMenu]="langMenu"
|
|
363
|
-
nzPlacement="bottomRight"
|
|
364
|
-
nz-icon
|
|
365
|
-
nzType="global"
|
|
366
|
-
></i>
|
|
367
|
-
<nz-dropdown-menu #langMenu="nzDropdownMenu">
|
|
368
|
-
<ul nz-menu>
|
|
369
|
-
<li
|
|
370
|
-
nz-menu-item
|
|
371
|
-
*ngFor="let item of langs"
|
|
372
|
-
[nzSelected]="item.code === curLangCode"
|
|
373
|
-
(click)="change(item.code)"
|
|
374
|
-
>
|
|
375
|
-
<span role="img" [attr.aria-label]="item.text" class="pr-xs">{{ item.abbr }}</span>
|
|
376
|
-
{{ item.text }}
|
|
377
|
-
</li>
|
|
378
|
-
</ul>
|
|
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()
|
|
394
|
-
], YzHeaderI18NComponent.prototype, "showLangText", void 0);
|
|
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',
|
|
519
|
-
template: `
|
|
520
|
-
<notice-icon
|
|
521
|
-
[data]="data"
|
|
522
|
-
[count]="count"
|
|
523
|
-
[loading]="loading"
|
|
524
|
-
btnClass="yunzai-default__nav-item"
|
|
525
|
-
btnIconClass="yunzai-default__nav-item-icon"
|
|
526
|
-
(select)="select($event)"
|
|
527
|
-
(clear)="clear($event)"
|
|
528
|
-
></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 }
|
|
539
|
-
];
|
|
540
|
-
|
|
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',
|
|
622
|
-
template: `
|
|
623
|
-
<div
|
|
624
|
-
class="yunzai-default__nav-item"
|
|
625
|
-
nz-dropdown
|
|
626
|
-
[nzDropdownMenu]="iconMenu"
|
|
627
|
-
nzTrigger="click"
|
|
628
|
-
nzPlacement="bottomRight"
|
|
629
|
-
>
|
|
630
|
-
<svg nz-tooltip class="anticon" role="img" width="21" height="21" viewBox="0 0 21 21" fill="currentColor">
|
|
631
|
-
<g fill-rule="evenodd">
|
|
632
|
-
<g fill-rule="nonzero">
|
|
633
|
-
<path
|
|
634
|
-
d="M7.02 3.635l12.518 12.518a1.863 1.863 0 010 2.635l-1.317 1.318a1.863 1.863 0 01-2.635 0L3.068 7.588A2.795 2.795 0 117.02 3.635zm2.09 14.428a.932.932 0 110 1.864.932.932 0 010-1.864zm-.043-9.747L7.75 9.635l9.154 9.153 1.318-1.317-9.154-9.155zM3.52 12.473c.514 0 .931.417.931.931v.932h.932a.932.932 0 110 1.864h-.932v.931a.932.932 0 01-1.863 0l-.001-.931h-.93a.932.932 0 010-1.864h.93v-.932c0-.514.418-.931.933-.931zm15.374-3.727a1.398 1.398 0 110 2.795 1.398 1.398 0 010-2.795zM4.385 4.953a.932.932 0 000 1.317l2.046 2.047L7.75 7 5.703 4.953a.932.932 0 00-1.318 0zM14.701.36a.932.932 0 01.931.932v.931h.932a.932.932 0 010 1.864h-.933l.001.932a.932.932 0 11-1.863 0l-.001-.932h-.93a.932.932 0 110-1.864h.93v-.931a.932.932 0 01.933-.932z"
|
|
635
|
-
></path>
|
|
636
|
-
</g>
|
|
637
|
-
</g>
|
|
638
|
-
</svg>
|
|
639
|
-
</div>
|
|
640
|
-
<nz-dropdown-menu #iconMenu="nzDropdownMenu">
|
|
641
|
-
<ul nz-menu>
|
|
642
|
-
<li
|
|
643
|
-
nz-menu-item
|
|
644
|
-
*ngFor="let theme of types"
|
|
645
|
-
(click)="onThemeChange(theme.key)"
|
|
646
|
-
[style]="{ color: theme.color }"
|
|
647
|
-
>
|
|
648
|
-
<i nz-icon nzType="bg-colors"></i>
|
|
649
|
-
{{ theme.text | i18n }}
|
|
650
|
-
</li>
|
|
651
|
-
</ul>
|
|
652
|
-
<!-- <div nz-menu class="wd-xl animated jello">-->
|
|
653
|
-
<!-- <div nz-row [nzJustify]="'space-between'" [nzAlign]="'middle'" class="app-icons">-->
|
|
654
|
-
<!-- <div nz-col [nzSpan]="4" *ngFor="let theme of types" (click)="onThemeChange(theme.key)">-->
|
|
655
|
-
<!-- <i nz-icon nzType="bg-colors" class="text-white" [style]="{ backgroundColor: theme.color }"></i>-->
|
|
656
|
-
<!-- <span [ngStyle]="{ color: theme.color }">{{ theme.text | i18n }}</span>-->
|
|
657
|
-
<!-- </div>-->
|
|
658
|
-
<!-- </div>-->
|
|
659
|
-
<!-- </div>-->
|
|
660
|
-
</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 }]
|
|
677
|
-
};
|
|
678
|
-
|
|
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);
|
|
688
|
-
}
|
|
689
|
-
|
|
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',
|
|
730
|
-
template: `
|
|
731
|
-
<div
|
|
732
|
-
class="yunzai-default__nav-item d-flex align-items-center px-sm"
|
|
733
|
-
nz-dropdown
|
|
734
|
-
nzPlacement="bottomRight"
|
|
735
|
-
[nzDropdownMenu]="userMenu"
|
|
736
|
-
>
|
|
737
|
-
<nz-avatar [nzSrc]="icon" nzSize="small" class="mr-sm"></nz-avatar>
|
|
738
|
-
{{ username }}
|
|
739
|
-
</div>
|
|
740
|
-
<nz-dropdown-menu #userMenu="nzDropdownMenu">
|
|
741
|
-
<div nz-menu class="width-sm">
|
|
742
|
-
<div nz-menu-item *ngFor="let m of menus" (click)="to(m.url)">
|
|
743
|
-
<i nz-icon [nzType]="m.icon" class="mr-sm"></i>
|
|
744
|
-
{{ m.name | i18n }}
|
|
745
|
-
</div>
|
|
746
|
-
<li nz-menu-divider></li>
|
|
747
|
-
<div nz-menu-item (click)="logout()">
|
|
748
|
-
<i nz-icon nzType="logout" class="mr-sm"></i>
|
|
749
|
-
{{ 'menu.account.logout' | i18n }}
|
|
750
|
-
</div>
|
|
751
|
-
</div>
|
|
752
|
-
</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 }
|
|
763
|
-
];
|
|
764
|
-
|
|
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',
|
|
783
|
-
template: `
|
|
784
|
-
<i nz-icon nzType="tool"></i>
|
|
785
|
-
{{ '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',] }]
|
|
799
|
-
};
|
|
800
|
-
|
|
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',
|
|
820
|
-
template: `
|
|
821
|
-
<i nz-icon [nzType]="status ? 'fullscreen-exit' : 'fullscreen'"></i>
|
|
822
|
-
{{ (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',] }]
|
|
833
|
-
};
|
|
834
|
-
|
|
835
|
-
const ɵ0 = msg => {
|
|
836
|
-
log$1(msg);
|
|
837
|
-
};
|
|
838
|
-
const STOMP_DEFAULT_CONFIG = {
|
|
839
|
-
connectHeaders: {
|
|
840
|
-
login: 'guest',
|
|
841
|
-
passcode: 'guest'
|
|
842
|
-
},
|
|
843
|
-
brokerURL: '/websocket/ws/',
|
|
844
|
-
heartbeatIncoming: 1000 * 60,
|
|
845
|
-
heartbeatOutgoing: 1000 * 60,
|
|
846
|
-
reconnectDelay: 30000000,
|
|
847
|
-
debug: ɵ0
|
|
848
|
-
};
|
|
849
|
-
function mergeStompConfig(srv) {
|
|
850
|
-
return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
class YzStompService {
|
|
854
|
-
constructor(csr, cache, injector, notification) {
|
|
855
|
-
this.csr = csr;
|
|
856
|
-
this.cache = cache;
|
|
857
|
-
this.injector = injector;
|
|
858
|
-
this.notification = notification;
|
|
859
|
-
this.subs = [];
|
|
860
|
-
if (!this.user) {
|
|
861
|
-
this.user = this.cache.get('_yz_user', { mode: 'none' });
|
|
862
|
-
}
|
|
863
|
-
if (!this.config) {
|
|
864
|
-
this.config = mergeStompConfig(this.csr);
|
|
865
|
-
}
|
|
866
|
-
if (!this.bisConfig) {
|
|
867
|
-
this.bisConfig = mergeBisConfig(csr);
|
|
868
|
-
}
|
|
869
|
-
if (!this.rxStomp) {
|
|
870
|
-
this.rxStomp = new RxStomp();
|
|
871
|
-
if (isDevMode()) {
|
|
872
|
-
log$1('yz.stomp.service: is dev mode');
|
|
873
|
-
log$1('yz.stomp.service: ', `config is ${JSON.stringify(this.config)}`);
|
|
874
|
-
this.rxStomp.configure(this.config);
|
|
875
|
-
return;
|
|
876
|
-
}
|
|
877
|
-
const { location } = this.injector.get(DOCUMENT);
|
|
878
|
-
const { protocol, host } = location;
|
|
879
|
-
log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
|
|
880
|
-
if (protocol.includes('http') && !protocol.includes('https')) {
|
|
881
|
-
this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
|
|
882
|
-
}
|
|
883
|
-
if (protocol.includes('https')) {
|
|
884
|
-
this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
|
|
885
|
-
}
|
|
886
|
-
log$1('yz.stomp.service: ', `config is ${this.config}`);
|
|
887
|
-
this.rxStomp.configure(this.config);
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
listen() {
|
|
891
|
-
this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
|
|
892
|
-
this.createNotification(JSON.parse(message.body));
|
|
893
|
-
}));
|
|
894
|
-
this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
|
|
895
|
-
this.logoutNotification(JSON.parse(message.body));
|
|
896
|
-
}));
|
|
897
|
-
this.rxStomp.activate();
|
|
898
|
-
}
|
|
899
|
-
createNotification(message) {
|
|
900
|
-
this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
|
|
901
|
-
}
|
|
902
|
-
logoutNotification(message) {
|
|
903
|
-
this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
|
|
904
|
-
setTimeout(() => {
|
|
905
|
-
this.cache.clear();
|
|
906
|
-
localStorage.clear();
|
|
907
|
-
this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
|
|
908
|
-
}, 5000);
|
|
909
|
-
}
|
|
910
|
-
unListen() {
|
|
911
|
-
this.subs.forEach(s => s.unsubscribe());
|
|
912
|
-
this.rxStomp.deactivate().then();
|
|
913
|
-
}
|
|
914
|
-
publish(parameters) {
|
|
915
|
-
this.rxStomp.publish(parameters);
|
|
916
|
-
}
|
|
917
|
-
watch(destination, headers) {
|
|
918
|
-
return this.rxStomp.watch(destination, headers);
|
|
919
|
-
}
|
|
920
|
-
}
|
|
921
|
-
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" });
|
|
922
|
-
YzStompService.decorators = [
|
|
923
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
924
|
-
];
|
|
925
|
-
YzStompService.ctorParameters = () => [
|
|
926
|
-
{ type: YunzaiConfigService$1 },
|
|
927
|
-
{ type: CacheService },
|
|
928
|
-
{ type: Injector },
|
|
929
|
-
{ type: NzNotificationService }
|
|
930
|
-
];
|
|
931
|
-
|
|
932
|
-
class YzLayoutBasicComponent {
|
|
933
|
-
constructor(cacheService, yzStompService) {
|
|
934
|
-
this.cacheService = cacheService;
|
|
935
|
-
this.yzStompService = yzStompService;
|
|
936
|
-
this.options = {
|
|
937
|
-
logoExpanded: `./assets/logo-full.svg`,
|
|
938
|
-
logoCollapsed: `./assets/logo.svg`
|
|
939
|
-
};
|
|
940
|
-
this.intro = '';
|
|
941
|
-
this.text = '';
|
|
942
|
-
this.icon = '';
|
|
943
|
-
}
|
|
944
|
-
ngOnInit() {
|
|
945
|
-
const current = this.cacheService.get('_yz_current', { mode: 'none' });
|
|
946
|
-
const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
|
|
947
|
-
this.text = current.text ? current.text : '应用名称';
|
|
948
|
-
this.intro = current.intro ? current.intro : '应用描述';
|
|
949
|
-
this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
|
|
950
|
-
this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
|
|
951
|
-
this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
|
|
952
|
-
this.yzStompService.listen();
|
|
953
|
-
}
|
|
954
|
-
ngOnDestroy() {
|
|
955
|
-
this.yzStompService.unListen();
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
YzLayoutBasicComponent.decorators = [
|
|
959
|
-
{ type: Component, args: [{
|
|
960
|
-
selector: 'yz-layout-basic',
|
|
961
|
-
template: `
|
|
962
|
-
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl">
|
|
963
|
-
<layout-default-header-item direction="left">
|
|
964
|
-
<yz-header-application></yz-header-application>
|
|
965
|
-
</layout-default-header-item>
|
|
966
|
-
|
|
967
|
-
<layout-default-header-item direction="right" hidden="mobile">
|
|
968
|
-
<yz-header-notify></yz-header-notify>
|
|
969
|
-
</layout-default-header-item>
|
|
970
|
-
|
|
971
|
-
<layout-default-header-item direction="right" hidden="mobile">
|
|
972
|
-
<yz-header-theme-btn></yz-header-theme-btn>
|
|
973
|
-
</layout-default-header-item>
|
|
974
|
-
|
|
975
|
-
<layout-default-header-item direction="right" hidden="mobile">
|
|
976
|
-
<div
|
|
977
|
-
layout-default-header-item-trigger
|
|
978
|
-
nz-dropdown
|
|
979
|
-
[nzDropdownMenu]="settingsMenu"
|
|
980
|
-
nzTrigger="click"
|
|
981
|
-
nzPlacement="bottomRight"
|
|
982
|
-
>
|
|
983
|
-
<i nz-icon nzType="setting"></i>
|
|
984
|
-
</div>
|
|
985
|
-
<nz-dropdown-menu #settingsMenu="nzDropdownMenu">
|
|
986
|
-
<div nz-menu style="width: 200px;">
|
|
987
|
-
<div nz-menu-item>
|
|
988
|
-
<yz-header-fullscreen></yz-header-fullscreen>
|
|
989
|
-
</div>
|
|
990
|
-
<div nz-menu-item>
|
|
991
|
-
<yz-header-clear-storage></yz-header-clear-storage>
|
|
992
|
-
</div>
|
|
993
|
-
<div nz-menu-item>
|
|
994
|
-
<yz-header-i18n></yz-header-i18n>
|
|
995
|
-
</div>
|
|
996
|
-
</div>
|
|
997
|
-
</nz-dropdown-menu>
|
|
998
|
-
</layout-default-header-item>
|
|
999
|
-
<layout-default-header-item direction="right">
|
|
1000
|
-
<yz-header-user></yz-header-user>
|
|
1001
|
-
</layout-default-header-item>
|
|
1002
|
-
<ng-template #asideUserTpl>
|
|
1003
|
-
<div nz-dropdown nzTrigger="click" [nzDropdownMenu]="userMenu" class="yunzai-default__aside-user">
|
|
1004
|
-
<nz-avatar class="yunzai-default__aside-user-avatar" [nzSrc]="icon"></nz-avatar>
|
|
1005
|
-
<div class="yunzai-default__aside-user-info">
|
|
1006
|
-
<strong>{{ text }}</strong>
|
|
1007
|
-
<p class="mb0">{{ intro }}</p>
|
|
1008
|
-
</div>
|
|
1009
|
-
</div>
|
|
1010
|
-
<nz-dropdown-menu #userMenu="nzDropdownMenu">
|
|
1011
|
-
<ul nz-menu>
|
|
1012
|
-
<li nz-menu-item routerLink="/">{{ 'menu.backtohome' | i18n }}</li>
|
|
1013
|
-
</ul>
|
|
1014
|
-
</nz-dropdown-menu>
|
|
1015
|
-
</ng-template>
|
|
1016
|
-
<ng-template #contentTpl>
|
|
1017
|
-
<reuse-tab #reuseTab></reuse-tab>
|
|
1018
|
-
<router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
|
|
1019
|
-
</ng-template>
|
|
1020
|
-
</layout-default>
|
|
1021
|
-
`,
|
|
1022
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1023
|
-
},] }
|
|
1024
|
-
];
|
|
1025
|
-
YzLayoutBasicComponent.ctorParameters = () => [
|
|
1026
|
-
{ type: CacheService },
|
|
1027
|
-
{ type: YzStompService }
|
|
1028
|
-
];
|
|
1029
|
-
|
|
1030
|
-
const COMPONENTS = [
|
|
1031
|
-
// ContactComponent,
|
|
1032
|
-
YzLayoutBasicComponent,
|
|
1033
|
-
YzHeaderApplicationComponent,
|
|
1034
|
-
YzHeaderNotifyComponent,
|
|
1035
|
-
YzHeaderThemBtnComponent,
|
|
1036
|
-
YzHeaderUserComponent,
|
|
1037
|
-
YzHeaderFullScreenComponent,
|
|
1038
|
-
YzHeaderClearStorageComponent,
|
|
1039
|
-
YzHeaderI18NComponent
|
|
1040
|
-
];
|
|
1041
|
-
class YunzaiLayoutModule {
|
|
1042
|
-
}
|
|
1043
|
-
YunzaiLayoutModule.decorators = [
|
|
1044
|
-
{ type: NgModule, args: [{
|
|
1045
|
-
imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
|
|
1046
|
-
providers: [
|
|
1047
|
-
{
|
|
1048
|
-
provide: YUNZAI_THEME_BTN_KEYS,
|
|
1049
|
-
useValue: 'site-theme'
|
|
1050
|
-
}
|
|
1051
|
-
],
|
|
1052
|
-
declarations: [...COMPONENTS],
|
|
1053
|
-
exports: [...COMPONENTS]
|
|
1054
|
-
},] }
|
|
1055
|
-
];
|
|
1056
|
-
|
|
1057
|
-
class YzAuthService {
|
|
1058
|
-
constructor(injector) {
|
|
1059
|
-
this.injector = injector;
|
|
1060
|
-
this.option = mergeConfig(this.csr);
|
|
1061
|
-
this.bis = mergeBisConfig(this.csr);
|
|
1062
|
-
}
|
|
1063
|
-
get csr() {
|
|
1064
|
-
return this.injector.get(YunzaiConfigService);
|
|
1065
|
-
}
|
|
1066
|
-
get tokenService() {
|
|
1067
|
-
return this.injector.get(YA_SERVICE_TOKEN);
|
|
1068
|
-
}
|
|
1069
|
-
get httpClient() {
|
|
1070
|
-
return this.injector.get(_HttpClient);
|
|
1071
|
-
}
|
|
1072
|
-
get cacheService() {
|
|
1073
|
-
return this.injector.get(CacheService);
|
|
1074
|
-
}
|
|
1075
|
-
askToken() {
|
|
1076
|
-
var _a;
|
|
1077
|
-
log('yz.auth.service: ', 'askToken');
|
|
1078
|
-
if ((_a = this.tokenService.get()) === null || _a === void 0 ? void 0 : _a.token) {
|
|
1079
|
-
return of(this.tokenService.get());
|
|
1080
|
-
}
|
|
1081
|
-
else {
|
|
1082
|
-
if (this.bis.loginForm) {
|
|
1083
|
-
return this.fetchTokenByUP();
|
|
1084
|
-
}
|
|
1085
|
-
else {
|
|
1086
|
-
return this.fetchTokenByCas();
|
|
1087
|
-
}
|
|
1088
|
-
}
|
|
1089
|
-
}
|
|
1090
|
-
fetchTokenByUP() {
|
|
1091
|
-
log('yz.auth.service: ', 'fetchTokenByUP');
|
|
1092
|
-
return this.httpClient.post(`/auth/oauth/token?_allow_anonymous=true`, this.bis.loginForm).pipe(map((response) => {
|
|
1093
|
-
const { access_token, expires_in, refresh_token, scope, token_type } = response;
|
|
1094
|
-
return {
|
|
1095
|
-
token: access_token,
|
|
1096
|
-
expired: expires_in,
|
|
1097
|
-
refreshToken: refresh_token,
|
|
1098
|
-
tokenType: token_type,
|
|
1099
|
-
scope
|
|
1100
|
-
};
|
|
1101
|
-
}));
|
|
1102
|
-
}
|
|
1103
|
-
fetchTokenByCas() {
|
|
1104
|
-
log('yz.auth.service: ', 'fetchTokenByCas');
|
|
1105
|
-
const uri = encodeURIComponent(this.injector.get(WINDOW).location.href);
|
|
1106
|
-
return this.httpClient
|
|
1107
|
-
.get(`/cas-proxy/app/validate_full?callback=${uri}&_allow_anonymous=true×tamp=${new Date().getTime()}`)
|
|
1108
|
-
.pipe(map((response) => {
|
|
1109
|
-
switch (response.errcode) {
|
|
1110
|
-
case 2000:
|
|
1111
|
-
const { access_token, expires_in, refresh_token, scope, token_type } = response.data;
|
|
1112
|
-
return {
|
|
1113
|
-
token: access_token,
|
|
1114
|
-
expired: expires_in,
|
|
1115
|
-
refreshToken: refresh_token,
|
|
1116
|
-
tokenType: token_type,
|
|
1117
|
-
scope
|
|
1118
|
-
};
|
|
1119
|
-
case 2001:
|
|
1120
|
-
this.injector.get(WINDOW).location.href = response.msg;
|
|
1121
|
-
throw Error("Cookie Error: Can't find Cas Cookie,So jump to login!");
|
|
1122
|
-
default:
|
|
1123
|
-
if (response.data) {
|
|
1124
|
-
console.error(response.data);
|
|
1125
|
-
throw Error(response.data);
|
|
1126
|
-
}
|
|
1127
|
-
else if (response.msg) {
|
|
1128
|
-
console.error(response.msg);
|
|
1129
|
-
throw Error(response.msg);
|
|
1130
|
-
}
|
|
1131
|
-
else {
|
|
1132
|
-
console.error('cas unknown error');
|
|
1133
|
-
throw Error('Unknown Error: Cas auth exception!');
|
|
1134
|
-
}
|
|
1135
|
-
}
|
|
1136
|
-
}));
|
|
1137
|
-
}
|
|
1138
|
-
login() {
|
|
1139
|
-
log('yz.auth.service: ', 'login white login form->', this.bis.loginForm);
|
|
1140
|
-
return this.askToken().pipe(mergeMap(token => {
|
|
1141
|
-
log('yz.auth.service: get token->', token);
|
|
1142
|
-
this.csr.set('auth', {
|
|
1143
|
-
token_send_key: 'Authorization',
|
|
1144
|
-
token_send_template: `${token.tokenType} \${token}`,
|
|
1145
|
-
token_send_place: 'header'
|
|
1146
|
-
});
|
|
1147
|
-
log('yz.auth.service: ', 'set token');
|
|
1148
|
-
this.tokenService.set(token);
|
|
1149
|
-
return this.cacheInit();
|
|
1150
|
-
}), mergeAll());
|
|
1151
|
-
}
|
|
1152
|
-
cacheInit() {
|
|
1153
|
-
log('yz.auth.service: ', 'cacheInit');
|
|
1154
|
-
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
1155
|
-
const header = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
1156
|
-
const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
|
|
1157
|
-
return forkJoin(of(user), of(header), of(project)).pipe(mergeMap(([u, h, p]) => {
|
|
1158
|
-
let list = [];
|
|
1159
|
-
// user cache
|
|
1160
|
-
if (!u) {
|
|
1161
|
-
log('yz.auth.service: ', 'fetch user cache');
|
|
1162
|
-
list.push(this.httpClient.get(`/auth/user`).pipe(map((user) => {
|
|
1163
|
-
this.cacheService.set('_yz_user', user.principal);
|
|
1164
|
-
})));
|
|
1165
|
-
}
|
|
1166
|
-
else {
|
|
1167
|
-
log('yz.auth.service: ', 'user recache');
|
|
1168
|
-
list.push(of(() => { }));
|
|
1169
|
-
}
|
|
1170
|
-
// header cache
|
|
1171
|
-
if (!h) {
|
|
1172
|
-
log('yz.auth.service: ', 'fetch header cache');
|
|
1173
|
-
list.push(this.httpClient.get(`/auth/allheader/v2`).pipe(map((header) => {
|
|
1174
|
-
this.cacheService.set('_yz_header', header.data);
|
|
1175
|
-
})));
|
|
1176
|
-
}
|
|
1177
|
-
else {
|
|
1178
|
-
log('yz.auth.service: ', 'header recache');
|
|
1179
|
-
list.push(of(() => { }));
|
|
1180
|
-
}
|
|
1181
|
-
// project cache
|
|
1182
|
-
if (!p) {
|
|
1183
|
-
log('yz.auth.service: ', 'fetch project cache');
|
|
1184
|
-
list.push(this.httpClient.get(`/app-manager/project/info`).pipe(map((info) => {
|
|
1185
|
-
this.cacheService.set('_yz_project_info', info.data);
|
|
1186
|
-
})));
|
|
1187
|
-
}
|
|
1188
|
-
else {
|
|
1189
|
-
log('yz.auth.service: ', 'project recache');
|
|
1190
|
-
list.push(of(() => { }));
|
|
1191
|
-
}
|
|
1192
|
-
return forkJoin(list);
|
|
1193
|
-
}));
|
|
1194
|
-
}
|
|
1195
|
-
}
|
|
1196
|
-
YzAuthService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzAuthService_Factory() { return new YzAuthService(i0.ɵɵinject(i0.INJECTOR)); }, token: YzAuthService, providedIn: "root" });
|
|
1197
|
-
YzAuthService.decorators = [
|
|
1198
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
1199
|
-
];
|
|
1200
|
-
YzAuthService.ctorParameters = () => [
|
|
1201
|
-
{ type: Injector }
|
|
1202
|
-
];
|
|
1203
|
-
|
|
1204
|
-
const CODEMESSAGE = {
|
|
1205
|
-
200: '服务器成功返回请求的数据。',
|
|
1206
|
-
201: '新建或修改数据成功。',
|
|
1207
|
-
202: '一个请求已经进入后台排队(异步任务)。',
|
|
1208
|
-
204: '删除数据成功。',
|
|
1209
|
-
400: '发出的请求有错误,服务器没有进行新建或修改数据的操作。',
|
|
1210
|
-
401: '用户没有权限(令牌、用户名、密码错误)。',
|
|
1211
|
-
403: '用户得到授权,但是访问是被禁止的。',
|
|
1212
|
-
404: '发出的请求针对的是不存在的记录,服务器没有进行操作。',
|
|
1213
|
-
406: '请求的格式不可得。',
|
|
1214
|
-
410: '请求的资源被永久删除,且不会再得到的。',
|
|
1215
|
-
422: '当创建一个对象时,发生一个验证错误。',
|
|
1216
|
-
500: '服务器发生错误,请检查服务器。',
|
|
1217
|
-
502: '网关错误。',
|
|
1218
|
-
503: '服务不可用,服务器暂时过载或维护。',
|
|
1219
|
-
504: '网关超时。'
|
|
1220
|
-
};
|
|
1221
|
-
/**
|
|
1222
|
-
* 默认HTTP拦截器,其注册细节见 `app.module.ts`
|
|
1223
|
-
*/
|
|
1224
|
-
class YzDefaultInterceptor {
|
|
1225
|
-
constructor(injector) {
|
|
1226
|
-
this.injector = injector;
|
|
1227
|
-
this.jump = false;
|
|
1228
|
-
this.refreshToking = false;
|
|
1229
|
-
this.refreshToken$ = new BehaviorSubject(null);
|
|
1230
|
-
if (this.config.refreshTokenType === 'auth-refresh') {
|
|
1231
|
-
console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
|
|
1232
|
-
}
|
|
1233
|
-
}
|
|
1234
|
-
get notification() {
|
|
1235
|
-
return this.injector.get(NzNotificationService);
|
|
1236
|
-
}
|
|
1237
|
-
get tokenSrv() {
|
|
1238
|
-
return this.injector.get(YA_SERVICE_TOKEN);
|
|
1239
|
-
}
|
|
1240
|
-
get http() {
|
|
1241
|
-
return this.injector.get(_HttpClient);
|
|
1242
|
-
}
|
|
1243
|
-
get config() {
|
|
1244
|
-
return mergeBisConfig(this.injector.get(YunzaiConfigService));
|
|
1245
|
-
}
|
|
1246
|
-
goTo(url) {
|
|
1247
|
-
setTimeout(() => this.injector.get(Router).navigateByUrl(url));
|
|
1248
|
-
}
|
|
1249
|
-
checkStatus(ev) {
|
|
1250
|
-
if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
|
|
1251
|
-
return;
|
|
1252
|
-
}
|
|
1253
|
-
if (ev instanceof HttpErrorResponse && (ev.error.message || ev.error.errorMessage)) {
|
|
1254
|
-
if (ev.error.errorMessage) {
|
|
1255
|
-
this.notification.error(`发生了一些错误 `, ev.error.errorMessage);
|
|
1256
|
-
}
|
|
1257
|
-
else {
|
|
1258
|
-
this.notification.error(`发生了一些错误 `, ev.error.message);
|
|
1259
|
-
}
|
|
1260
|
-
return;
|
|
1261
|
-
}
|
|
1262
|
-
if (ev instanceof HttpResponse && ev.body.errorMessage) {
|
|
1263
|
-
this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
|
|
1264
|
-
return;
|
|
1265
|
-
}
|
|
1266
|
-
const errortext = CODEMESSAGE[ev.status] || ev.statusText;
|
|
1267
|
-
this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
|
|
1268
|
-
}
|
|
1269
|
-
ToLogin() {
|
|
1270
|
-
this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
|
|
1271
|
-
setTimeout(() => {
|
|
1272
|
-
localStorage.clear();
|
|
1273
|
-
this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
|
|
1274
|
-
}, 5000);
|
|
1275
|
-
}
|
|
1276
|
-
reAttachToken(req) {
|
|
1277
|
-
var _a;
|
|
1278
|
-
const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
|
|
1279
|
-
return req.clone({
|
|
1280
|
-
setHeaders: {
|
|
1281
|
-
Authorization: `Bearer ${token}`
|
|
1282
|
-
}
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
refreshTokenRequest() {
|
|
1286
|
-
const model = this.tokenSrv.get();
|
|
1287
|
-
const form = new FormData();
|
|
1288
|
-
form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
|
|
1289
|
-
log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
|
|
1290
|
-
return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
|
|
1291
|
-
}
|
|
1292
|
-
tryRefreshToken(ev, req, next) {
|
|
1293
|
-
// 连刷新Token的请求都错了,那就是真错了
|
|
1294
|
-
if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
|
|
1295
|
-
this.ToLogin();
|
|
1296
|
-
return throwError(ev);
|
|
1297
|
-
}
|
|
1298
|
-
// 正在刷新token,所有其他请求排队
|
|
1299
|
-
if (this.refreshToking) {
|
|
1300
|
-
return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
|
|
1301
|
-
}
|
|
1302
|
-
//尝试调用刷新 Token
|
|
1303
|
-
this.refreshToking = true;
|
|
1304
|
-
this.refreshToken$.next(null);
|
|
1305
|
-
// 处理Token
|
|
1306
|
-
return this.refreshTokenRequest().pipe(switchMap(res => {
|
|
1307
|
-
log('yz.default.interceptor: refresh token accessed -> ', res);
|
|
1308
|
-
// 重新保存新 token
|
|
1309
|
-
const { access_token, expires_in, refresh_token, scope, token_type } = res;
|
|
1310
|
-
this.tokenSrv.set({
|
|
1311
|
-
token: access_token,
|
|
1312
|
-
expired: expires_in,
|
|
1313
|
-
refreshToken: refresh_token,
|
|
1314
|
-
tokenType: token_type,
|
|
1315
|
-
scope
|
|
1316
|
-
});
|
|
1317
|
-
// 通知后续请求继续执行
|
|
1318
|
-
this.refreshToking = false;
|
|
1319
|
-
this.refreshToken$.next(res);
|
|
1320
|
-
// 重新发起请求
|
|
1321
|
-
return next.handle(this.reAttachToken(req));
|
|
1322
|
-
}), catchError(err => {
|
|
1323
|
-
this.refreshToking = false;
|
|
1324
|
-
this.ToLogin();
|
|
1325
|
-
return throwError(err);
|
|
1326
|
-
}));
|
|
1327
|
-
}
|
|
1328
|
-
getAdditionalHeaders(headers) {
|
|
1329
|
-
const res = {};
|
|
1330
|
-
const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
|
|
1331
|
-
if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
|
|
1332
|
-
res['Accept-Language'] = lang;
|
|
1333
|
-
}
|
|
1334
|
-
return res;
|
|
1335
|
-
}
|
|
1336
|
-
handleData(ev, req, next) {
|
|
1337
|
-
this.checkStatus(ev);
|
|
1338
|
-
switch (ev.status) {
|
|
1339
|
-
case 200:
|
|
1340
|
-
return of(ev);
|
|
1341
|
-
case 401:
|
|
1342
|
-
if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
|
|
1343
|
-
return this.tryRefreshToken(ev, req, next);
|
|
1344
|
-
}
|
|
1345
|
-
this.ToLogin();
|
|
1346
|
-
break;
|
|
1347
|
-
case 403:
|
|
1348
|
-
case 404:
|
|
1349
|
-
case 500:
|
|
1350
|
-
if (this.jump) {
|
|
1351
|
-
this.goTo(`/exception/${ev.status}`);
|
|
1352
|
-
}
|
|
1353
|
-
break;
|
|
1354
|
-
default:
|
|
1355
|
-
if (ev instanceof HttpErrorResponse) {
|
|
1356
|
-
console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
|
|
1357
|
-
}
|
|
1358
|
-
break;
|
|
1359
|
-
}
|
|
1360
|
-
if (ev instanceof HttpErrorResponse) {
|
|
1361
|
-
return throwError(ev);
|
|
1362
|
-
}
|
|
1363
|
-
else {
|
|
1364
|
-
return of(ev);
|
|
1365
|
-
}
|
|
1366
|
-
}
|
|
1367
|
-
intercept(req, next) {
|
|
1368
|
-
log('yz.default.interceptor.ts: ', 'request ', req);
|
|
1369
|
-
// 统一加前缀
|
|
1370
|
-
let url = req.url;
|
|
1371
|
-
if (!url.startsWith('https://') && !url.startsWith('http://')) {
|
|
1372
|
-
url = this.config.baseUrl + url;
|
|
1373
|
-
}
|
|
1374
|
-
if (url.includes('.json') && url.includes('assets')) {
|
|
1375
|
-
url = req.url;
|
|
1376
|
-
}
|
|
1377
|
-
// 加入语言头
|
|
1378
|
-
const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
|
|
1379
|
-
return next.handle(newReq).pipe(mergeMap(ev => {
|
|
1380
|
-
// 允许统一对请求错误处理
|
|
1381
|
-
if (ev instanceof HttpResponseBase) {
|
|
1382
|
-
return this.handleData(ev, newReq, next);
|
|
1383
|
-
}
|
|
1384
|
-
// 若一切都正常,则后续操作
|
|
1385
|
-
return of(ev);
|
|
1386
|
-
}), catchError((err) => this.handleData(err, newReq, next)));
|
|
1387
|
-
}
|
|
1388
|
-
}
|
|
1389
|
-
YzDefaultInterceptor.decorators = [
|
|
1390
|
-
{ type: Injectable }
|
|
1391
|
-
];
|
|
1392
|
-
YzDefaultInterceptor.ctorParameters = () => [
|
|
1393
|
-
{ type: Injector }
|
|
1394
|
-
];
|
|
1395
|
-
|
|
1396
|
-
function mapYzSideToYelonMenu(menus) {
|
|
1397
|
-
menus.forEach(menu => {
|
|
1398
|
-
menu.badgeDot = menu.badge_dot || null;
|
|
1399
|
-
menu.badgeStatus = menu.badge_status || null;
|
|
1400
|
-
menu.shortcutRoot = menu.shortcut_root || null;
|
|
1401
|
-
menu.reuse = true;
|
|
1402
|
-
if (menu.children) {
|
|
1403
|
-
mapYzSideToYelonMenu(menu.children);
|
|
1404
|
-
}
|
|
1405
|
-
});
|
|
1406
|
-
}
|
|
1407
|
-
function generateAbility(menus, abilities, prefix) {
|
|
1408
|
-
menus.forEach(menu => {
|
|
1409
|
-
if (menu.link) {
|
|
1410
|
-
prefix += menu.link;
|
|
1411
|
-
}
|
|
1412
|
-
else {
|
|
1413
|
-
prefix += '';
|
|
1414
|
-
}
|
|
1415
|
-
if (menu.menuAuths) {
|
|
1416
|
-
menu.menuAuths.forEach((a) => {
|
|
1417
|
-
abilities.push(`${prefix}:${a}`);
|
|
1418
|
-
abilities.push(a);
|
|
1419
|
-
});
|
|
1420
|
-
}
|
|
1421
|
-
if (menu.children) {
|
|
1422
|
-
generateAbility(menu.children, abilities, prefix);
|
|
1423
|
-
}
|
|
1424
|
-
});
|
|
1425
|
-
}
|
|
1426
|
-
class YzStartupService {
|
|
1427
|
-
constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
|
|
1428
|
-
this.menuService = menuService;
|
|
1429
|
-
this.i18n = i18n;
|
|
1430
|
-
this.settingService = settingService;
|
|
1431
|
-
this.aclService = aclService;
|
|
1432
|
-
this.titleService = titleService;
|
|
1433
|
-
this.yzAuthService = yzAuthService;
|
|
1434
|
-
this.cacheService = cacheService;
|
|
1435
|
-
this.configService = configService;
|
|
1436
|
-
this.bis = BUSINESS_DEFAULT_CONFIG;
|
|
1437
|
-
this.bis = mergeBisConfig(this.configService);
|
|
1438
|
-
iconSrv.addIcon(...ICONS);
|
|
1439
|
-
}
|
|
1440
|
-
load() {
|
|
1441
|
-
log$1('startup.service: ', 'load');
|
|
1442
|
-
const defaultLang = this.i18n.defaultLang;
|
|
1443
|
-
return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
|
|
1444
|
-
log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
|
|
1445
|
-
this.i18n.use(defaultLang, langData);
|
|
1446
|
-
return of(null);
|
|
1447
|
-
}), mergeMap(() => {
|
|
1448
|
-
return this.yzAuthService.login();
|
|
1449
|
-
}), mergeMap(v => {
|
|
1450
|
-
// preloader finish
|
|
1451
|
-
this.systemInit();
|
|
1452
|
-
log$1('startup.service: preloader finish');
|
|
1453
|
-
const win = window;
|
|
1454
|
-
if (win && win.appBootstrap) {
|
|
1455
|
-
win.appBootstrap();
|
|
1456
|
-
}
|
|
1457
|
-
return of(v);
|
|
1458
|
-
}));
|
|
1459
|
-
}
|
|
1460
|
-
systemInit() {
|
|
1461
|
-
log$1('startup.service: system init');
|
|
1462
|
-
// user
|
|
1463
|
-
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
1464
|
-
// menu
|
|
1465
|
-
const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
|
|
1466
|
-
mapYzSideToYelonMenu(ms);
|
|
1467
|
-
const currentMenu = ms.pop();
|
|
1468
|
-
this.menuService.add([currentMenu]);
|
|
1469
|
-
// logo app
|
|
1470
|
-
this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
|
|
1471
|
-
this.settingService.setUser({
|
|
1472
|
-
name: user.realname || 'no name',
|
|
1473
|
-
avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
|
|
1474
|
-
email: user.email || 'no email'
|
|
1475
|
-
});
|
|
1476
|
-
// title
|
|
1477
|
-
this.titleService.default = currentMenu.text || 'default application name';
|
|
1478
|
-
this.titleService.setTitle(currentMenu.text || 'no title');
|
|
1479
|
-
// acl
|
|
1480
|
-
const abilities = [];
|
|
1481
|
-
generateAbility([currentMenu], abilities, '');
|
|
1482
|
-
this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
|
|
1483
|
-
return role.roleValue;
|
|
1484
|
-
}).filter((a) => !!a)) || []);
|
|
1485
|
-
this.aclService.attachAbility(abilities);
|
|
1486
|
-
// cache current
|
|
1487
|
-
this.cacheService.set('_yz_current', {
|
|
1488
|
-
text: currentMenu.text,
|
|
1489
|
-
intro: currentMenu.intro,
|
|
1490
|
-
icon: currentMenu.appIconUrl
|
|
1491
|
-
});
|
|
1492
|
-
}
|
|
1493
|
-
}
|
|
1494
|
-
YzStartupService.decorators = [
|
|
1495
|
-
{ type: Injectable }
|
|
1496
|
-
];
|
|
1497
|
-
YzStartupService.ctorParameters = () => [
|
|
1498
|
-
{ type: NzIconService },
|
|
1499
|
-
{ type: MenuService },
|
|
1500
|
-
{ type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
|
|
1501
|
-
{ type: SettingsService },
|
|
1502
|
-
{ type: ACLService },
|
|
1503
|
-
{ type: TitleService },
|
|
1504
|
-
{ type: YzAuthService },
|
|
1505
|
-
{ type: CacheService },
|
|
1506
|
-
{ type: YunzaiConfigService$1 }
|
|
1507
|
-
];
|
|
1508
|
-
function YzStartupServiceFactory(startupService) {
|
|
1509
|
-
return () => startupService.load();
|
|
1510
|
-
}
|
|
1511
|
-
//@ts-ignore
|
|
1512
|
-
const YZ_APPINIT_PROVIDES = [
|
|
1513
|
-
YzStartupService,
|
|
1514
|
-
{
|
|
1515
|
-
provide: APP_INITIALIZER,
|
|
1516
|
-
useFactory: YzStartupServiceFactory,
|
|
1517
|
-
deps: [YzStartupService],
|
|
1518
|
-
multi: true
|
|
1519
|
-
}
|
|
1520
|
-
];
|
|
1521
|
-
|
|
1522
|
-
class PathToRegexpService {
|
|
1523
|
-
constructor() {
|
|
1524
|
-
this.DEFAULT_DELIMITER = '/';
|
|
1525
|
-
this.PATH_REGEXP = new RegExp(['(\\\\.)', '(?:\\:(\\w+)(?:\\(((?:\\\\.|[^\\\\()])+)\\))?|\\(((?:\\\\.|[^\\\\()])+)\\))([+*?])?'].join('|'), 'g');
|
|
1526
|
-
}
|
|
1527
|
-
parse(str, options) {
|
|
1528
|
-
const tokens = [];
|
|
1529
|
-
let key = 0;
|
|
1530
|
-
let index = 0;
|
|
1531
|
-
let path = '';
|
|
1532
|
-
const defaultDelimiter = (options && options.delimiter) || this.DEFAULT_DELIMITER;
|
|
1533
|
-
const whitelist = (options && options.whitelist) || undefined;
|
|
1534
|
-
let pathEscaped = false;
|
|
1535
|
-
let res;
|
|
1536
|
-
while ((res = this.PATH_REGEXP.exec(str)) !== null) {
|
|
1537
|
-
const m = res[0];
|
|
1538
|
-
const escaped = res[1];
|
|
1539
|
-
const offset = res.index;
|
|
1540
|
-
path += str.slice(index, offset);
|
|
1541
|
-
index = offset + m.length;
|
|
1542
|
-
// Ignore already escaped sequences.
|
|
1543
|
-
if (escaped) {
|
|
1544
|
-
path += escaped[1];
|
|
1545
|
-
pathEscaped = true;
|
|
1546
|
-
continue;
|
|
1547
|
-
}
|
|
1548
|
-
let prev = '';
|
|
1549
|
-
const name = res[2];
|
|
1550
|
-
const capture = res[3];
|
|
1551
|
-
const group = res[4];
|
|
1552
|
-
const modifier = res[5];
|
|
1553
|
-
if (!pathEscaped && path.length) {
|
|
1554
|
-
const k = path.length - 1;
|
|
1555
|
-
const c = path[k];
|
|
1556
|
-
const matches = whitelist ? whitelist.indexOf(c) > -1 : true;
|
|
1557
|
-
if (matches) {
|
|
1558
|
-
prev = c;
|
|
1559
|
-
path = path.slice(0, k);
|
|
1560
|
-
}
|
|
1561
|
-
}
|
|
1562
|
-
// Push the current path onto the tokens.
|
|
1563
|
-
if (path) {
|
|
1564
|
-
tokens.push(path);
|
|
1565
|
-
path = '';
|
|
1566
|
-
pathEscaped = false;
|
|
1567
|
-
}
|
|
1568
|
-
const repeat = modifier === '+' || modifier === '*';
|
|
1569
|
-
const optional = modifier === '?' || modifier === '*';
|
|
1570
|
-
const pattern = capture || group;
|
|
1571
|
-
const delimiter = prev || defaultDelimiter;
|
|
1572
|
-
tokens.push({
|
|
1573
|
-
name: name || key++,
|
|
1574
|
-
prefix: prev,
|
|
1575
|
-
delimiter: delimiter,
|
|
1576
|
-
optional: optional,
|
|
1577
|
-
repeat: repeat,
|
|
1578
|
-
pattern: pattern
|
|
1579
|
-
? this.escapeGroup(pattern)
|
|
1580
|
-
: `[^${this.escapeString(delimiter === defaultDelimiter ? delimiter : delimiter + defaultDelimiter)}]+?`
|
|
1581
|
-
});
|
|
1582
|
-
}
|
|
1583
|
-
// Push any remaining characters.
|
|
1584
|
-
if (path || index < str.length) {
|
|
1585
|
-
tokens.push(path + str.substr(index));
|
|
1586
|
-
}
|
|
1587
|
-
return tokens;
|
|
1588
|
-
}
|
|
1589
|
-
compile(str, options) {
|
|
1590
|
-
return this.tokensToFunction(this.parse(str, options), options);
|
|
1591
|
-
}
|
|
1592
|
-
tokensToFunction(tokens, options) {
|
|
1593
|
-
const matches = new Array(tokens.length);
|
|
1594
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
1595
|
-
if (typeof tokens[i] === 'object') {
|
|
1596
|
-
matches[i] = new RegExp(`^(?:${tokens[i].pattern})$`, this.flags(options));
|
|
1597
|
-
}
|
|
1598
|
-
}
|
|
1599
|
-
return function (data, options) {
|
|
1600
|
-
let path = '';
|
|
1601
|
-
const encode = (options && options.encode) || encodeURIComponent;
|
|
1602
|
-
const validate = options ? options.validate !== false : true;
|
|
1603
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
1604
|
-
const token = tokens[i];
|
|
1605
|
-
if (typeof token === 'string') {
|
|
1606
|
-
path += token;
|
|
1607
|
-
continue;
|
|
1608
|
-
}
|
|
1609
|
-
const value = data ? data[token.name] : undefined;
|
|
1610
|
-
let segment;
|
|
1611
|
-
if (Array.isArray(value)) {
|
|
1612
|
-
if (!token.repeat) {
|
|
1613
|
-
throw new TypeError(`Expected "${token.name}" to not repeat, but got array`);
|
|
1614
|
-
}
|
|
1615
|
-
if (value.length === 0) {
|
|
1616
|
-
if (token.optional) {
|
|
1617
|
-
continue;
|
|
1618
|
-
}
|
|
1619
|
-
throw new TypeError(`Expected "${token.name}" to not be empty`);
|
|
1620
|
-
}
|
|
1621
|
-
for (let j = 0; j < value.length; j++) {
|
|
1622
|
-
segment = encode(value[j], token);
|
|
1623
|
-
if (validate && !matches[i].test(segment)) {
|
|
1624
|
-
throw new TypeError(`Expected all "${token.name}" to match "${token.pattern}"`);
|
|
1625
|
-
}
|
|
1626
|
-
path += (j === 0 ? token.prefix : token.delimiter) + segment;
|
|
1627
|
-
}
|
|
1628
|
-
continue;
|
|
1629
|
-
}
|
|
1630
|
-
if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') {
|
|
1631
|
-
segment = encode(String(value), token);
|
|
1632
|
-
if (validate && !matches[i].test(segment)) {
|
|
1633
|
-
throw new TypeError(`Expected "${token.name}" to match "${token.pattern}", but got "${segment}"`);
|
|
1634
|
-
}
|
|
1635
|
-
path += token.prefix + segment;
|
|
1636
|
-
continue;
|
|
1637
|
-
}
|
|
1638
|
-
if (token.optional) {
|
|
1639
|
-
continue;
|
|
1640
|
-
}
|
|
1641
|
-
throw new TypeError(`Expected "${token.name}" to be ${token.repeat ? 'an array' : 'a string'}`);
|
|
1642
|
-
}
|
|
1643
|
-
return path;
|
|
1644
|
-
};
|
|
1645
|
-
}
|
|
1646
|
-
escapeString(str) {
|
|
1647
|
-
return str.replace(/([.+*?=^!:${}()[\]|/\\])/g, '\\$1');
|
|
1648
|
-
}
|
|
1649
|
-
escapeGroup(group) {
|
|
1650
|
-
return group.replace(/([=!:$/()])/g, '\\$1');
|
|
1651
|
-
}
|
|
1652
|
-
flags(options) {
|
|
1653
|
-
return options && options.sensitive ? '' : 'i';
|
|
1654
|
-
}
|
|
1655
|
-
regexpToRegexp(path, keys) {
|
|
1656
|
-
if (!keys) {
|
|
1657
|
-
return path;
|
|
1658
|
-
}
|
|
1659
|
-
const groups = path.source.match(/\((?!\?)/g);
|
|
1660
|
-
if (groups) {
|
|
1661
|
-
for (let i = 0; i < groups.length; i++) {
|
|
1662
|
-
keys.push({
|
|
1663
|
-
name: i,
|
|
1664
|
-
prefix: null,
|
|
1665
|
-
delimiter: null,
|
|
1666
|
-
optional: false,
|
|
1667
|
-
repeat: false,
|
|
1668
|
-
pattern: null
|
|
1669
|
-
});
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
return path;
|
|
1673
|
-
}
|
|
1674
|
-
arrayToRegexp(path, keys, options) {
|
|
1675
|
-
const parts = [];
|
|
1676
|
-
for (let i = 0; i < path.length; i++) {
|
|
1677
|
-
parts.push(this.pathToRegexp(path[i], keys, options).source);
|
|
1678
|
-
}
|
|
1679
|
-
return new RegExp(`(?:${parts.join('|')})`, this.flags(options));
|
|
1680
|
-
}
|
|
1681
|
-
stringToRegexp(path, keys, options) {
|
|
1682
|
-
return this.tokensToRegExp(this.parse(path, options), keys, options);
|
|
1683
|
-
}
|
|
1684
|
-
tokensToRegExp(tokens, keys, options) {
|
|
1685
|
-
options = options || {};
|
|
1686
|
-
const strict = options.strict;
|
|
1687
|
-
const start = options.start !== false;
|
|
1688
|
-
const end = options.end !== false;
|
|
1689
|
-
const delimiter = options.delimiter || this.DEFAULT_DELIMITER;
|
|
1690
|
-
const endsWith = []
|
|
1691
|
-
.concat(options.endsWith || [])
|
|
1692
|
-
.map(this.escapeString)
|
|
1693
|
-
.concat('$')
|
|
1694
|
-
.join('|');
|
|
1695
|
-
let route = start ? '^' : '';
|
|
1696
|
-
for (let i = 0; i < tokens.length; i++) {
|
|
1697
|
-
const token = tokens[i];
|
|
1698
|
-
if (typeof token === 'string') {
|
|
1699
|
-
route += this.escapeString(token);
|
|
1700
|
-
}
|
|
1701
|
-
else {
|
|
1702
|
-
const capture = token.repeat
|
|
1703
|
-
? `(?:${token.pattern})(?:${this.escapeString(token.delimiter)}(?:${token.pattern}))*`
|
|
1704
|
-
: token.pattern;
|
|
1705
|
-
if (keys) {
|
|
1706
|
-
keys.push(token);
|
|
1707
|
-
}
|
|
1708
|
-
if (token.optional) {
|
|
1709
|
-
if (!token.prefix) {
|
|
1710
|
-
route += `(${capture})?`;
|
|
1711
|
-
}
|
|
1712
|
-
else {
|
|
1713
|
-
route += `(?:${this.escapeString(token.prefix)}(${capture}))?`;
|
|
1714
|
-
}
|
|
1715
|
-
}
|
|
1716
|
-
else {
|
|
1717
|
-
route += `${this.escapeString(token.prefix)}(${capture})`;
|
|
1718
|
-
}
|
|
1719
|
-
}
|
|
1720
|
-
}
|
|
1721
|
-
if (end) {
|
|
1722
|
-
if (!strict) {
|
|
1723
|
-
route += `(?:${this.escapeString(delimiter)})?`;
|
|
1724
|
-
}
|
|
1725
|
-
route += endsWith === '$' ? '$' : `(?=${endsWith})`;
|
|
1726
|
-
}
|
|
1727
|
-
else {
|
|
1728
|
-
const endToken = tokens[tokens.length - 1];
|
|
1729
|
-
const isEndDelimited = typeof endToken === 'string' ? endToken[endToken.length - 1] === delimiter : endToken === undefined;
|
|
1730
|
-
if (!strict) {
|
|
1731
|
-
route += `(?:${this.escapeString(delimiter)}(?=${endsWith}))?`;
|
|
1732
|
-
}
|
|
1733
|
-
if (!isEndDelimited) {
|
|
1734
|
-
route += `(?=${this.escapeString(delimiter)}|${endsWith})`;
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
return new RegExp(route, this.flags(options));
|
|
1738
|
-
}
|
|
1739
|
-
pathToRegexp(path, keys, options) {
|
|
1740
|
-
if (path instanceof RegExp) {
|
|
1741
|
-
return this.regexpToRegexp(path, keys);
|
|
1742
|
-
}
|
|
1743
|
-
if (Array.isArray(path)) {
|
|
1744
|
-
return this.arrayToRegexp(/** @type {!Array} */ path, keys, options);
|
|
1745
|
-
}
|
|
1746
|
-
return this.stringToRegexp(/** @type {string} */ path, keys, options);
|
|
1747
|
-
}
|
|
1748
|
-
}
|
|
1749
|
-
PathToRegexpService.ɵprov = i0.ɵɵdefineInjectable({ factory: function PathToRegexpService_Factory() { return new PathToRegexpService(); }, token: PathToRegexpService, providedIn: "root" });
|
|
1750
|
-
PathToRegexpService.decorators = [
|
|
1751
|
-
{ type: Injectable, args: [{
|
|
1752
|
-
providedIn: 'root'
|
|
1753
|
-
},] }
|
|
1754
|
-
];
|
|
1755
|
-
PathToRegexpService.ctorParameters = () => [];
|
|
1756
|
-
|
|
1757
|
-
class ActGuard {
|
|
1758
|
-
constructor(configService, cacheService, pathToRegexp, router) {
|
|
1759
|
-
this.configService = configService;
|
|
1760
|
-
this.cacheService = cacheService;
|
|
1761
|
-
this.pathToRegexp = pathToRegexp;
|
|
1762
|
-
this.router = router;
|
|
1763
|
-
this.bis = BUSINESS_DEFAULT_CONFIG;
|
|
1764
|
-
this.menus = [];
|
|
1765
|
-
this.links = [];
|
|
1766
|
-
log$1('act: ');
|
|
1767
|
-
this.bis = mergeBisConfig(this.configService);
|
|
1768
|
-
log$1('act: config ', this.bis);
|
|
1769
|
-
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
1770
|
-
log$1('act: user ', user);
|
|
1771
|
-
this.menus = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
|
|
1772
|
-
log$1('act: menus ', this.menus);
|
|
1773
|
-
this.getAllLinks(this.menus, this.links);
|
|
1774
|
-
log$1('act: links ', this.links);
|
|
1775
|
-
}
|
|
1776
|
-
canActivate(_, state) {
|
|
1777
|
-
log$1('act: can activate ', state);
|
|
1778
|
-
if (this.preHandle(state)) {
|
|
1779
|
-
return true;
|
|
1780
|
-
}
|
|
1781
|
-
log$1('act: can activate child prehandle success');
|
|
1782
|
-
let canactivate = false;
|
|
1783
|
-
this.links.forEach((link) => {
|
|
1784
|
-
const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
|
|
1785
|
-
log$1(`act: ${link} test ${state.url.split('?')[0]}`);
|
|
1786
|
-
if (regexp.test(state.url.split('?')[0])) {
|
|
1787
|
-
canactivate = true;
|
|
1788
|
-
log$1(`act: test value ${canactivate}`);
|
|
1789
|
-
return;
|
|
1790
|
-
}
|
|
1791
|
-
});
|
|
1792
|
-
if (canactivate) {
|
|
1793
|
-
log$1(`act: test sucess`);
|
|
1794
|
-
return true;
|
|
1795
|
-
}
|
|
1796
|
-
else {
|
|
1797
|
-
log$1(`act: test error`);
|
|
1798
|
-
this.router.navigate(['displayIndex']);
|
|
1799
|
-
return false;
|
|
1800
|
-
}
|
|
1801
|
-
}
|
|
1802
|
-
canActivateChild(_, state) {
|
|
1803
|
-
log$1('act: can activate child ', state);
|
|
1804
|
-
if (this.preHandle(state)) {
|
|
1805
|
-
return true;
|
|
1806
|
-
}
|
|
1807
|
-
log$1('act: can activate child prehandle success');
|
|
1808
|
-
let canactivate = false;
|
|
1809
|
-
this.links.forEach((link) => {
|
|
1810
|
-
const regexp = this.pathToRegexp.stringToRegexp(link, null, null);
|
|
1811
|
-
if (regexp.test(state.url.split('?')[0])) {
|
|
1812
|
-
log$1(`act: ${link} test ${state.url.split('?')[0]}`);
|
|
1813
|
-
canactivate = true;
|
|
1814
|
-
log$1(`act: test value ${canactivate}`);
|
|
1815
|
-
return;
|
|
1816
|
-
}
|
|
1817
|
-
});
|
|
1818
|
-
if (canactivate) {
|
|
1819
|
-
log$1(`act: test sucess`);
|
|
1820
|
-
return true;
|
|
1821
|
-
}
|
|
1822
|
-
else {
|
|
1823
|
-
log$1(`act: test error`);
|
|
1824
|
-
this.router.navigate(['displayIndex']);
|
|
1825
|
-
return false;
|
|
1826
|
-
}
|
|
1827
|
-
}
|
|
1828
|
-
preHandle(state) {
|
|
1829
|
-
return (state.url.includes('error') ||
|
|
1830
|
-
state.url.includes('exception') ||
|
|
1831
|
-
state.url.includes('displayIndex') ||
|
|
1832
|
-
state.url === '' ||
|
|
1833
|
-
state.url === null ||
|
|
1834
|
-
state.url === '/' ||
|
|
1835
|
-
state.url.includes('iframePage'));
|
|
1836
|
-
}
|
|
1837
|
-
getAllLinks(menu, links) {
|
|
1838
|
-
menu.forEach((sider) => {
|
|
1839
|
-
if (sider.link) {
|
|
1840
|
-
links.push(sider.link);
|
|
1841
|
-
}
|
|
1842
|
-
if (sider.children && sider.children.length > 0) {
|
|
1843
|
-
this.getAllLinks(sider.children, links);
|
|
1844
|
-
}
|
|
1845
|
-
});
|
|
1846
|
-
}
|
|
1847
|
-
}
|
|
1848
|
-
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" });
|
|
1849
|
-
ActGuard.decorators = [
|
|
1850
|
-
{ type: Injectable, args: [{
|
|
1851
|
-
providedIn: 'root'
|
|
1852
|
-
},] }
|
|
1853
|
-
];
|
|
1854
|
-
ActGuard.ctorParameters = () => [
|
|
1855
|
-
{ type: YunzaiConfigService$1 },
|
|
1856
|
-
{ type: CacheService },
|
|
1857
|
-
{ type: PathToRegexpService },
|
|
1858
|
-
{ type: Router }
|
|
1859
|
-
];
|
|
1860
|
-
|
|
1861
|
-
// export * from './contact/contact.component';
|
|
1862
|
-
// export * from './contact/contact.service';
|
|
1863
|
-
|
|
1864
|
-
/**
|
|
1865
|
-
* Generated bundle index. Do not edit.
|
|
1866
|
-
*/
|
|
1867
|
-
|
|
1868
|
-
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, YzHeaderApplicationComponent as ɵa, YzHeaderNotifyComponent as ɵb, YzHeaderThemBtnComponent as ɵc, YzHeaderUserComponent as ɵd, YzHeaderFullScreenComponent as ɵe, YzHeaderClearStorageComponent as ɵf, YzHeaderI18NComponent as ɵg };
|
|
1869
|
-
//# sourceMappingURL=layout.js.map
|