@yelon/bis 12.0.10 → 12.0.11
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/LICENSE +21 -21
- package/bis.d.ts +4 -4
- package/bundles/bis.umd.js +7 -7
- package/bundles/layout.umd.js +1609 -1609
- package/bundles/shared.umd.js +1225 -1225
- package/esm2015/bis.js +4 -4
- package/esm2015/layout/bis.config.js +10 -10
- package/esm2015/layout/layout.js +5 -5
- package/esm2015/layout/layout.module.js +34 -34
- package/esm2015/layout/public_api.js +10 -10
- package/esm2015/layout/stomp.config.js +19 -19
- package/esm2015/layout/widgets/index.js +7 -7
- package/esm2015/layout/widgets/yz.application.component.js +132 -132
- package/esm2015/layout/widgets/yz.clear-storage.component.js +35 -35
- package/esm2015/layout/widgets/yz.fullscreen.component.js +32 -32
- package/esm2015/layout/widgets/yz.i18n.component.js +50 -50
- package/esm2015/layout/widgets/yz.notify.component.js +143 -143
- package/esm2015/layout/widgets/yz.them-btn.component.js +106 -106
- package/esm2015/layout/widgets/yz.user.component.js +57 -57
- package/esm2015/layout/yz.auth.service.js +157 -157
- package/esm2015/layout/yz.basic.component.js +40 -40
- package/esm2015/layout/yz.default.interceptor.js +191 -191
- package/esm2015/layout/yz.i18n.service.js +103 -103
- package/esm2015/layout/yz.startup.service.js +137 -137
- package/esm2015/layout/yz.stomp.service.js +90 -90
- package/esm2015/public_api.js +1 -1
- package/esm2015/shared/public_api.js +4 -4
- package/esm2015/shared/shared-yelon.module.js +107 -107
- package/esm2015/shared/shared-zorro.module.js +78 -78
- package/esm2015/shared/shared.js +4 -4
- package/esm2015/shared/shared.module.js +15 -15
- package/esm2015/shared/style-icons.js +795 -795
- package/fesm2015/bis.js +2 -2
- package/fesm2015/layout.js +1207 -1207
- package/fesm2015/shared.js +901 -901
- package/layout/bis.config.d.ts +3 -3
- package/layout/layout.d.ts +5 -5
- package/layout/layout.module.d.ts +2 -2
- package/layout/public_api.d.ts +10 -10
- package/layout/stomp.config.d.ts +3 -3
- package/layout/widgets/index.d.ts +7 -7
- package/layout/widgets/yz.application.component.d.ts +45 -45
- package/layout/widgets/yz.clear-storage.component.d.ts +8 -8
- package/layout/widgets/yz.fullscreen.component.d.ts +6 -6
- package/layout/widgets/yz.i18n.component.d.ts +19 -19
- package/layout/widgets/yz.notify.component.d.ts +25 -25
- package/layout/widgets/yz.them-btn.component.d.ts +29 -29
- package/layout/widgets/yz.user.component.d.ts +25 -25
- package/layout/yz.auth.service.d.ts +19 -19
- package/layout/yz.basic.component.d.ts +15 -15
- package/layout/yz.default.interceptor.d.ts +25 -25
- package/layout/yz.i18n.service.d.ts +24 -24
- package/layout/yz.startup.service.d.ts +31 -31
- package/layout/yz.stomp.service.d.ts +39 -39
- package/package.json +10 -10
- package/public_api.d.ts +2 -2
- package/shared/public_api.d.ts +4 -4
- package/shared/shared-yelon.module.d.ts +3 -3
- package/shared/shared-zorro.module.d.ts +2 -2
- package/shared/shared.d.ts +4 -4
- package/shared/shared.module.d.ts +2 -2
- package/shared/style-icons.d.ts +1 -1
package/fesm2015/layout.js
CHANGED
|
@@ -38,212 +38,212 @@ import { NzNotificationService } from 'ng-zorro-antd/notification';
|
|
|
38
38
|
import { NzIconService } from 'ng-zorro-antd/icon';
|
|
39
39
|
import { ACLService } from '@yelon/acl';
|
|
40
40
|
|
|
41
|
-
// 请参考:https://ng.yunzainfo.com/docs/i18n
|
|
42
|
-
const DEFAULT = 'zh-CN';
|
|
43
|
-
const LANGS = {
|
|
44
|
-
'zh-CN': {
|
|
45
|
-
text: '简体中文',
|
|
46
|
-
ng: ngZh,
|
|
47
|
-
zorro: zh_CN,
|
|
48
|
-
date: zhCN,
|
|
49
|
-
yelon: zh_CN$1,
|
|
50
|
-
abbr: '🇨🇳'
|
|
51
|
-
},
|
|
52
|
-
'zh-TW': {
|
|
53
|
-
text: '繁体中文',
|
|
54
|
-
ng: ngZhTw,
|
|
55
|
-
zorro: zh_TW,
|
|
56
|
-
date: zhTW,
|
|
57
|
-
yelon: zh_TW$1,
|
|
58
|
-
abbr: '🇭🇰'
|
|
59
|
-
},
|
|
60
|
-
'en-US': {
|
|
61
|
-
text: 'English',
|
|
62
|
-
ng: ngEn,
|
|
63
|
-
zorro: en_US,
|
|
64
|
-
date: enUS,
|
|
65
|
-
yelon: en_US$1,
|
|
66
|
-
abbr: '🇬🇧'
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
class YzI18NService extends YunzaiI18nBaseService {
|
|
70
|
-
constructor(http, settings, nzI18nService, yelonLocaleService, platform, cogSrv) {
|
|
71
|
-
super(cogSrv);
|
|
72
|
-
this.http = http;
|
|
73
|
-
this.settings = settings;
|
|
74
|
-
this.nzI18nService = nzI18nService;
|
|
75
|
-
this.yelonLocaleService = yelonLocaleService;
|
|
76
|
-
this.platform = platform;
|
|
77
|
-
this._defaultLang = DEFAULT;
|
|
78
|
-
this._langs = Object.keys(LANGS).map(code => {
|
|
79
|
-
const item = LANGS[code];
|
|
80
|
-
return { code, text: item.text, abbr: item.abbr };
|
|
81
|
-
});
|
|
82
|
-
const defaultLang = this.getDefaultLang();
|
|
83
|
-
if (this._langs.findIndex(w => w.code === defaultLang)) {
|
|
84
|
-
this._defaultLang = defaultLang;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
getDefaultLang() {
|
|
88
|
-
if (!this.platform.isBrowser) {
|
|
89
|
-
return DEFAULT;
|
|
90
|
-
}
|
|
91
|
-
if (this.settings.layout.lang) {
|
|
92
|
-
return this.settings.layout.lang;
|
|
93
|
-
}
|
|
94
|
-
let res = (navigator.languages ? navigator.languages[0] : null) || navigator.language;
|
|
95
|
-
const arr = res.split('-');
|
|
96
|
-
return arr.length <= 1 ? res : `${arr[0]}-${arr[1].toUpperCase()}`;
|
|
97
|
-
}
|
|
98
|
-
loadLangData(lang) {
|
|
99
|
-
return this.http.get(`assets/tmp/i18n/${lang}.json`);
|
|
100
|
-
}
|
|
101
|
-
use(lang, data) {
|
|
102
|
-
if (this._currentLang === lang)
|
|
103
|
-
return;
|
|
104
|
-
this._data = data;
|
|
105
|
-
const item = LANGS[lang];
|
|
106
|
-
registerLocaleData(item.ng);
|
|
107
|
-
this.nzI18nService.setLocale(item.zorro);
|
|
108
|
-
this.nzI18nService.setDateLocale(item.date);
|
|
109
|
-
this.yelonLocaleService.setLocale(item.yelon);
|
|
110
|
-
this._currentLang = lang;
|
|
111
|
-
this._change$.next(lang);
|
|
112
|
-
}
|
|
113
|
-
getLangs() {
|
|
114
|
-
return this._langs;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
YzI18NService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzI18NService_Factory() { return new YzI18NService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i1.SettingsService), i0.ɵɵinject(i2.NzI18nService), i0.ɵɵinject(i1.YelonLocaleService), i0.ɵɵinject(i3.Platform), i0.ɵɵinject(i4.YunzaiConfigService)); }, token: YzI18NService, providedIn: "root" });
|
|
118
|
-
YzI18NService.decorators = [
|
|
119
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
120
|
-
];
|
|
121
|
-
YzI18NService.ctorParameters = () => [
|
|
122
|
-
{ type: _HttpClient },
|
|
123
|
-
{ type: SettingsService },
|
|
124
|
-
{ type: NzI18nService },
|
|
125
|
-
{ type: YelonLocaleService },
|
|
126
|
-
{ type: Platform },
|
|
127
|
-
{ type: YunzaiConfigService }
|
|
41
|
+
// 请参考:https://ng.yunzainfo.com/docs/i18n
|
|
42
|
+
const DEFAULT = 'zh-CN';
|
|
43
|
+
const LANGS = {
|
|
44
|
+
'zh-CN': {
|
|
45
|
+
text: '简体中文',
|
|
46
|
+
ng: ngZh,
|
|
47
|
+
zorro: zh_CN,
|
|
48
|
+
date: zhCN,
|
|
49
|
+
yelon: zh_CN$1,
|
|
50
|
+
abbr: '🇨🇳'
|
|
51
|
+
},
|
|
52
|
+
'zh-TW': {
|
|
53
|
+
text: '繁体中文',
|
|
54
|
+
ng: ngZhTw,
|
|
55
|
+
zorro: zh_TW,
|
|
56
|
+
date: zhTW,
|
|
57
|
+
yelon: zh_TW$1,
|
|
58
|
+
abbr: '🇭🇰'
|
|
59
|
+
},
|
|
60
|
+
'en-US': {
|
|
61
|
+
text: 'English',
|
|
62
|
+
ng: ngEn,
|
|
63
|
+
zorro: en_US,
|
|
64
|
+
date: enUS,
|
|
65
|
+
yelon: en_US$1,
|
|
66
|
+
abbr: '🇬🇧'
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
class YzI18NService extends YunzaiI18nBaseService {
|
|
70
|
+
constructor(http, settings, nzI18nService, yelonLocaleService, platform, cogSrv) {
|
|
71
|
+
super(cogSrv);
|
|
72
|
+
this.http = http;
|
|
73
|
+
this.settings = settings;
|
|
74
|
+
this.nzI18nService = nzI18nService;
|
|
75
|
+
this.yelonLocaleService = yelonLocaleService;
|
|
76
|
+
this.platform = platform;
|
|
77
|
+
this._defaultLang = DEFAULT;
|
|
78
|
+
this._langs = Object.keys(LANGS).map(code => {
|
|
79
|
+
const item = LANGS[code];
|
|
80
|
+
return { code, text: item.text, abbr: item.abbr };
|
|
81
|
+
});
|
|
82
|
+
const defaultLang = this.getDefaultLang();
|
|
83
|
+
if (this._langs.findIndex(w => w.code === defaultLang)) {
|
|
84
|
+
this._defaultLang = defaultLang;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
getDefaultLang() {
|
|
88
|
+
if (!this.platform.isBrowser) {
|
|
89
|
+
return DEFAULT;
|
|
90
|
+
}
|
|
91
|
+
if (this.settings.layout.lang) {
|
|
92
|
+
return this.settings.layout.lang;
|
|
93
|
+
}
|
|
94
|
+
let res = (navigator.languages ? navigator.languages[0] : null) || navigator.language;
|
|
95
|
+
const arr = res.split('-');
|
|
96
|
+
return arr.length <= 1 ? res : `${arr[0]}-${arr[1].toUpperCase()}`;
|
|
97
|
+
}
|
|
98
|
+
loadLangData(lang) {
|
|
99
|
+
return this.http.get(`assets/tmp/i18n/${lang}.json`);
|
|
100
|
+
}
|
|
101
|
+
use(lang, data) {
|
|
102
|
+
if (this._currentLang === lang)
|
|
103
|
+
return;
|
|
104
|
+
this._data = data;
|
|
105
|
+
const item = LANGS[lang];
|
|
106
|
+
registerLocaleData(item.ng);
|
|
107
|
+
this.nzI18nService.setLocale(item.zorro);
|
|
108
|
+
this.nzI18nService.setDateLocale(item.date);
|
|
109
|
+
this.yelonLocaleService.setLocale(item.yelon);
|
|
110
|
+
this._currentLang = lang;
|
|
111
|
+
this._change$.next(lang);
|
|
112
|
+
}
|
|
113
|
+
getLangs() {
|
|
114
|
+
return this._langs;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
YzI18NService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzI18NService_Factory() { return new YzI18NService(i0.ɵɵinject(i1._HttpClient), i0.ɵɵinject(i1.SettingsService), i0.ɵɵinject(i2.NzI18nService), i0.ɵɵinject(i1.YelonLocaleService), i0.ɵɵinject(i3.Platform), i0.ɵɵinject(i4.YunzaiConfigService)); }, token: YzI18NService, providedIn: "root" });
|
|
118
|
+
YzI18NService.decorators = [
|
|
119
|
+
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
120
|
+
];
|
|
121
|
+
YzI18NService.ctorParameters = () => [
|
|
122
|
+
{ type: _HttpClient },
|
|
123
|
+
{ type: SettingsService },
|
|
124
|
+
{ type: NzI18nService },
|
|
125
|
+
{ type: YelonLocaleService },
|
|
126
|
+
{ type: Platform },
|
|
127
|
+
{ type: YunzaiConfigService }
|
|
128
128
|
];
|
|
129
129
|
|
|
130
|
-
var TOPIC;
|
|
131
|
-
(function (TOPIC) {
|
|
132
|
-
TOPIC[TOPIC["FULL"] = 0] = "FULL";
|
|
133
|
-
TOPIC[TOPIC["OWN"] = 1] = "OWN";
|
|
134
|
-
TOPIC[TOPIC["EVERY"] = 2] = "EVERY";
|
|
135
|
-
})(TOPIC || (TOPIC = {}));
|
|
136
|
-
class YzHeaderApplicationComponent {
|
|
137
|
-
constructor(inject, cacheService, i18n, http) {
|
|
138
|
-
this.inject = inject;
|
|
139
|
-
this.cacheService = cacheService;
|
|
140
|
-
this.i18n = i18n;
|
|
141
|
-
this.http = http;
|
|
142
|
-
this.T = TOPIC;
|
|
143
|
-
this.active = false;
|
|
144
|
-
this.topicData = [];
|
|
145
|
-
this.listData = [];
|
|
146
|
-
this.topic = TOPIC.FULL;
|
|
147
|
-
this.searchValue = null;
|
|
148
|
-
this.subs = [];
|
|
149
|
-
}
|
|
150
|
-
ngOnInit() {
|
|
151
|
-
this.topicData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
152
|
-
this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
153
|
-
}
|
|
154
|
-
ngOnDestroy() {
|
|
155
|
-
this.subs.forEach(f => f.unsubscribe());
|
|
156
|
-
}
|
|
157
|
-
diffChange(flag) {
|
|
158
|
-
if (flag) {
|
|
159
|
-
this.active = flag;
|
|
160
|
-
}
|
|
161
|
-
else {
|
|
162
|
-
this.active = !this.active;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
initTopic(topic) {
|
|
166
|
-
this.searchValue = null;
|
|
167
|
-
this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
168
|
-
this.topic = topic;
|
|
169
|
-
}
|
|
170
|
-
full() {
|
|
171
|
-
this.initTopic(TOPIC.FULL);
|
|
172
|
-
}
|
|
173
|
-
own() {
|
|
174
|
-
this.initTopic(TOPIC.OWN);
|
|
175
|
-
const temp = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
176
|
-
this.listData = temp
|
|
177
|
-
.filter((topic) => {
|
|
178
|
-
topic.children = topic.children.filter((child) => {
|
|
179
|
-
return child.auth;
|
|
180
|
-
});
|
|
181
|
-
return topic;
|
|
182
|
-
})
|
|
183
|
-
.filter((topic) => {
|
|
184
|
-
return topic.children.length > 0;
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
every(e) {
|
|
188
|
-
this.initTopic(TOPIC.EVERY);
|
|
189
|
-
this.choosed = e;
|
|
190
|
-
const temp = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
191
|
-
this.listData = [...temp.filter(t => t.key === e.key)[0].children];
|
|
192
|
-
}
|
|
193
|
-
onSearch() {
|
|
194
|
-
const temp = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
195
|
-
// 如果搜索输入的有值
|
|
196
|
-
if (this.searchValue) {
|
|
197
|
-
// 过滤菜单过滤出搜索的值
|
|
198
|
-
this.listData = temp
|
|
199
|
-
.filter((topic) => {
|
|
200
|
-
if (this.i18n.fanyi(topic.name).includes(this.searchValue)) {
|
|
201
|
-
return topic;
|
|
202
|
-
}
|
|
203
|
-
else {
|
|
204
|
-
topic.children = topic.children.filter((child) => {
|
|
205
|
-
return this.i18n.fanyi(child.name).includes(this.searchValue);
|
|
206
|
-
});
|
|
207
|
-
return topic;
|
|
208
|
-
}
|
|
209
|
-
})
|
|
210
|
-
.filter((topic) => {
|
|
211
|
-
return topic.children.length > 0;
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
// 如果没有值,取消搜索
|
|
216
|
-
this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
open(topic) {
|
|
220
|
-
if (topic.key) {
|
|
221
|
-
this.subs.push(this.http
|
|
222
|
-
.post(`/app-manager/web-scan/save`, {
|
|
223
|
-
appId: topic.key,
|
|
224
|
-
createDate: new Date()
|
|
225
|
-
})
|
|
226
|
-
.subscribe());
|
|
227
|
-
}
|
|
228
|
-
switch (topic.target) {
|
|
229
|
-
case 'href':
|
|
230
|
-
this.inject.get(WINDOW).location.href = topic.url;
|
|
231
|
-
break;
|
|
232
|
-
case 'blank':
|
|
233
|
-
this.inject.get(WINDOW).location.href = topic.url;
|
|
234
|
-
break;
|
|
235
|
-
case 'target':
|
|
236
|
-
this.inject.get(WINDOW).location.href = topic.url;
|
|
237
|
-
break;
|
|
238
|
-
default:
|
|
239
|
-
this.inject.get(WINDOW).location.href = topic.url;
|
|
240
|
-
break;
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
YzHeaderApplicationComponent.decorators = [
|
|
245
|
-
{ type: Component, args: [{
|
|
246
|
-
selector: 'yz-header-application',
|
|
130
|
+
var TOPIC;
|
|
131
|
+
(function (TOPIC) {
|
|
132
|
+
TOPIC[TOPIC["FULL"] = 0] = "FULL";
|
|
133
|
+
TOPIC[TOPIC["OWN"] = 1] = "OWN";
|
|
134
|
+
TOPIC[TOPIC["EVERY"] = 2] = "EVERY";
|
|
135
|
+
})(TOPIC || (TOPIC = {}));
|
|
136
|
+
class YzHeaderApplicationComponent {
|
|
137
|
+
constructor(inject, cacheService, i18n, http) {
|
|
138
|
+
this.inject = inject;
|
|
139
|
+
this.cacheService = cacheService;
|
|
140
|
+
this.i18n = i18n;
|
|
141
|
+
this.http = http;
|
|
142
|
+
this.T = TOPIC;
|
|
143
|
+
this.active = false;
|
|
144
|
+
this.topicData = [];
|
|
145
|
+
this.listData = [];
|
|
146
|
+
this.topic = TOPIC.FULL;
|
|
147
|
+
this.searchValue = null;
|
|
148
|
+
this.subs = [];
|
|
149
|
+
}
|
|
150
|
+
ngOnInit() {
|
|
151
|
+
this.topicData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
152
|
+
this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
153
|
+
}
|
|
154
|
+
ngOnDestroy() {
|
|
155
|
+
this.subs.forEach(f => f.unsubscribe());
|
|
156
|
+
}
|
|
157
|
+
diffChange(flag) {
|
|
158
|
+
if (flag) {
|
|
159
|
+
this.active = flag;
|
|
160
|
+
}
|
|
161
|
+
else {
|
|
162
|
+
this.active = !this.active;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
initTopic(topic) {
|
|
166
|
+
this.searchValue = null;
|
|
167
|
+
this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
168
|
+
this.topic = topic;
|
|
169
|
+
}
|
|
170
|
+
full() {
|
|
171
|
+
this.initTopic(TOPIC.FULL);
|
|
172
|
+
}
|
|
173
|
+
own() {
|
|
174
|
+
this.initTopic(TOPIC.OWN);
|
|
175
|
+
const temp = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
176
|
+
this.listData = temp
|
|
177
|
+
.filter((topic) => {
|
|
178
|
+
topic.children = topic.children.filter((child) => {
|
|
179
|
+
return child.auth;
|
|
180
|
+
});
|
|
181
|
+
return topic;
|
|
182
|
+
})
|
|
183
|
+
.filter((topic) => {
|
|
184
|
+
return topic.children.length > 0;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
every(e) {
|
|
188
|
+
this.initTopic(TOPIC.EVERY);
|
|
189
|
+
this.choosed = e;
|
|
190
|
+
const temp = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
191
|
+
this.listData = [...temp.filter(t => t.key === e.key)[0].children];
|
|
192
|
+
}
|
|
193
|
+
onSearch() {
|
|
194
|
+
const temp = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
195
|
+
// 如果搜索输入的有值
|
|
196
|
+
if (this.searchValue) {
|
|
197
|
+
// 过滤菜单过滤出搜索的值
|
|
198
|
+
this.listData = temp
|
|
199
|
+
.filter((topic) => {
|
|
200
|
+
if (this.i18n.fanyi(topic.name).includes(this.searchValue)) {
|
|
201
|
+
return topic;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
topic.children = topic.children.filter((child) => {
|
|
205
|
+
return this.i18n.fanyi(child.name).includes(this.searchValue);
|
|
206
|
+
});
|
|
207
|
+
return topic;
|
|
208
|
+
}
|
|
209
|
+
})
|
|
210
|
+
.filter((topic) => {
|
|
211
|
+
return topic.children.length > 0;
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
else {
|
|
215
|
+
// 如果没有值,取消搜索
|
|
216
|
+
this.listData = this.cacheService.get('_yz_header', { mode: 'none' });
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
open(topic) {
|
|
220
|
+
if (topic.key) {
|
|
221
|
+
this.subs.push(this.http
|
|
222
|
+
.post(`/app-manager/web-scan/save`, {
|
|
223
|
+
appId: topic.key,
|
|
224
|
+
createDate: new Date()
|
|
225
|
+
})
|
|
226
|
+
.subscribe());
|
|
227
|
+
}
|
|
228
|
+
switch (topic.target) {
|
|
229
|
+
case 'href':
|
|
230
|
+
this.inject.get(WINDOW).location.href = topic.url;
|
|
231
|
+
break;
|
|
232
|
+
case 'blank':
|
|
233
|
+
this.inject.get(WINDOW).location.href = topic.url;
|
|
234
|
+
break;
|
|
235
|
+
case 'target':
|
|
236
|
+
this.inject.get(WINDOW).location.href = topic.url;
|
|
237
|
+
break;
|
|
238
|
+
default:
|
|
239
|
+
this.inject.get(WINDOW).location.href = topic.url;
|
|
240
|
+
break;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
YzHeaderApplicationComponent.decorators = [
|
|
245
|
+
{ type: Component, args: [{
|
|
246
|
+
selector: 'yz-header-application',
|
|
247
247
|
template: `
|
|
248
248
|
<!-- template start-->
|
|
249
249
|
<ng-template #search>
|
|
@@ -311,46 +311,46 @@ YzHeaderApplicationComponent.decorators = [
|
|
|
311
311
|
</div>
|
|
312
312
|
</div>
|
|
313
313
|
<!-- header end-->
|
|
314
|
-
`,
|
|
315
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
316
|
-
},] }
|
|
317
|
-
];
|
|
318
|
-
YzHeaderApplicationComponent.ctorParameters = () => [
|
|
319
|
-
{ type: Injector },
|
|
320
|
-
{ type: CacheService },
|
|
321
|
-
{ type: YzI18NService },
|
|
322
|
-
{ type: _HttpClient }
|
|
314
|
+
`,
|
|
315
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
316
|
+
},] }
|
|
317
|
+
];
|
|
318
|
+
YzHeaderApplicationComponent.ctorParameters = () => [
|
|
319
|
+
{ type: Injector },
|
|
320
|
+
{ type: CacheService },
|
|
321
|
+
{ type: YzI18NService },
|
|
322
|
+
{ type: _HttpClient }
|
|
323
323
|
];
|
|
324
324
|
|
|
325
|
-
class YzHeaderI18NComponent {
|
|
326
|
-
constructor(settings, i18n, doc) {
|
|
327
|
-
this.settings = settings;
|
|
328
|
-
this.i18n = i18n;
|
|
329
|
-
this.doc = doc;
|
|
330
|
-
/** Whether to display language text */
|
|
331
|
-
this.showLangText = true;
|
|
332
|
-
}
|
|
333
|
-
get langs() {
|
|
334
|
-
return this.i18n.getLangs();
|
|
335
|
-
}
|
|
336
|
-
get curLangCode() {
|
|
337
|
-
return this.settings.layout.lang;
|
|
338
|
-
}
|
|
339
|
-
change(lang) {
|
|
340
|
-
const spinEl = this.doc.createElement('div');
|
|
341
|
-
spinEl.setAttribute('class', `page-loading ant-spin ant-spin-lg ant-spin-spinning`);
|
|
342
|
-
spinEl.innerHTML = `<span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>`;
|
|
343
|
-
this.doc.body.appendChild(spinEl);
|
|
344
|
-
this.i18n.loadLangData(lang).subscribe(res => {
|
|
345
|
-
this.i18n.use(lang, res);
|
|
346
|
-
this.settings.setLayout('lang', lang);
|
|
347
|
-
setTimeout(() => this.doc.location.reload());
|
|
348
|
-
});
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
YzHeaderI18NComponent.decorators = [
|
|
352
|
-
{ type: Component, args: [{
|
|
353
|
-
selector: 'yz-header-i18n',
|
|
325
|
+
class YzHeaderI18NComponent {
|
|
326
|
+
constructor(settings, i18n, doc) {
|
|
327
|
+
this.settings = settings;
|
|
328
|
+
this.i18n = i18n;
|
|
329
|
+
this.doc = doc;
|
|
330
|
+
/** Whether to display language text */
|
|
331
|
+
this.showLangText = true;
|
|
332
|
+
}
|
|
333
|
+
get langs() {
|
|
334
|
+
return this.i18n.getLangs();
|
|
335
|
+
}
|
|
336
|
+
get curLangCode() {
|
|
337
|
+
return this.settings.layout.lang;
|
|
338
|
+
}
|
|
339
|
+
change(lang) {
|
|
340
|
+
const spinEl = this.doc.createElement('div');
|
|
341
|
+
spinEl.setAttribute('class', `page-loading ant-spin ant-spin-lg ant-spin-spinning`);
|
|
342
|
+
spinEl.innerHTML = `<span class="ant-spin-dot ant-spin-dot-spin"><i></i><i></i><i></i><i></i></span>`;
|
|
343
|
+
this.doc.body.appendChild(spinEl);
|
|
344
|
+
this.i18n.loadLangData(lang).subscribe(res => {
|
|
345
|
+
this.i18n.use(lang, res);
|
|
346
|
+
this.settings.setLayout('lang', lang);
|
|
347
|
+
setTimeout(() => this.doc.location.reload());
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
YzHeaderI18NComponent.decorators = [
|
|
352
|
+
{ type: Component, args: [{
|
|
353
|
+
selector: 'yz-header-i18n',
|
|
354
354
|
template: `
|
|
355
355
|
<div *ngIf="showLangText" nz-dropdown [nzDropdownMenu]="langMenu" nzPlacement="bottomRight">
|
|
356
356
|
<i nz-icon nzType="global"></i>
|
|
@@ -378,145 +378,145 @@ YzHeaderI18NComponent.decorators = [
|
|
|
378
378
|
</li>
|
|
379
379
|
</ul>
|
|
380
380
|
</nz-dropdown-menu>
|
|
381
|
-
`,
|
|
382
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
383
|
-
},] }
|
|
384
|
-
];
|
|
385
|
-
YzHeaderI18NComponent.ctorParameters = () => [
|
|
386
|
-
{ type: SettingsService },
|
|
387
|
-
{ type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
|
|
388
|
-
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
|
|
389
|
-
];
|
|
390
|
-
YzHeaderI18NComponent.propDecorators = {
|
|
391
|
-
showLangText: [{ type: Input }]
|
|
392
|
-
};
|
|
393
|
-
__decorate([
|
|
394
|
-
InputBoolean()
|
|
381
|
+
`,
|
|
382
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
383
|
+
},] }
|
|
384
|
+
];
|
|
385
|
+
YzHeaderI18NComponent.ctorParameters = () => [
|
|
386
|
+
{ type: SettingsService },
|
|
387
|
+
{ type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
|
|
388
|
+
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] }
|
|
389
|
+
];
|
|
390
|
+
YzHeaderI18NComponent.propDecorators = {
|
|
391
|
+
showLangText: [{ type: Input }]
|
|
392
|
+
};
|
|
393
|
+
__decorate([
|
|
394
|
+
InputBoolean()
|
|
395
395
|
], YzHeaderI18NComponent.prototype, "showLangText", void 0);
|
|
396
396
|
|
|
397
|
-
class YzHeaderNotifyComponent {
|
|
398
|
-
constructor(injector, msg, nzI18n, cdr, httpClient) {
|
|
399
|
-
this.injector = injector;
|
|
400
|
-
this.msg = msg;
|
|
401
|
-
this.nzI18n = nzI18n;
|
|
402
|
-
this.cdr = cdr;
|
|
403
|
-
this.httpClient = httpClient;
|
|
404
|
-
this.data = [
|
|
405
|
-
{
|
|
406
|
-
key: 'msg',
|
|
407
|
-
title: '消息',
|
|
408
|
-
list: [],
|
|
409
|
-
emptyText: '您已读完所有消息',
|
|
410
|
-
emptyImage: './assets/tmp/img/message.svg',
|
|
411
|
-
clearText: '清空消息'
|
|
412
|
-
},
|
|
413
|
-
{
|
|
414
|
-
key: 'todo',
|
|
415
|
-
title: '待办',
|
|
416
|
-
list: [],
|
|
417
|
-
emptyText: '你已完成所有待办',
|
|
418
|
-
emptyImage: './assets/tmp/img/todo.svg',
|
|
419
|
-
clearText: '重新加载'
|
|
420
|
-
},
|
|
421
|
-
{
|
|
422
|
-
key: 'notice',
|
|
423
|
-
title: '通知',
|
|
424
|
-
list: [],
|
|
425
|
-
emptyText: '你已查看所有通知',
|
|
426
|
-
emptyImage: './assets/tmp/img/notice.svg',
|
|
427
|
-
clearText: '重新加载'
|
|
428
|
-
}
|
|
429
|
-
];
|
|
430
|
-
this.loading = false;
|
|
431
|
-
this.count = 0;
|
|
432
|
-
this.subs = [];
|
|
433
|
-
}
|
|
434
|
-
ngOnInit() {
|
|
435
|
-
this.loadData();
|
|
436
|
-
}
|
|
437
|
-
loadData() {
|
|
438
|
-
this.count = 0;
|
|
439
|
-
this.loading = true;
|
|
440
|
-
this.subs.push(forkJoin(this.loadTodo(), this.loadMessage()).subscribe(() => {
|
|
441
|
-
this.loading = false;
|
|
442
|
-
this.cdr.detectChanges();
|
|
443
|
-
}));
|
|
444
|
-
}
|
|
445
|
-
loadMessage() {
|
|
446
|
-
log('notify.component: ', 'fetch message list');
|
|
447
|
-
const formatMessageStatus = (status) => {
|
|
448
|
-
switch (status) {
|
|
449
|
-
case '0':
|
|
450
|
-
return { extra: '未读', color: 'red' };
|
|
451
|
-
case '1':
|
|
452
|
-
return { extra: '已读', color: 'green' };
|
|
453
|
-
default:
|
|
454
|
-
return { extra: '无状态', color: 'primary' };
|
|
455
|
-
}
|
|
456
|
-
};
|
|
457
|
-
return this.httpClient
|
|
458
|
-
.post(`/message-center-3/my-msg-and-todo/msg-list`, {
|
|
459
|
-
pageNum: 1,
|
|
460
|
-
pageSize: 10,
|
|
461
|
-
status: '0'
|
|
462
|
-
})
|
|
463
|
-
.pipe(map((response) => {
|
|
464
|
-
const viewMessage = this.data.filter(d => d.key === 'msg')[0];
|
|
465
|
-
viewMessage.list = response.data.list.map((m) => {
|
|
466
|
-
return Object.assign(Object.assign({}, m), { avatar: (m === null || m === void 0 ? void 0 : m.imgUrl) || './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
|
|
467
|
-
});
|
|
468
|
-
this.count += viewMessage.list.length;
|
|
469
|
-
}));
|
|
470
|
-
}
|
|
471
|
-
loadTodo() {
|
|
472
|
-
log('notify.component: ', 'fetch todo list');
|
|
473
|
-
const formatTodoStatus = (status) => {
|
|
474
|
-
switch (status) {
|
|
475
|
-
case '0':
|
|
476
|
-
return { extra: '未开始', color: 'red' };
|
|
477
|
-
case '1':
|
|
478
|
-
return { extra: '已开始', color: 'green' };
|
|
479
|
-
default:
|
|
480
|
-
return { extra: '无状态', color: 'primary' };
|
|
481
|
-
}
|
|
482
|
-
};
|
|
483
|
-
return this.httpClient
|
|
484
|
-
.post(`/message-center-3/my-msg-and-todo/todo-list`, {
|
|
485
|
-
pageNum: 1,
|
|
486
|
-
pageSize: 10,
|
|
487
|
-
status: '0'
|
|
488
|
-
})
|
|
489
|
-
.pipe(map((response) => {
|
|
490
|
-
const viewTodo = this.data.filter(d => d.key === 'todo')[0];
|
|
491
|
-
viewTodo.list = response.data.list.map((t) => {
|
|
492
|
-
return Object.assign(Object.assign({}, t), { avatar: (t === null || t === void 0 ? void 0 : t.imgUrl) || './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
|
|
493
|
-
});
|
|
494
|
-
this.count += viewTodo.list.length;
|
|
495
|
-
}));
|
|
496
|
-
}
|
|
497
|
-
clear(type) {
|
|
498
|
-
const t = this.data.filter(d => d.title === type)[0];
|
|
499
|
-
if (t.key == 'msg' || t.key == 'notice') {
|
|
500
|
-
this.subs.push(this.httpClient.post(`/message-center-3/my-msg-and-todo/msg-clear`, {}).subscribe(_ => {
|
|
501
|
-
this.msg.success(`清空了 ${type}`);
|
|
502
|
-
this.loadData();
|
|
503
|
-
}));
|
|
504
|
-
}
|
|
505
|
-
if (t.key == 'todo') {
|
|
506
|
-
this.loadData();
|
|
507
|
-
}
|
|
508
|
-
}
|
|
509
|
-
select(res) {
|
|
510
|
-
this.injector.get(WINDOW).open(res.item.url);
|
|
511
|
-
this.loadData();
|
|
512
|
-
}
|
|
513
|
-
ngOnDestroy() {
|
|
514
|
-
this.subs.forEach(a => a.unsubscribe());
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
YzHeaderNotifyComponent.decorators = [
|
|
518
|
-
{ type: Component, args: [{
|
|
519
|
-
selector: 'yz-header-notify',
|
|
397
|
+
class YzHeaderNotifyComponent {
|
|
398
|
+
constructor(injector, msg, nzI18n, cdr, httpClient) {
|
|
399
|
+
this.injector = injector;
|
|
400
|
+
this.msg = msg;
|
|
401
|
+
this.nzI18n = nzI18n;
|
|
402
|
+
this.cdr = cdr;
|
|
403
|
+
this.httpClient = httpClient;
|
|
404
|
+
this.data = [
|
|
405
|
+
{
|
|
406
|
+
key: 'msg',
|
|
407
|
+
title: '消息',
|
|
408
|
+
list: [],
|
|
409
|
+
emptyText: '您已读完所有消息',
|
|
410
|
+
emptyImage: './assets/tmp/img/message.svg',
|
|
411
|
+
clearText: '清空消息'
|
|
412
|
+
},
|
|
413
|
+
{
|
|
414
|
+
key: 'todo',
|
|
415
|
+
title: '待办',
|
|
416
|
+
list: [],
|
|
417
|
+
emptyText: '你已完成所有待办',
|
|
418
|
+
emptyImage: './assets/tmp/img/todo.svg',
|
|
419
|
+
clearText: '重新加载'
|
|
420
|
+
},
|
|
421
|
+
{
|
|
422
|
+
key: 'notice',
|
|
423
|
+
title: '通知',
|
|
424
|
+
list: [],
|
|
425
|
+
emptyText: '你已查看所有通知',
|
|
426
|
+
emptyImage: './assets/tmp/img/notice.svg',
|
|
427
|
+
clearText: '重新加载'
|
|
428
|
+
}
|
|
429
|
+
];
|
|
430
|
+
this.loading = false;
|
|
431
|
+
this.count = 0;
|
|
432
|
+
this.subs = [];
|
|
433
|
+
}
|
|
434
|
+
ngOnInit() {
|
|
435
|
+
this.loadData();
|
|
436
|
+
}
|
|
437
|
+
loadData() {
|
|
438
|
+
this.count = 0;
|
|
439
|
+
this.loading = true;
|
|
440
|
+
this.subs.push(forkJoin(this.loadTodo(), this.loadMessage()).subscribe(() => {
|
|
441
|
+
this.loading = false;
|
|
442
|
+
this.cdr.detectChanges();
|
|
443
|
+
}));
|
|
444
|
+
}
|
|
445
|
+
loadMessage() {
|
|
446
|
+
log('notify.component: ', 'fetch message list');
|
|
447
|
+
const formatMessageStatus = (status) => {
|
|
448
|
+
switch (status) {
|
|
449
|
+
case '0':
|
|
450
|
+
return { extra: '未读', color: 'red' };
|
|
451
|
+
case '1':
|
|
452
|
+
return { extra: '已读', color: 'green' };
|
|
453
|
+
default:
|
|
454
|
+
return { extra: '无状态', color: 'primary' };
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
return this.httpClient
|
|
458
|
+
.post(`/message-center-3/my-msg-and-todo/msg-list`, {
|
|
459
|
+
pageNum: 1,
|
|
460
|
+
pageSize: 10,
|
|
461
|
+
status: '0'
|
|
462
|
+
})
|
|
463
|
+
.pipe(map((response) => {
|
|
464
|
+
const viewMessage = this.data.filter(d => d.key === 'msg')[0];
|
|
465
|
+
viewMessage.list = response.data.list.map((m) => {
|
|
466
|
+
return Object.assign(Object.assign({}, m), { avatar: (m === null || m === void 0 ? void 0 : m.imgUrl) || './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
|
|
467
|
+
});
|
|
468
|
+
this.count += viewMessage.list.length;
|
|
469
|
+
}));
|
|
470
|
+
}
|
|
471
|
+
loadTodo() {
|
|
472
|
+
log('notify.component: ', 'fetch todo list');
|
|
473
|
+
const formatTodoStatus = (status) => {
|
|
474
|
+
switch (status) {
|
|
475
|
+
case '0':
|
|
476
|
+
return { extra: '未开始', color: 'red' };
|
|
477
|
+
case '1':
|
|
478
|
+
return { extra: '已开始', color: 'green' };
|
|
479
|
+
default:
|
|
480
|
+
return { extra: '无状态', color: 'primary' };
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
return this.httpClient
|
|
484
|
+
.post(`/message-center-3/my-msg-and-todo/todo-list`, {
|
|
485
|
+
pageNum: 1,
|
|
486
|
+
pageSize: 10,
|
|
487
|
+
status: '0'
|
|
488
|
+
})
|
|
489
|
+
.pipe(map((response) => {
|
|
490
|
+
const viewTodo = this.data.filter(d => d.key === 'todo')[0];
|
|
491
|
+
viewTodo.list = response.data.list.map((t) => {
|
|
492
|
+
return Object.assign(Object.assign({}, t), { avatar: (t === null || t === void 0 ? void 0 : t.imgUrl) || './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
|
|
493
|
+
});
|
|
494
|
+
this.count += viewTodo.list.length;
|
|
495
|
+
}));
|
|
496
|
+
}
|
|
497
|
+
clear(type) {
|
|
498
|
+
const t = this.data.filter(d => d.title === type)[0];
|
|
499
|
+
if (t.key == 'msg' || t.key == 'notice') {
|
|
500
|
+
this.subs.push(this.httpClient.post(`/message-center-3/my-msg-and-todo/msg-clear`, {}).subscribe(_ => {
|
|
501
|
+
this.msg.success(`清空了 ${type}`);
|
|
502
|
+
this.loadData();
|
|
503
|
+
}));
|
|
504
|
+
}
|
|
505
|
+
if (t.key == 'todo') {
|
|
506
|
+
this.loadData();
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
select(res) {
|
|
510
|
+
this.injector.get(WINDOW).open(res.item.url);
|
|
511
|
+
this.loadData();
|
|
512
|
+
}
|
|
513
|
+
ngOnDestroy() {
|
|
514
|
+
this.subs.forEach(a => a.unsubscribe());
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
YzHeaderNotifyComponent.decorators = [
|
|
518
|
+
{ type: Component, args: [{
|
|
519
|
+
selector: 'yz-header-notify',
|
|
520
520
|
template: `
|
|
521
521
|
<notice-icon
|
|
522
522
|
[data]="data"
|
|
@@ -527,99 +527,99 @@ YzHeaderNotifyComponent.decorators = [
|
|
|
527
527
|
(select)="select($event)"
|
|
528
528
|
(clear)="clear($event)"
|
|
529
529
|
></notice-icon>
|
|
530
|
-
`,
|
|
531
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
532
|
-
},] }
|
|
533
|
-
];
|
|
534
|
-
YzHeaderNotifyComponent.ctorParameters = () => [
|
|
535
|
-
{ type: Injector },
|
|
536
|
-
{ type: NzMessageService },
|
|
537
|
-
{ type: NzI18nService },
|
|
538
|
-
{ type: ChangeDetectorRef },
|
|
539
|
-
{ type: _HttpClient }
|
|
530
|
+
`,
|
|
531
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
532
|
+
},] }
|
|
533
|
+
];
|
|
534
|
+
YzHeaderNotifyComponent.ctorParameters = () => [
|
|
535
|
+
{ type: Injector },
|
|
536
|
+
{ type: NzMessageService },
|
|
537
|
+
{ type: NzI18nService },
|
|
538
|
+
{ type: ChangeDetectorRef },
|
|
539
|
+
{ type: _HttpClient }
|
|
540
540
|
];
|
|
541
541
|
|
|
542
|
-
class YzHeaderThemBtnComponent {
|
|
543
|
-
constructor(renderer, configSrv, platform, doc, directionality, KEYS) {
|
|
544
|
-
this.renderer = renderer;
|
|
545
|
-
this.configSrv = configSrv;
|
|
546
|
-
this.platform = platform;
|
|
547
|
-
this.doc = doc;
|
|
548
|
-
this.directionality = directionality;
|
|
549
|
-
this.KEYS = KEYS;
|
|
550
|
-
this.theme = 'default';
|
|
551
|
-
this.types = [
|
|
552
|
-
{ key: 'default', text: 'theme.default', color: '#2163ff' },
|
|
553
|
-
{ key: 'compact', text: 'theme.compact', color: '#2163ff' },
|
|
554
|
-
{ key: 'dark', text: 'theme.dark', color: '#020202' },
|
|
555
|
-
{ key: 'yuhong', text: 'theme.yuhong', color: '#C04851' },
|
|
556
|
-
{ key: 'danjuhuang', text: 'theme.danjuhuang', color: '#FBA414' },
|
|
557
|
-
{ key: 'xinghuang', text: 'theme.xinghuang', color: '#F28E16' },
|
|
558
|
-
{ key: 'shilv', text: 'theme.shilv', color: '#57C3C2' },
|
|
559
|
-
{ key: 'zhulv', text: 'theme.zhulv', color: '#1BA784' },
|
|
560
|
-
{ key: 'youlan', text: 'theme.youlan', color: '#1781B5' },
|
|
561
|
-
{ key: 'dianqing', text: 'theme.dianqing', color: '#1661AB' },
|
|
562
|
-
{ key: 'shangengzi', text: 'theme.shangengzi', color: '#61649F' },
|
|
563
|
-
{ key: 'shuiniuhui', text: 'theme.shuiniuhui', color: '#2F2F35' }
|
|
564
|
-
];
|
|
565
|
-
this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
|
|
566
|
-
this.deployUrl = '';
|
|
567
|
-
this.destroy$ = new Subject();
|
|
568
|
-
this.dir = 'ltr';
|
|
569
|
-
}
|
|
570
|
-
ngOnInit() {
|
|
571
|
-
var _a;
|
|
572
|
-
this.dir = this.directionality.value;
|
|
573
|
-
(_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
|
|
574
|
-
this.dir = direction;
|
|
575
|
-
});
|
|
576
|
-
this.initTheme();
|
|
577
|
-
}
|
|
578
|
-
initTheme() {
|
|
579
|
-
if (!this.platform.isBrowser) {
|
|
580
|
-
return;
|
|
581
|
-
}
|
|
582
|
-
this.theme = localStorage.getItem(this.KEYS) || 'default';
|
|
583
|
-
this.updateChartTheme();
|
|
584
|
-
this.onThemeChange(this.theme);
|
|
585
|
-
}
|
|
586
|
-
updateChartTheme() {
|
|
587
|
-
this.configSrv.set('chart', { theme: this.theme === 'dark' ? 'dark' : '' });
|
|
588
|
-
}
|
|
589
|
-
onThemeChange(theme) {
|
|
590
|
-
if (!this.platform.isBrowser) {
|
|
591
|
-
return;
|
|
592
|
-
}
|
|
593
|
-
this.theme = theme;
|
|
594
|
-
this.renderer.setAttribute(this.doc.body, 'data-theme', theme);
|
|
595
|
-
const dom = this.doc.getElementById(this.KEYS);
|
|
596
|
-
if (dom) {
|
|
597
|
-
dom.remove();
|
|
598
|
-
}
|
|
599
|
-
localStorage.removeItem(this.KEYS);
|
|
600
|
-
if (theme !== 'default') {
|
|
601
|
-
const el = this.doc.createElement('link');
|
|
602
|
-
el.type = 'text/css';
|
|
603
|
-
el.rel = 'stylesheet';
|
|
604
|
-
el.id = this.KEYS;
|
|
605
|
-
el.href = `${this.deployUrl}assets/style.${theme}.css`;
|
|
606
|
-
localStorage.setItem(this.KEYS, theme);
|
|
607
|
-
this.doc.body.append(el);
|
|
608
|
-
}
|
|
609
|
-
this.updateChartTheme();
|
|
610
|
-
}
|
|
611
|
-
ngOnDestroy() {
|
|
612
|
-
const el = this.doc.getElementById(this.KEYS);
|
|
613
|
-
if (el != null) {
|
|
614
|
-
this.doc.body.removeChild(el);
|
|
615
|
-
}
|
|
616
|
-
this.destroy$.next();
|
|
617
|
-
this.destroy$.complete();
|
|
618
|
-
}
|
|
619
|
-
}
|
|
620
|
-
YzHeaderThemBtnComponent.decorators = [
|
|
621
|
-
{ type: Component, args: [{
|
|
622
|
-
selector: 'yz-header-theme-btn',
|
|
542
|
+
class YzHeaderThemBtnComponent {
|
|
543
|
+
constructor(renderer, configSrv, platform, doc, directionality, KEYS) {
|
|
544
|
+
this.renderer = renderer;
|
|
545
|
+
this.configSrv = configSrv;
|
|
546
|
+
this.platform = platform;
|
|
547
|
+
this.doc = doc;
|
|
548
|
+
this.directionality = directionality;
|
|
549
|
+
this.KEYS = KEYS;
|
|
550
|
+
this.theme = 'default';
|
|
551
|
+
this.types = [
|
|
552
|
+
{ key: 'default', text: 'theme.default', color: '#2163ff' },
|
|
553
|
+
{ key: 'compact', text: 'theme.compact', color: '#2163ff' },
|
|
554
|
+
{ key: 'dark', text: 'theme.dark', color: '#020202' },
|
|
555
|
+
{ key: 'yuhong', text: 'theme.yuhong', color: '#C04851' },
|
|
556
|
+
{ key: 'danjuhuang', text: 'theme.danjuhuang', color: '#FBA414' },
|
|
557
|
+
{ key: 'xinghuang', text: 'theme.xinghuang', color: '#F28E16' },
|
|
558
|
+
{ key: 'shilv', text: 'theme.shilv', color: '#57C3C2' },
|
|
559
|
+
{ key: 'zhulv', text: 'theme.zhulv', color: '#1BA784' },
|
|
560
|
+
{ key: 'youlan', text: 'theme.youlan', color: '#1781B5' },
|
|
561
|
+
{ key: 'dianqing', text: 'theme.dianqing', color: '#1661AB' },
|
|
562
|
+
{ key: 'shangengzi', text: 'theme.shangengzi', color: '#61649F' },
|
|
563
|
+
{ key: 'shuiniuhui', text: 'theme.shuiniuhui', color: '#2F2F35' }
|
|
564
|
+
];
|
|
565
|
+
this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
|
|
566
|
+
this.deployUrl = '';
|
|
567
|
+
this.destroy$ = new Subject();
|
|
568
|
+
this.dir = 'ltr';
|
|
569
|
+
}
|
|
570
|
+
ngOnInit() {
|
|
571
|
+
var _a;
|
|
572
|
+
this.dir = this.directionality.value;
|
|
573
|
+
(_a = this.directionality.change) === null || _a === void 0 ? void 0 : _a.pipe(takeUntil(this.destroy$)).subscribe((direction) => {
|
|
574
|
+
this.dir = direction;
|
|
575
|
+
});
|
|
576
|
+
this.initTheme();
|
|
577
|
+
}
|
|
578
|
+
initTheme() {
|
|
579
|
+
if (!this.platform.isBrowser) {
|
|
580
|
+
return;
|
|
581
|
+
}
|
|
582
|
+
this.theme = localStorage.getItem(this.KEYS) || 'default';
|
|
583
|
+
this.updateChartTheme();
|
|
584
|
+
this.onThemeChange(this.theme);
|
|
585
|
+
}
|
|
586
|
+
updateChartTheme() {
|
|
587
|
+
this.configSrv.set('chart', { theme: this.theme === 'dark' ? 'dark' : '' });
|
|
588
|
+
}
|
|
589
|
+
onThemeChange(theme) {
|
|
590
|
+
if (!this.platform.isBrowser) {
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
593
|
+
this.theme = theme;
|
|
594
|
+
this.renderer.setAttribute(this.doc.body, 'data-theme', theme);
|
|
595
|
+
const dom = this.doc.getElementById(this.KEYS);
|
|
596
|
+
if (dom) {
|
|
597
|
+
dom.remove();
|
|
598
|
+
}
|
|
599
|
+
localStorage.removeItem(this.KEYS);
|
|
600
|
+
if (theme !== 'default') {
|
|
601
|
+
const el = this.doc.createElement('link');
|
|
602
|
+
el.type = 'text/css';
|
|
603
|
+
el.rel = 'stylesheet';
|
|
604
|
+
el.id = this.KEYS;
|
|
605
|
+
el.href = `${this.deployUrl}assets/style.${theme}.css`;
|
|
606
|
+
localStorage.setItem(this.KEYS, theme);
|
|
607
|
+
this.doc.body.append(el);
|
|
608
|
+
}
|
|
609
|
+
this.updateChartTheme();
|
|
610
|
+
}
|
|
611
|
+
ngOnDestroy() {
|
|
612
|
+
const el = this.doc.getElementById(this.KEYS);
|
|
613
|
+
if (el != null) {
|
|
614
|
+
this.doc.body.removeChild(el);
|
|
615
|
+
}
|
|
616
|
+
this.destroy$.next();
|
|
617
|
+
this.destroy$.complete();
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
YzHeaderThemBtnComponent.decorators = [
|
|
621
|
+
{ type: Component, args: [{
|
|
622
|
+
selector: 'yz-header-theme-btn',
|
|
623
623
|
template: `
|
|
624
624
|
<div
|
|
625
625
|
class="yunzai-default__nav-item"
|
|
@@ -659,75 +659,75 @@ YzHeaderThemBtnComponent.decorators = [
|
|
|
659
659
|
<!-- </div>-->
|
|
660
660
|
<!-- </div>-->
|
|
661
661
|
</nz-dropdown-menu>
|
|
662
|
-
`,
|
|
663
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
664
|
-
},] }
|
|
665
|
-
];
|
|
666
|
-
YzHeaderThemBtnComponent.ctorParameters = () => [
|
|
667
|
-
{ type: Renderer2 },
|
|
668
|
-
{ type: YunzaiConfigService },
|
|
669
|
-
{ type: Platform },
|
|
670
|
-
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
671
|
-
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
672
|
-
{ type: String, decorators: [{ type: Inject, args: [YUNZAI_THEME_BTN_KEYS,] }] }
|
|
673
|
-
];
|
|
674
|
-
YzHeaderThemBtnComponent.propDecorators = {
|
|
675
|
-
types: [{ type: Input }],
|
|
676
|
-
devTips: [{ type: Input }],
|
|
677
|
-
deployUrl: [{ type: Input }]
|
|
662
|
+
`,
|
|
663
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
664
|
+
},] }
|
|
665
|
+
];
|
|
666
|
+
YzHeaderThemBtnComponent.ctorParameters = () => [
|
|
667
|
+
{ type: Renderer2 },
|
|
668
|
+
{ type: YunzaiConfigService },
|
|
669
|
+
{ type: Platform },
|
|
670
|
+
{ type: undefined, decorators: [{ type: Inject, args: [DOCUMENT,] }] },
|
|
671
|
+
{ type: Directionality, decorators: [{ type: Optional }] },
|
|
672
|
+
{ type: String, decorators: [{ type: Inject, args: [YUNZAI_THEME_BTN_KEYS,] }] }
|
|
673
|
+
];
|
|
674
|
+
YzHeaderThemBtnComponent.propDecorators = {
|
|
675
|
+
types: [{ type: Input }],
|
|
676
|
+
devTips: [{ type: Input }],
|
|
677
|
+
deployUrl: [{ type: Input }]
|
|
678
678
|
};
|
|
679
679
|
|
|
680
|
-
const BUSINESS_DEFAULT_CONFIG = {
|
|
681
|
-
baseUrl: '/backstage',
|
|
682
|
-
systemCode: 'portal',
|
|
683
|
-
loginForm: null,
|
|
684
|
-
refreshTokenEnabled: true,
|
|
685
|
-
refreshTokenType: 're-request'
|
|
686
|
-
};
|
|
687
|
-
function mergeBisConfig(srv) {
|
|
688
|
-
return srv.merge('bis', BUSINESS_DEFAULT_CONFIG);
|
|
680
|
+
const BUSINESS_DEFAULT_CONFIG = {
|
|
681
|
+
baseUrl: '/backstage',
|
|
682
|
+
systemCode: 'portal',
|
|
683
|
+
loginForm: null,
|
|
684
|
+
refreshTokenEnabled: true,
|
|
685
|
+
refreshTokenType: 're-request'
|
|
686
|
+
};
|
|
687
|
+
function mergeBisConfig(srv) {
|
|
688
|
+
return srv.merge('bis', BUSINESS_DEFAULT_CONFIG);
|
|
689
689
|
}
|
|
690
690
|
|
|
691
|
-
class YzHeaderUserComponent {
|
|
692
|
-
constructor(injector, msg, tokenService,
|
|
693
|
-
// @ts-ignore
|
|
694
|
-
configService, cacheService) {
|
|
695
|
-
this.injector = injector;
|
|
696
|
-
this.msg = msg;
|
|
697
|
-
this.tokenService = tokenService;
|
|
698
|
-
this.configService = configService;
|
|
699
|
-
this.cacheService = cacheService;
|
|
700
|
-
this.icon = '';
|
|
701
|
-
this.username = '';
|
|
702
|
-
this.menus = [];
|
|
703
|
-
this.config = mergeBisConfig(configService);
|
|
704
|
-
}
|
|
705
|
-
ngOnInit() {
|
|
706
|
-
const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
|
|
707
|
-
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
708
|
-
this.username = user.realname ? user.realname : '未命名';
|
|
709
|
-
this.icon = user.avatarId
|
|
710
|
-
? `${this.config.baseUrl}/filecenter/file/${user.avatarId}`
|
|
711
|
-
: `./assets/tmp/img/avatar.jpg`;
|
|
712
|
-
this.menus = projectInfo.profileList;
|
|
713
|
-
}
|
|
714
|
-
logout() {
|
|
715
|
-
localStorage.clear();
|
|
716
|
-
this.tokenService.clear();
|
|
717
|
-
this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
|
|
718
|
-
}
|
|
719
|
-
to(href) {
|
|
720
|
-
if (href) {
|
|
721
|
-
this.injector.get(WINDOW).open(href);
|
|
722
|
-
}
|
|
723
|
-
else {
|
|
724
|
-
this.msg.error('该菜单没有配置链接!');
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
}
|
|
728
|
-
YzHeaderUserComponent.decorators = [
|
|
729
|
-
{ type: Component, args: [{
|
|
730
|
-
selector: 'yz-header-user',
|
|
691
|
+
class YzHeaderUserComponent {
|
|
692
|
+
constructor(injector, msg, tokenService,
|
|
693
|
+
// @ts-ignore
|
|
694
|
+
configService, cacheService) {
|
|
695
|
+
this.injector = injector;
|
|
696
|
+
this.msg = msg;
|
|
697
|
+
this.tokenService = tokenService;
|
|
698
|
+
this.configService = configService;
|
|
699
|
+
this.cacheService = cacheService;
|
|
700
|
+
this.icon = '';
|
|
701
|
+
this.username = '';
|
|
702
|
+
this.menus = [];
|
|
703
|
+
this.config = mergeBisConfig(configService);
|
|
704
|
+
}
|
|
705
|
+
ngOnInit() {
|
|
706
|
+
const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
|
|
707
|
+
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
708
|
+
this.username = user.realname ? user.realname : '未命名';
|
|
709
|
+
this.icon = user.avatarId
|
|
710
|
+
? `${this.config.baseUrl}/filecenter/file/${user.avatarId}`
|
|
711
|
+
: `./assets/tmp/img/avatar.jpg`;
|
|
712
|
+
this.menus = projectInfo.profileList;
|
|
713
|
+
}
|
|
714
|
+
logout() {
|
|
715
|
+
localStorage.clear();
|
|
716
|
+
this.tokenService.clear();
|
|
717
|
+
this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
|
|
718
|
+
}
|
|
719
|
+
to(href) {
|
|
720
|
+
if (href) {
|
|
721
|
+
this.injector.get(WINDOW).open(href);
|
|
722
|
+
}
|
|
723
|
+
else {
|
|
724
|
+
this.msg.error('该菜单没有配置链接!');
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
YzHeaderUserComponent.decorators = [
|
|
729
|
+
{ type: Component, args: [{
|
|
730
|
+
selector: 'yz-header-user',
|
|
731
731
|
template: `
|
|
732
732
|
<div
|
|
733
733
|
class="yunzai-default__nav-item d-flex align-items-center px-sm"
|
|
@@ -751,214 +751,214 @@ YzHeaderUserComponent.decorators = [
|
|
|
751
751
|
</div>
|
|
752
752
|
</div>
|
|
753
753
|
</nz-dropdown-menu>
|
|
754
|
-
`,
|
|
755
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
756
|
-
},] }
|
|
757
|
-
];
|
|
758
|
-
YzHeaderUserComponent.ctorParameters = () => [
|
|
759
|
-
{ type: Injector },
|
|
760
|
-
{ type: NzMessageService },
|
|
761
|
-
{ type: undefined, decorators: [{ type: Inject, args: [YA_SERVICE_TOKEN,] }] },
|
|
762
|
-
{ type: YunzaiConfigService$1 },
|
|
763
|
-
{ type: CacheService }
|
|
754
|
+
`,
|
|
755
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
756
|
+
},] }
|
|
757
|
+
];
|
|
758
|
+
YzHeaderUserComponent.ctorParameters = () => [
|
|
759
|
+
{ type: Injector },
|
|
760
|
+
{ type: NzMessageService },
|
|
761
|
+
{ type: undefined, decorators: [{ type: Inject, args: [YA_SERVICE_TOKEN,] }] },
|
|
762
|
+
{ type: YunzaiConfigService$1 },
|
|
763
|
+
{ type: CacheService }
|
|
764
764
|
];
|
|
765
765
|
|
|
766
|
-
class YzHeaderClearStorageComponent {
|
|
767
|
-
constructor(modalSrv, messageSrv) {
|
|
768
|
-
this.modalSrv = modalSrv;
|
|
769
|
-
this.messageSrv = messageSrv;
|
|
770
|
-
}
|
|
771
|
-
_click() {
|
|
772
|
-
this.modalSrv.confirm({
|
|
773
|
-
nzTitle: 'Make sure clear all local storage?',
|
|
774
|
-
nzOnOk: () => {
|
|
775
|
-
localStorage.clear();
|
|
776
|
-
this.messageSrv.success('Clear Finished!');
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
YzHeaderClearStorageComponent.decorators = [
|
|
782
|
-
{ type: Component, args: [{
|
|
783
|
-
selector: 'yz-header-clear-storage',
|
|
766
|
+
class YzHeaderClearStorageComponent {
|
|
767
|
+
constructor(modalSrv, messageSrv) {
|
|
768
|
+
this.modalSrv = modalSrv;
|
|
769
|
+
this.messageSrv = messageSrv;
|
|
770
|
+
}
|
|
771
|
+
_click() {
|
|
772
|
+
this.modalSrv.confirm({
|
|
773
|
+
nzTitle: 'Make sure clear all local storage?',
|
|
774
|
+
nzOnOk: () => {
|
|
775
|
+
localStorage.clear();
|
|
776
|
+
this.messageSrv.success('Clear Finished!');
|
|
777
|
+
}
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
YzHeaderClearStorageComponent.decorators = [
|
|
782
|
+
{ type: Component, args: [{
|
|
783
|
+
selector: 'yz-header-clear-storage',
|
|
784
784
|
template: `
|
|
785
785
|
<i nz-icon nzType="tool"></i>
|
|
786
786
|
{{ 'menu.clear.local.storage' | i18n }}
|
|
787
|
-
`,
|
|
788
|
-
host: {
|
|
789
|
-
'[class.d-block]': 'true'
|
|
790
|
-
},
|
|
791
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
792
|
-
},] }
|
|
793
|
-
];
|
|
794
|
-
YzHeaderClearStorageComponent.ctorParameters = () => [
|
|
795
|
-
{ type: NzModalService },
|
|
796
|
-
{ type: NzMessageService }
|
|
797
|
-
];
|
|
798
|
-
YzHeaderClearStorageComponent.propDecorators = {
|
|
799
|
-
_click: [{ type: HostListener, args: ['click',] }]
|
|
787
|
+
`,
|
|
788
|
+
host: {
|
|
789
|
+
'[class.d-block]': 'true'
|
|
790
|
+
},
|
|
791
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
792
|
+
},] }
|
|
793
|
+
];
|
|
794
|
+
YzHeaderClearStorageComponent.ctorParameters = () => [
|
|
795
|
+
{ type: NzModalService },
|
|
796
|
+
{ type: NzMessageService }
|
|
797
|
+
];
|
|
798
|
+
YzHeaderClearStorageComponent.propDecorators = {
|
|
799
|
+
_click: [{ type: HostListener, args: ['click',] }]
|
|
800
800
|
};
|
|
801
801
|
|
|
802
|
-
class YzHeaderFullScreenComponent {
|
|
803
|
-
constructor() {
|
|
804
|
-
this.status = false;
|
|
805
|
-
}
|
|
806
|
-
get sf() {
|
|
807
|
-
return screenfull;
|
|
808
|
-
}
|
|
809
|
-
_resize() {
|
|
810
|
-
this.status = this.sf.isFullscreen;
|
|
811
|
-
}
|
|
812
|
-
_click() {
|
|
813
|
-
if (this.sf.isEnabled) {
|
|
814
|
-
this.sf.toggle();
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
YzHeaderFullScreenComponent.decorators = [
|
|
819
|
-
{ type: Component, args: [{
|
|
820
|
-
selector: 'yz-header-fullscreen',
|
|
802
|
+
class YzHeaderFullScreenComponent {
|
|
803
|
+
constructor() {
|
|
804
|
+
this.status = false;
|
|
805
|
+
}
|
|
806
|
+
get sf() {
|
|
807
|
+
return screenfull;
|
|
808
|
+
}
|
|
809
|
+
_resize() {
|
|
810
|
+
this.status = this.sf.isFullscreen;
|
|
811
|
+
}
|
|
812
|
+
_click() {
|
|
813
|
+
if (this.sf.isEnabled) {
|
|
814
|
+
this.sf.toggle();
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
YzHeaderFullScreenComponent.decorators = [
|
|
819
|
+
{ type: Component, args: [{
|
|
820
|
+
selector: 'yz-header-fullscreen',
|
|
821
821
|
template: `
|
|
822
822
|
<i nz-icon [nzType]="status ? 'fullscreen-exit' : 'fullscreen'"></i>
|
|
823
823
|
{{ (status ? 'menu.fullscreen.exit' : 'menu.fullscreen') | i18n }}
|
|
824
|
-
`,
|
|
825
|
-
host: {
|
|
826
|
-
'[class.d-block]': 'true'
|
|
827
|
-
},
|
|
828
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
829
|
-
},] }
|
|
830
|
-
];
|
|
831
|
-
YzHeaderFullScreenComponent.propDecorators = {
|
|
832
|
-
_resize: [{ type: HostListener, args: ['window:resize',] }],
|
|
833
|
-
_click: [{ type: HostListener, args: ['click',] }]
|
|
824
|
+
`,
|
|
825
|
+
host: {
|
|
826
|
+
'[class.d-block]': 'true'
|
|
827
|
+
},
|
|
828
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
829
|
+
},] }
|
|
830
|
+
];
|
|
831
|
+
YzHeaderFullScreenComponent.propDecorators = {
|
|
832
|
+
_resize: [{ type: HostListener, args: ['window:resize',] }],
|
|
833
|
+
_click: [{ type: HostListener, args: ['click',] }]
|
|
834
834
|
};
|
|
835
835
|
|
|
836
|
-
const ɵ0 = msg => {
|
|
837
|
-
log$1(msg);
|
|
838
|
-
};
|
|
839
|
-
const STOMP_DEFAULT_CONFIG = {
|
|
840
|
-
connectHeaders: {
|
|
841
|
-
login: 'guest',
|
|
842
|
-
passcode: 'guest'
|
|
843
|
-
},
|
|
844
|
-
brokerURL: '/websocket/ws/',
|
|
845
|
-
heartbeatIncoming: 1000 * 60,
|
|
846
|
-
heartbeatOutgoing: 1000 * 60,
|
|
847
|
-
reconnectDelay: 30000000,
|
|
848
|
-
debug: ɵ0
|
|
849
|
-
};
|
|
850
|
-
function mergeStompConfig(srv) {
|
|
851
|
-
return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
|
|
836
|
+
const ɵ0 = msg => {
|
|
837
|
+
log$1(msg);
|
|
838
|
+
};
|
|
839
|
+
const STOMP_DEFAULT_CONFIG = {
|
|
840
|
+
connectHeaders: {
|
|
841
|
+
login: 'guest',
|
|
842
|
+
passcode: 'guest'
|
|
843
|
+
},
|
|
844
|
+
brokerURL: '/websocket/ws/',
|
|
845
|
+
heartbeatIncoming: 1000 * 60,
|
|
846
|
+
heartbeatOutgoing: 1000 * 60,
|
|
847
|
+
reconnectDelay: 30000000,
|
|
848
|
+
debug: ɵ0
|
|
849
|
+
};
|
|
850
|
+
function mergeStompConfig(srv) {
|
|
851
|
+
return srv.merge('stomp', STOMP_DEFAULT_CONFIG);
|
|
852
852
|
}
|
|
853
853
|
|
|
854
|
-
class YzStompService {
|
|
855
|
-
constructor(csr, cache, injector, notification) {
|
|
856
|
-
this.csr = csr;
|
|
857
|
-
this.cache = cache;
|
|
858
|
-
this.injector = injector;
|
|
859
|
-
this.notification = notification;
|
|
860
|
-
this.subs = [];
|
|
861
|
-
if (!this.user) {
|
|
862
|
-
this.user = this.cache.get('_yz_user', { mode: 'none' });
|
|
863
|
-
}
|
|
864
|
-
if (!this.config) {
|
|
865
|
-
this.config = mergeStompConfig(this.csr);
|
|
866
|
-
}
|
|
867
|
-
if (!this.bisConfig) {
|
|
868
|
-
this.bisConfig = mergeBisConfig(csr);
|
|
869
|
-
}
|
|
870
|
-
if (!this.rxStomp) {
|
|
871
|
-
this.rxStomp = new RxStomp();
|
|
872
|
-
if (isDevMode()) {
|
|
873
|
-
log$1('yz.stomp.service: is dev mode');
|
|
874
|
-
log$1('yz.stomp.service: ', `config is ${this.config}`);
|
|
875
|
-
this.rxStomp.configure(this.config);
|
|
876
|
-
return;
|
|
877
|
-
}
|
|
878
|
-
const { location } = this.injector.get(DOCUMENT);
|
|
879
|
-
const { protocol, host } = location;
|
|
880
|
-
log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
|
|
881
|
-
if (protocol.includes('http') && !protocol.includes('https')) {
|
|
882
|
-
this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
|
|
883
|
-
}
|
|
884
|
-
if (protocol.includes('https')) {
|
|
885
|
-
this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
|
|
886
|
-
}
|
|
887
|
-
log$1('yz.stomp.service: ', `config is ${this.config}`);
|
|
888
|
-
this.rxStomp.configure(this.config);
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
listen() {
|
|
892
|
-
this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
|
|
893
|
-
this.createNotification(JSON.parse(message.body));
|
|
894
|
-
}));
|
|
895
|
-
this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
|
|
896
|
-
this.logoutNotification(JSON.parse(message.body));
|
|
897
|
-
}));
|
|
898
|
-
this.rxStomp.activate();
|
|
899
|
-
}
|
|
900
|
-
createNotification(message) {
|
|
901
|
-
this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
|
|
902
|
-
}
|
|
903
|
-
logoutNotification(message) {
|
|
904
|
-
this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
|
|
905
|
-
setTimeout(() => {
|
|
906
|
-
this.cache.clear();
|
|
907
|
-
localStorage.clear();
|
|
908
|
-
this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
|
|
909
|
-
}, 5000);
|
|
910
|
-
}
|
|
911
|
-
unListen() {
|
|
912
|
-
this.subs.forEach(s => s.unsubscribe());
|
|
913
|
-
this.rxStomp.deactivate().then();
|
|
914
|
-
}
|
|
915
|
-
publish(parameters) {
|
|
916
|
-
this.rxStomp.publish(parameters);
|
|
917
|
-
}
|
|
918
|
-
watch(destination, headers) {
|
|
919
|
-
return this.rxStomp.watch(destination, headers);
|
|
920
|
-
}
|
|
921
|
-
}
|
|
922
|
-
YzStompService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzStompService_Factory() { return new YzStompService(i0.ɵɵinject(i4.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i3$1.NzNotificationService)); }, token: YzStompService, providedIn: "root" });
|
|
923
|
-
YzStompService.decorators = [
|
|
924
|
-
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
925
|
-
];
|
|
926
|
-
YzStompService.ctorParameters = () => [
|
|
927
|
-
{ type: YunzaiConfigService$1 },
|
|
928
|
-
{ type: CacheService },
|
|
929
|
-
{ type: Injector },
|
|
930
|
-
{ type: NzNotificationService }
|
|
854
|
+
class YzStompService {
|
|
855
|
+
constructor(csr, cache, injector, notification) {
|
|
856
|
+
this.csr = csr;
|
|
857
|
+
this.cache = cache;
|
|
858
|
+
this.injector = injector;
|
|
859
|
+
this.notification = notification;
|
|
860
|
+
this.subs = [];
|
|
861
|
+
if (!this.user) {
|
|
862
|
+
this.user = this.cache.get('_yz_user', { mode: 'none' });
|
|
863
|
+
}
|
|
864
|
+
if (!this.config) {
|
|
865
|
+
this.config = mergeStompConfig(this.csr);
|
|
866
|
+
}
|
|
867
|
+
if (!this.bisConfig) {
|
|
868
|
+
this.bisConfig = mergeBisConfig(csr);
|
|
869
|
+
}
|
|
870
|
+
if (!this.rxStomp) {
|
|
871
|
+
this.rxStomp = new RxStomp();
|
|
872
|
+
if (isDevMode()) {
|
|
873
|
+
log$1('yz.stomp.service: is dev mode');
|
|
874
|
+
log$1('yz.stomp.service: ', `config is ${this.config}`);
|
|
875
|
+
this.rxStomp.configure(this.config);
|
|
876
|
+
return;
|
|
877
|
+
}
|
|
878
|
+
const { location } = this.injector.get(DOCUMENT);
|
|
879
|
+
const { protocol, host } = location;
|
|
880
|
+
log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
|
|
881
|
+
if (protocol.includes('http') && !protocol.includes('https')) {
|
|
882
|
+
this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
|
|
883
|
+
}
|
|
884
|
+
if (protocol.includes('https')) {
|
|
885
|
+
this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
|
|
886
|
+
}
|
|
887
|
+
log$1('yz.stomp.service: ', `config is ${this.config}`);
|
|
888
|
+
this.rxStomp.configure(this.config);
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
listen() {
|
|
892
|
+
this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
|
|
893
|
+
this.createNotification(JSON.parse(message.body));
|
|
894
|
+
}));
|
|
895
|
+
this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
|
|
896
|
+
this.logoutNotification(JSON.parse(message.body));
|
|
897
|
+
}));
|
|
898
|
+
this.rxStomp.activate();
|
|
899
|
+
}
|
|
900
|
+
createNotification(message) {
|
|
901
|
+
this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
|
|
902
|
+
}
|
|
903
|
+
logoutNotification(message) {
|
|
904
|
+
this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
|
|
905
|
+
setTimeout(() => {
|
|
906
|
+
this.cache.clear();
|
|
907
|
+
localStorage.clear();
|
|
908
|
+
this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
|
|
909
|
+
}, 5000);
|
|
910
|
+
}
|
|
911
|
+
unListen() {
|
|
912
|
+
this.subs.forEach(s => s.unsubscribe());
|
|
913
|
+
this.rxStomp.deactivate().then();
|
|
914
|
+
}
|
|
915
|
+
publish(parameters) {
|
|
916
|
+
this.rxStomp.publish(parameters);
|
|
917
|
+
}
|
|
918
|
+
watch(destination, headers) {
|
|
919
|
+
return this.rxStomp.watch(destination, headers);
|
|
920
|
+
}
|
|
921
|
+
}
|
|
922
|
+
YzStompService.ɵprov = i0.ɵɵdefineInjectable({ factory: function YzStompService_Factory() { return new YzStompService(i0.ɵɵinject(i4.YunzaiConfigService), i0.ɵɵinject(i2$1.CacheService), i0.ɵɵinject(i0.INJECTOR), i0.ɵɵinject(i3$1.NzNotificationService)); }, token: YzStompService, providedIn: "root" });
|
|
923
|
+
YzStompService.decorators = [
|
|
924
|
+
{ type: Injectable, args: [{ providedIn: 'root' },] }
|
|
925
|
+
];
|
|
926
|
+
YzStompService.ctorParameters = () => [
|
|
927
|
+
{ type: YunzaiConfigService$1 },
|
|
928
|
+
{ type: CacheService },
|
|
929
|
+
{ type: Injector },
|
|
930
|
+
{ type: NzNotificationService }
|
|
931
931
|
];
|
|
932
932
|
|
|
933
|
-
class YzLayoutBasicComponent {
|
|
934
|
-
constructor(cacheService, yzStompService) {
|
|
935
|
-
this.cacheService = cacheService;
|
|
936
|
-
this.yzStompService = yzStompService;
|
|
937
|
-
this.options = {
|
|
938
|
-
logoExpanded: `./assets/logo-full.svg`,
|
|
939
|
-
logoCollapsed: `./assets/logo.svg`
|
|
940
|
-
};
|
|
941
|
-
this.intro = '';
|
|
942
|
-
this.text = '';
|
|
943
|
-
this.icon = '';
|
|
944
|
-
}
|
|
945
|
-
ngOnInit() {
|
|
946
|
-
const current = this.cacheService.get('_yz_current', { mode: 'none' });
|
|
947
|
-
const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
|
|
948
|
-
this.text = current.text ? current.text : '应用名称';
|
|
949
|
-
this.intro = current.intro ? current.intro : '应用描述';
|
|
950
|
-
this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
|
|
951
|
-
this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
|
|
952
|
-
this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
|
|
953
|
-
this.yzStompService.listen();
|
|
954
|
-
}
|
|
955
|
-
ngOnDestroy() {
|
|
956
|
-
this.yzStompService.unListen();
|
|
957
|
-
}
|
|
958
|
-
}
|
|
959
|
-
YzLayoutBasicComponent.decorators = [
|
|
960
|
-
{ type: Component, args: [{
|
|
961
|
-
selector: 'yz-layout-basic',
|
|
933
|
+
class YzLayoutBasicComponent {
|
|
934
|
+
constructor(cacheService, yzStompService) {
|
|
935
|
+
this.cacheService = cacheService;
|
|
936
|
+
this.yzStompService = yzStompService;
|
|
937
|
+
this.options = {
|
|
938
|
+
logoExpanded: `./assets/logo-full.svg`,
|
|
939
|
+
logoCollapsed: `./assets/logo.svg`
|
|
940
|
+
};
|
|
941
|
+
this.intro = '';
|
|
942
|
+
this.text = '';
|
|
943
|
+
this.icon = '';
|
|
944
|
+
}
|
|
945
|
+
ngOnInit() {
|
|
946
|
+
const current = this.cacheService.get('_yz_current', { mode: 'none' });
|
|
947
|
+
const project = this.cacheService.get('_yz_project_info', { mode: 'none' });
|
|
948
|
+
this.text = current.text ? current.text : '应用名称';
|
|
949
|
+
this.intro = current.intro ? current.intro : '应用描述';
|
|
950
|
+
this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
|
|
951
|
+
this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
|
|
952
|
+
this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
|
|
953
|
+
this.yzStompService.listen();
|
|
954
|
+
}
|
|
955
|
+
ngOnDestroy() {
|
|
956
|
+
this.yzStompService.unListen();
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
YzLayoutBasicComponent.decorators = [
|
|
960
|
+
{ type: Component, args: [{
|
|
961
|
+
selector: 'yz-layout-basic',
|
|
962
962
|
template: `
|
|
963
963
|
<layout-default [options]="options" [asideUser]="asideUserTpl" [content]="contentTpl">
|
|
964
964
|
<layout-default-header-item direction="left">
|
|
@@ -1019,496 +1019,496 @@ YzLayoutBasicComponent.decorators = [
|
|
|
1019
1019
|
<router-outlet (activate)="reuseTab.activate($event)"></router-outlet>
|
|
1020
1020
|
</ng-template>
|
|
1021
1021
|
</layout-default>
|
|
1022
|
-
`,
|
|
1023
|
-
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1024
|
-
},] }
|
|
1025
|
-
];
|
|
1026
|
-
YzLayoutBasicComponent.ctorParameters = () => [
|
|
1027
|
-
{ type: CacheService },
|
|
1028
|
-
{ type: YzStompService }
|
|
1022
|
+
`,
|
|
1023
|
+
changeDetection: ChangeDetectionStrategy.OnPush
|
|
1024
|
+
},] }
|
|
1025
|
+
];
|
|
1026
|
+
YzLayoutBasicComponent.ctorParameters = () => [
|
|
1027
|
+
{ type: CacheService },
|
|
1028
|
+
{ type: YzStompService }
|
|
1029
1029
|
];
|
|
1030
1030
|
|
|
1031
|
-
const COMPONENTS = [
|
|
1032
|
-
YzLayoutBasicComponent,
|
|
1033
|
-
YzHeaderApplicationComponent,
|
|
1034
|
-
YzHeaderNotifyComponent,
|
|
1035
|
-
YzHeaderThemBtnComponent,
|
|
1036
|
-
YzHeaderUserComponent,
|
|
1037
|
-
YzHeaderFullScreenComponent,
|
|
1038
|
-
YzHeaderClearStorageComponent,
|
|
1039
|
-
YzHeaderI18NComponent
|
|
1040
|
-
];
|
|
1041
|
-
class YunzaiLayoutModule {
|
|
1042
|
-
}
|
|
1043
|
-
YunzaiLayoutModule.decorators = [
|
|
1044
|
-
{ type: NgModule, args: [{
|
|
1045
|
-
imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
|
|
1046
|
-
providers: [
|
|
1047
|
-
{
|
|
1048
|
-
provide: YUNZAI_THEME_BTN_KEYS,
|
|
1049
|
-
useValue: 'site-theme'
|
|
1050
|
-
}
|
|
1051
|
-
],
|
|
1052
|
-
declarations: [...COMPONENTS],
|
|
1053
|
-
exports: [...COMPONENTS]
|
|
1054
|
-
},] }
|
|
1031
|
+
const COMPONENTS = [
|
|
1032
|
+
YzLayoutBasicComponent,
|
|
1033
|
+
YzHeaderApplicationComponent,
|
|
1034
|
+
YzHeaderNotifyComponent,
|
|
1035
|
+
YzHeaderThemBtnComponent,
|
|
1036
|
+
YzHeaderUserComponent,
|
|
1037
|
+
YzHeaderFullScreenComponent,
|
|
1038
|
+
YzHeaderClearStorageComponent,
|
|
1039
|
+
YzHeaderI18NComponent
|
|
1040
|
+
];
|
|
1041
|
+
class YunzaiLayoutModule {
|
|
1042
|
+
}
|
|
1043
|
+
YunzaiLayoutModule.decorators = [
|
|
1044
|
+
{ type: NgModule, args: [{
|
|
1045
|
+
imports: [HttpClientModule, CommonModule, FormsModule, RouterModule, ReactiveFormsModule, YzSharedModule],
|
|
1046
|
+
providers: [
|
|
1047
|
+
{
|
|
1048
|
+
provide: YUNZAI_THEME_BTN_KEYS,
|
|
1049
|
+
useValue: 'site-theme'
|
|
1050
|
+
}
|
|
1051
|
+
],
|
|
1052
|
+
declarations: [...COMPONENTS],
|
|
1053
|
+
exports: [...COMPONENTS]
|
|
1054
|
+
},] }
|
|
1055
1055
|
];
|
|
1056
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 }
|
|
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
1202
|
];
|
|
1203
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.refreshToking = false;
|
|
1228
|
-
this.refreshToken$ = new BehaviorSubject(null);
|
|
1229
|
-
if (this.config.refreshTokenType === 'auth-refresh') {
|
|
1230
|
-
console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
|
|
1231
|
-
}
|
|
1232
|
-
}
|
|
1233
|
-
get notification() {
|
|
1234
|
-
return this.injector.get(NzNotificationService);
|
|
1235
|
-
}
|
|
1236
|
-
get tokenSrv() {
|
|
1237
|
-
return this.injector.get(YA_SERVICE_TOKEN);
|
|
1238
|
-
}
|
|
1239
|
-
get http() {
|
|
1240
|
-
return this.injector.get(_HttpClient);
|
|
1241
|
-
}
|
|
1242
|
-
get config() {
|
|
1243
|
-
return mergeBisConfig(this.injector.get(YunzaiConfigService));
|
|
1244
|
-
}
|
|
1245
|
-
goTo(url) {
|
|
1246
|
-
setTimeout(() => this.injector.get(Router).navigateByUrl(url));
|
|
1247
|
-
}
|
|
1248
|
-
checkStatus(ev) {
|
|
1249
|
-
if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
|
|
1250
|
-
return;
|
|
1251
|
-
}
|
|
1252
|
-
if (ev instanceof HttpResponse && ev.body.errorMessage) {
|
|
1253
|
-
this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
|
|
1254
|
-
return;
|
|
1255
|
-
}
|
|
1256
|
-
const errortext = CODEMESSAGE[ev.status] || ev.statusText;
|
|
1257
|
-
this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
|
|
1258
|
-
}
|
|
1259
|
-
ToLogin() {
|
|
1260
|
-
this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
|
|
1261
|
-
setTimeout(() => {
|
|
1262
|
-
localStorage.clear();
|
|
1263
|
-
this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
|
|
1264
|
-
}, 5000);
|
|
1265
|
-
}
|
|
1266
|
-
reAttachToken(req) {
|
|
1267
|
-
var _a;
|
|
1268
|
-
const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
|
|
1269
|
-
return req.clone({
|
|
1270
|
-
setHeaders: {
|
|
1271
|
-
Authorization: `Bearer ${token}`
|
|
1272
|
-
}
|
|
1273
|
-
});
|
|
1274
|
-
}
|
|
1275
|
-
refreshTokenRequest() {
|
|
1276
|
-
const model = this.tokenSrv.get();
|
|
1277
|
-
const form = new FormData();
|
|
1278
|
-
form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
|
|
1279
|
-
log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
|
|
1280
|
-
return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
|
|
1281
|
-
}
|
|
1282
|
-
tryRefreshToken(ev, req, next) {
|
|
1283
|
-
// 连刷新Token的请求都错了,那就是真错了
|
|
1284
|
-
if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
|
|
1285
|
-
this.ToLogin();
|
|
1286
|
-
return throwError(ev);
|
|
1287
|
-
}
|
|
1288
|
-
// 正在刷新token,所有其他请求排队
|
|
1289
|
-
if (this.refreshToking) {
|
|
1290
|
-
return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
|
|
1291
|
-
}
|
|
1292
|
-
//尝试调用刷新 Token
|
|
1293
|
-
this.refreshToking = true;
|
|
1294
|
-
this.refreshToken$.next(null);
|
|
1295
|
-
// 处理Token
|
|
1296
|
-
return this.refreshTokenRequest().pipe(switchMap(res => {
|
|
1297
|
-
log('yz.default.interceptor: refresh token accessed -> ', res);
|
|
1298
|
-
// 重新保存新 token
|
|
1299
|
-
const { access_token, expires_in, refresh_token, scope, token_type } = res;
|
|
1300
|
-
this.tokenSrv.set({
|
|
1301
|
-
token: access_token,
|
|
1302
|
-
expired: expires_in,
|
|
1303
|
-
refreshToken: refresh_token,
|
|
1304
|
-
tokenType: token_type,
|
|
1305
|
-
scope
|
|
1306
|
-
});
|
|
1307
|
-
// 通知后续请求继续执行
|
|
1308
|
-
this.refreshToking = false;
|
|
1309
|
-
this.refreshToken$.next(res);
|
|
1310
|
-
// 重新发起请求
|
|
1311
|
-
return next.handle(this.reAttachToken(req));
|
|
1312
|
-
}), catchError(err => {
|
|
1313
|
-
this.refreshToking = false;
|
|
1314
|
-
this.ToLogin();
|
|
1315
|
-
return throwError(err);
|
|
1316
|
-
}));
|
|
1317
|
-
}
|
|
1318
|
-
getAdditionalHeaders(headers) {
|
|
1319
|
-
const res = {};
|
|
1320
|
-
const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
|
|
1321
|
-
if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
|
|
1322
|
-
res['Accept-Language'] = lang;
|
|
1323
|
-
}
|
|
1324
|
-
return res;
|
|
1325
|
-
}
|
|
1326
|
-
handleData(ev, req, next) {
|
|
1327
|
-
this.checkStatus(ev);
|
|
1328
|
-
switch (ev.status) {
|
|
1329
|
-
case 200:
|
|
1330
|
-
return of(ev);
|
|
1331
|
-
case 401:
|
|
1332
|
-
if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
|
|
1333
|
-
return this.tryRefreshToken(ev, req, next);
|
|
1334
|
-
}
|
|
1335
|
-
this.ToLogin();
|
|
1336
|
-
break;
|
|
1337
|
-
case 403:
|
|
1338
|
-
case 404:
|
|
1339
|
-
case 500:
|
|
1340
|
-
this.goTo(`/exception/${ev.status}`);
|
|
1341
|
-
break;
|
|
1342
|
-
default:
|
|
1343
|
-
if (ev instanceof HttpErrorResponse) {
|
|
1344
|
-
console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
|
|
1345
|
-
}
|
|
1346
|
-
break;
|
|
1347
|
-
}
|
|
1348
|
-
if (ev instanceof HttpErrorResponse) {
|
|
1349
|
-
return throwError(ev);
|
|
1350
|
-
}
|
|
1351
|
-
else {
|
|
1352
|
-
return of(ev);
|
|
1353
|
-
}
|
|
1354
|
-
}
|
|
1355
|
-
intercept(req, next) {
|
|
1356
|
-
log('yz.default.interceptor.ts: ', 'request ', req);
|
|
1357
|
-
// 统一加前缀
|
|
1358
|
-
let url = req.url;
|
|
1359
|
-
if (!url.startsWith('https://') && !url.startsWith('http://')) {
|
|
1360
|
-
url = this.config.baseUrl + url;
|
|
1361
|
-
}
|
|
1362
|
-
if (url.includes('.json') && url.includes('assets')) {
|
|
1363
|
-
url = req.url;
|
|
1364
|
-
}
|
|
1365
|
-
// 加入语言头
|
|
1366
|
-
const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
|
|
1367
|
-
return next.handle(newReq).pipe(mergeMap(ev => {
|
|
1368
|
-
// 允许统一对请求错误处理
|
|
1369
|
-
if (ev instanceof HttpResponseBase) {
|
|
1370
|
-
return this.handleData(ev, newReq, next);
|
|
1371
|
-
}
|
|
1372
|
-
// 若一切都正常,则后续操作
|
|
1373
|
-
return of(ev);
|
|
1374
|
-
}), catchError((err) => this.handleData(err, newReq, next)));
|
|
1375
|
-
}
|
|
1376
|
-
}
|
|
1377
|
-
YzDefaultInterceptor.decorators = [
|
|
1378
|
-
{ type: Injectable }
|
|
1379
|
-
];
|
|
1380
|
-
YzDefaultInterceptor.ctorParameters = () => [
|
|
1381
|
-
{ type: Injector }
|
|
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.refreshToking = false;
|
|
1228
|
+
this.refreshToken$ = new BehaviorSubject(null);
|
|
1229
|
+
if (this.config.refreshTokenType === 'auth-refresh') {
|
|
1230
|
+
console.error("can't use auth-refresh, please change yz.default.interceptor to default.interceptor!");
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
get notification() {
|
|
1234
|
+
return this.injector.get(NzNotificationService);
|
|
1235
|
+
}
|
|
1236
|
+
get tokenSrv() {
|
|
1237
|
+
return this.injector.get(YA_SERVICE_TOKEN);
|
|
1238
|
+
}
|
|
1239
|
+
get http() {
|
|
1240
|
+
return this.injector.get(_HttpClient);
|
|
1241
|
+
}
|
|
1242
|
+
get config() {
|
|
1243
|
+
return mergeBisConfig(this.injector.get(YunzaiConfigService));
|
|
1244
|
+
}
|
|
1245
|
+
goTo(url) {
|
|
1246
|
+
setTimeout(() => this.injector.get(Router).navigateByUrl(url));
|
|
1247
|
+
}
|
|
1248
|
+
checkStatus(ev) {
|
|
1249
|
+
if ((ev.status >= 200 && ev.status < 300) || ev.status === 401) {
|
|
1250
|
+
return;
|
|
1251
|
+
}
|
|
1252
|
+
if (ev instanceof HttpResponse && ev.body.errorMessage) {
|
|
1253
|
+
this.notification.error(`发生了一些错误 `, ev.body.errorMessage);
|
|
1254
|
+
return;
|
|
1255
|
+
}
|
|
1256
|
+
const errortext = CODEMESSAGE[ev.status] || ev.statusText;
|
|
1257
|
+
this.notification.error(`请求错误 ${ev.status}: ${ev.url}`, errortext);
|
|
1258
|
+
}
|
|
1259
|
+
ToLogin() {
|
|
1260
|
+
this.notification.error(`未登录或登录状态已过期,5秒后将跳转到登录页面。`, ``);
|
|
1261
|
+
setTimeout(() => {
|
|
1262
|
+
localStorage.clear();
|
|
1263
|
+
this.injector.get(WINDOW).location.href = `${this.config.baseUrl}/cas-proxy/app/logout`;
|
|
1264
|
+
}, 5000);
|
|
1265
|
+
}
|
|
1266
|
+
reAttachToken(req) {
|
|
1267
|
+
var _a;
|
|
1268
|
+
const token = (_a = this.tokenSrv.get()) === null || _a === void 0 ? void 0 : _a.token;
|
|
1269
|
+
return req.clone({
|
|
1270
|
+
setHeaders: {
|
|
1271
|
+
Authorization: `Bearer ${token}`
|
|
1272
|
+
}
|
|
1273
|
+
});
|
|
1274
|
+
}
|
|
1275
|
+
refreshTokenRequest() {
|
|
1276
|
+
const model = this.tokenSrv.get();
|
|
1277
|
+
const form = new FormData();
|
|
1278
|
+
form.set('refresh_token', model === null || model === void 0 ? void 0 : model.refreshToken);
|
|
1279
|
+
log('yz.default.interceptor: use the refresh token to request a new token', model === null || model === void 0 ? void 0 : model.refreshToken);
|
|
1280
|
+
return this.http.post(`/auth/user/token/refresh?_allow_anonymous=true`, form);
|
|
1281
|
+
}
|
|
1282
|
+
tryRefreshToken(ev, req, next) {
|
|
1283
|
+
// 连刷新Token的请求都错了,那就是真错了
|
|
1284
|
+
if (['/auth/oauth/token'].some(url => req.url.includes(url))) {
|
|
1285
|
+
this.ToLogin();
|
|
1286
|
+
return throwError(ev);
|
|
1287
|
+
}
|
|
1288
|
+
// 正在刷新token,所有其他请求排队
|
|
1289
|
+
if (this.refreshToking) {
|
|
1290
|
+
return this.refreshToken$.pipe(filter(v => !!v), take(1), switchMap(() => next.handle(this.reAttachToken(req))));
|
|
1291
|
+
}
|
|
1292
|
+
//尝试调用刷新 Token
|
|
1293
|
+
this.refreshToking = true;
|
|
1294
|
+
this.refreshToken$.next(null);
|
|
1295
|
+
// 处理Token
|
|
1296
|
+
return this.refreshTokenRequest().pipe(switchMap(res => {
|
|
1297
|
+
log('yz.default.interceptor: refresh token accessed -> ', res);
|
|
1298
|
+
// 重新保存新 token
|
|
1299
|
+
const { access_token, expires_in, refresh_token, scope, token_type } = res;
|
|
1300
|
+
this.tokenSrv.set({
|
|
1301
|
+
token: access_token,
|
|
1302
|
+
expired: expires_in,
|
|
1303
|
+
refreshToken: refresh_token,
|
|
1304
|
+
tokenType: token_type,
|
|
1305
|
+
scope
|
|
1306
|
+
});
|
|
1307
|
+
// 通知后续请求继续执行
|
|
1308
|
+
this.refreshToking = false;
|
|
1309
|
+
this.refreshToken$.next(res);
|
|
1310
|
+
// 重新发起请求
|
|
1311
|
+
return next.handle(this.reAttachToken(req));
|
|
1312
|
+
}), catchError(err => {
|
|
1313
|
+
this.refreshToking = false;
|
|
1314
|
+
this.ToLogin();
|
|
1315
|
+
return throwError(err);
|
|
1316
|
+
}));
|
|
1317
|
+
}
|
|
1318
|
+
getAdditionalHeaders(headers) {
|
|
1319
|
+
const res = {};
|
|
1320
|
+
const lang = this.injector.get(YUNZAI_I18N_TOKEN).currentLang;
|
|
1321
|
+
if (!(headers === null || headers === void 0 ? void 0 : headers.has('Accept-Language')) && lang) {
|
|
1322
|
+
res['Accept-Language'] = lang;
|
|
1323
|
+
}
|
|
1324
|
+
return res;
|
|
1325
|
+
}
|
|
1326
|
+
handleData(ev, req, next) {
|
|
1327
|
+
this.checkStatus(ev);
|
|
1328
|
+
switch (ev.status) {
|
|
1329
|
+
case 200:
|
|
1330
|
+
return of(ev);
|
|
1331
|
+
case 401:
|
|
1332
|
+
if (this.config.refreshTokenEnabled && this.config.refreshTokenType === 're-request') {
|
|
1333
|
+
return this.tryRefreshToken(ev, req, next);
|
|
1334
|
+
}
|
|
1335
|
+
this.ToLogin();
|
|
1336
|
+
break;
|
|
1337
|
+
case 403:
|
|
1338
|
+
case 404:
|
|
1339
|
+
case 500:
|
|
1340
|
+
this.goTo(`/exception/${ev.status}`);
|
|
1341
|
+
break;
|
|
1342
|
+
default:
|
|
1343
|
+
if (ev instanceof HttpErrorResponse) {
|
|
1344
|
+
console.warn('未可知错误,大部分是由于后端不支持跨域CORS或无效配置引起,请参考 https://ng.yunzainfo.com/docs/server 解决跨域问题', ev);
|
|
1345
|
+
}
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
if (ev instanceof HttpErrorResponse) {
|
|
1349
|
+
return throwError(ev);
|
|
1350
|
+
}
|
|
1351
|
+
else {
|
|
1352
|
+
return of(ev);
|
|
1353
|
+
}
|
|
1354
|
+
}
|
|
1355
|
+
intercept(req, next) {
|
|
1356
|
+
log('yz.default.interceptor.ts: ', 'request ', req);
|
|
1357
|
+
// 统一加前缀
|
|
1358
|
+
let url = req.url;
|
|
1359
|
+
if (!url.startsWith('https://') && !url.startsWith('http://')) {
|
|
1360
|
+
url = this.config.baseUrl + url;
|
|
1361
|
+
}
|
|
1362
|
+
if (url.includes('.json') && url.includes('assets')) {
|
|
1363
|
+
url = req.url;
|
|
1364
|
+
}
|
|
1365
|
+
// 加入语言头
|
|
1366
|
+
const newReq = req.clone({ url, setHeaders: this.getAdditionalHeaders(req.headers) });
|
|
1367
|
+
return next.handle(newReq).pipe(mergeMap(ev => {
|
|
1368
|
+
// 允许统一对请求错误处理
|
|
1369
|
+
if (ev instanceof HttpResponseBase) {
|
|
1370
|
+
return this.handleData(ev, newReq, next);
|
|
1371
|
+
}
|
|
1372
|
+
// 若一切都正常,则后续操作
|
|
1373
|
+
return of(ev);
|
|
1374
|
+
}), catchError((err) => this.handleData(err, newReq, next)));
|
|
1375
|
+
}
|
|
1376
|
+
}
|
|
1377
|
+
YzDefaultInterceptor.decorators = [
|
|
1378
|
+
{ type: Injectable }
|
|
1379
|
+
];
|
|
1380
|
+
YzDefaultInterceptor.ctorParameters = () => [
|
|
1381
|
+
{ type: Injector }
|
|
1382
1382
|
];
|
|
1383
1383
|
|
|
1384
|
-
function mapYzSideToYelonMenu(menus) {
|
|
1385
|
-
menus.forEach(menu => {
|
|
1386
|
-
menu.badgeDot = menu.badge_dot || null;
|
|
1387
|
-
menu.badgeStatus = menu.badge_status || null;
|
|
1388
|
-
menu.shortcutRoot = menu.shortcut_root || null;
|
|
1389
|
-
menu.reuse = true;
|
|
1390
|
-
if (menu.children) {
|
|
1391
|
-
mapYzSideToYelonMenu(menu.children);
|
|
1392
|
-
}
|
|
1393
|
-
});
|
|
1394
|
-
}
|
|
1395
|
-
function generateAbility(menus, abilities, prefix) {
|
|
1396
|
-
menus.forEach(menu => {
|
|
1397
|
-
if (menu.link) {
|
|
1398
|
-
prefix += menu.link;
|
|
1399
|
-
}
|
|
1400
|
-
else {
|
|
1401
|
-
prefix += '';
|
|
1402
|
-
}
|
|
1403
|
-
if (menu.menuAuths) {
|
|
1404
|
-
menu.menuAuths.forEach((a) => {
|
|
1405
|
-
abilities.push(`${prefix}:${a}`);
|
|
1406
|
-
abilities.push(a);
|
|
1407
|
-
});
|
|
1408
|
-
}
|
|
1409
|
-
if (menu.children) {
|
|
1410
|
-
generateAbility(menu.children, abilities, prefix);
|
|
1411
|
-
}
|
|
1412
|
-
});
|
|
1413
|
-
}
|
|
1414
|
-
class YzStartupService {
|
|
1415
|
-
constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
|
|
1416
|
-
this.menuService = menuService;
|
|
1417
|
-
this.i18n = i18n;
|
|
1418
|
-
this.settingService = settingService;
|
|
1419
|
-
this.aclService = aclService;
|
|
1420
|
-
this.titleService = titleService;
|
|
1421
|
-
this.yzAuthService = yzAuthService;
|
|
1422
|
-
this.cacheService = cacheService;
|
|
1423
|
-
this.configService = configService;
|
|
1424
|
-
this.bis = BUSINESS_DEFAULT_CONFIG;
|
|
1425
|
-
this.bis = mergeBisConfig(this.configService);
|
|
1426
|
-
iconSrv.addIcon(...ICONS);
|
|
1427
|
-
}
|
|
1428
|
-
load() {
|
|
1429
|
-
log$1('startup.service: ', 'load');
|
|
1430
|
-
const defaultLang = this.i18n.defaultLang;
|
|
1431
|
-
return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
|
|
1432
|
-
log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
|
|
1433
|
-
this.i18n.use(defaultLang, langData);
|
|
1434
|
-
return of(null);
|
|
1435
|
-
}), mergeMap(() => {
|
|
1436
|
-
return this.yzAuthService.login();
|
|
1437
|
-
}), mergeMap(v => {
|
|
1438
|
-
// preloader finish
|
|
1439
|
-
this.systemInit();
|
|
1440
|
-
log$1('startup.service: preloader finish');
|
|
1441
|
-
const win = window;
|
|
1442
|
-
if (win && win.appBootstrap) {
|
|
1443
|
-
win.appBootstrap();
|
|
1444
|
-
}
|
|
1445
|
-
return of(v);
|
|
1446
|
-
}));
|
|
1447
|
-
}
|
|
1448
|
-
systemInit() {
|
|
1449
|
-
log$1('startup.service: system init');
|
|
1450
|
-
// user
|
|
1451
|
-
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
1452
|
-
// menu
|
|
1453
|
-
const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
|
|
1454
|
-
mapYzSideToYelonMenu(ms);
|
|
1455
|
-
const currentMenu = ms.pop();
|
|
1456
|
-
this.menuService.add([currentMenu]);
|
|
1457
|
-
// logo app
|
|
1458
|
-
this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
|
|
1459
|
-
this.settingService.setUser({
|
|
1460
|
-
name: user.realname || 'no name',
|
|
1461
|
-
avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
|
|
1462
|
-
email: user.email || 'no email'
|
|
1463
|
-
});
|
|
1464
|
-
// title
|
|
1465
|
-
this.titleService.default = currentMenu.text || 'default application name';
|
|
1466
|
-
this.titleService.setTitle(currentMenu.text || 'no title');
|
|
1467
|
-
// acl
|
|
1468
|
-
const abilities = [];
|
|
1469
|
-
generateAbility([currentMenu], abilities, '');
|
|
1470
|
-
this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
|
|
1471
|
-
return role.roleValue;
|
|
1472
|
-
}).filter((a) => !!a)) || []);
|
|
1473
|
-
this.aclService.attachAbility(abilities);
|
|
1474
|
-
// cache current
|
|
1475
|
-
this.cacheService.set('_yz_current', {
|
|
1476
|
-
text: currentMenu.text,
|
|
1477
|
-
intro: currentMenu.intro,
|
|
1478
|
-
icon: currentMenu.appIconUrl
|
|
1479
|
-
});
|
|
1480
|
-
}
|
|
1481
|
-
}
|
|
1482
|
-
YzStartupService.decorators = [
|
|
1483
|
-
{ type: Injectable }
|
|
1484
|
-
];
|
|
1485
|
-
YzStartupService.ctorParameters = () => [
|
|
1486
|
-
{ type: NzIconService },
|
|
1487
|
-
{ type: MenuService },
|
|
1488
|
-
{ type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
|
|
1489
|
-
{ type: SettingsService },
|
|
1490
|
-
{ type: ACLService },
|
|
1491
|
-
{ type: TitleService },
|
|
1492
|
-
{ type: YzAuthService },
|
|
1493
|
-
{ type: CacheService },
|
|
1494
|
-
{ type: YunzaiConfigService$1 }
|
|
1495
|
-
];
|
|
1496
|
-
function YzStartupServiceFactory(startupService) {
|
|
1497
|
-
return () => startupService.load();
|
|
1498
|
-
}
|
|
1499
|
-
//@ts-ignore
|
|
1500
|
-
const YZ_APPINIT_PROVIDES = [
|
|
1501
|
-
YzStartupService,
|
|
1502
|
-
{
|
|
1503
|
-
provide: APP_INITIALIZER,
|
|
1504
|
-
useFactory: YzStartupServiceFactory,
|
|
1505
|
-
deps: [YzStartupService],
|
|
1506
|
-
multi: true
|
|
1507
|
-
}
|
|
1384
|
+
function mapYzSideToYelonMenu(menus) {
|
|
1385
|
+
menus.forEach(menu => {
|
|
1386
|
+
menu.badgeDot = menu.badge_dot || null;
|
|
1387
|
+
menu.badgeStatus = menu.badge_status || null;
|
|
1388
|
+
menu.shortcutRoot = menu.shortcut_root || null;
|
|
1389
|
+
menu.reuse = true;
|
|
1390
|
+
if (menu.children) {
|
|
1391
|
+
mapYzSideToYelonMenu(menu.children);
|
|
1392
|
+
}
|
|
1393
|
+
});
|
|
1394
|
+
}
|
|
1395
|
+
function generateAbility(menus, abilities, prefix) {
|
|
1396
|
+
menus.forEach(menu => {
|
|
1397
|
+
if (menu.link) {
|
|
1398
|
+
prefix += menu.link;
|
|
1399
|
+
}
|
|
1400
|
+
else {
|
|
1401
|
+
prefix += '';
|
|
1402
|
+
}
|
|
1403
|
+
if (menu.menuAuths) {
|
|
1404
|
+
menu.menuAuths.forEach((a) => {
|
|
1405
|
+
abilities.push(`${prefix}:${a}`);
|
|
1406
|
+
abilities.push(a);
|
|
1407
|
+
});
|
|
1408
|
+
}
|
|
1409
|
+
if (menu.children) {
|
|
1410
|
+
generateAbility(menu.children, abilities, prefix);
|
|
1411
|
+
}
|
|
1412
|
+
});
|
|
1413
|
+
}
|
|
1414
|
+
class YzStartupService {
|
|
1415
|
+
constructor(iconSrv, menuService, i18n, settingService, aclService, titleService, yzAuthService, cacheService, configService) {
|
|
1416
|
+
this.menuService = menuService;
|
|
1417
|
+
this.i18n = i18n;
|
|
1418
|
+
this.settingService = settingService;
|
|
1419
|
+
this.aclService = aclService;
|
|
1420
|
+
this.titleService = titleService;
|
|
1421
|
+
this.yzAuthService = yzAuthService;
|
|
1422
|
+
this.cacheService = cacheService;
|
|
1423
|
+
this.configService = configService;
|
|
1424
|
+
this.bis = BUSINESS_DEFAULT_CONFIG;
|
|
1425
|
+
this.bis = mergeBisConfig(this.configService);
|
|
1426
|
+
iconSrv.addIcon(...ICONS);
|
|
1427
|
+
}
|
|
1428
|
+
load() {
|
|
1429
|
+
log$1('startup.service: ', 'load');
|
|
1430
|
+
const defaultLang = this.i18n.defaultLang;
|
|
1431
|
+
return this.i18n.loadLangData(defaultLang).pipe(mergeMap(langData => {
|
|
1432
|
+
log$1('startup.service: ', 'set i18n, defaultLang->', defaultLang, ' langData->', langData);
|
|
1433
|
+
this.i18n.use(defaultLang, langData);
|
|
1434
|
+
return of(null);
|
|
1435
|
+
}), mergeMap(() => {
|
|
1436
|
+
return this.yzAuthService.login();
|
|
1437
|
+
}), mergeMap(v => {
|
|
1438
|
+
// preloader finish
|
|
1439
|
+
this.systemInit();
|
|
1440
|
+
log$1('startup.service: preloader finish');
|
|
1441
|
+
const win = window;
|
|
1442
|
+
if (win && win.appBootstrap) {
|
|
1443
|
+
win.appBootstrap();
|
|
1444
|
+
}
|
|
1445
|
+
return of(v);
|
|
1446
|
+
}));
|
|
1447
|
+
}
|
|
1448
|
+
systemInit() {
|
|
1449
|
+
log$1('startup.service: system init');
|
|
1450
|
+
// user
|
|
1451
|
+
const user = this.cacheService.get('_yz_user', { mode: 'none' });
|
|
1452
|
+
// menu
|
|
1453
|
+
const ms = deepCopy(user.menu).filter((m) => m.systemCode && m.systemCode === this.bis.systemCode);
|
|
1454
|
+
mapYzSideToYelonMenu(ms);
|
|
1455
|
+
const currentMenu = ms.pop();
|
|
1456
|
+
this.menuService.add([currentMenu]);
|
|
1457
|
+
// logo app
|
|
1458
|
+
this.settingService.setApp({ name: currentMenu.text, description: currentMenu.intro });
|
|
1459
|
+
this.settingService.setUser({
|
|
1460
|
+
name: user.realname || 'no name',
|
|
1461
|
+
avatar: `${this.bis.baseUrl}/filecenter/file/${user.avatarId}` || '',
|
|
1462
|
+
email: user.email || 'no email'
|
|
1463
|
+
});
|
|
1464
|
+
// title
|
|
1465
|
+
this.titleService.default = currentMenu.text || 'default application name';
|
|
1466
|
+
this.titleService.setTitle(currentMenu.text || 'no title');
|
|
1467
|
+
// acl
|
|
1468
|
+
const abilities = [];
|
|
1469
|
+
generateAbility([currentMenu], abilities, '');
|
|
1470
|
+
this.aclService.attachRole((user === null || user === void 0 ? void 0 : user.roles.map((role) => {
|
|
1471
|
+
return role.roleValue;
|
|
1472
|
+
}).filter((a) => !!a)) || []);
|
|
1473
|
+
this.aclService.attachAbility(abilities);
|
|
1474
|
+
// cache current
|
|
1475
|
+
this.cacheService.set('_yz_current', {
|
|
1476
|
+
text: currentMenu.text,
|
|
1477
|
+
intro: currentMenu.intro,
|
|
1478
|
+
icon: currentMenu.appIconUrl
|
|
1479
|
+
});
|
|
1480
|
+
}
|
|
1481
|
+
}
|
|
1482
|
+
YzStartupService.decorators = [
|
|
1483
|
+
{ type: Injectable }
|
|
1484
|
+
];
|
|
1485
|
+
YzStartupService.ctorParameters = () => [
|
|
1486
|
+
{ type: NzIconService },
|
|
1487
|
+
{ type: MenuService },
|
|
1488
|
+
{ type: YzI18NService, decorators: [{ type: Inject, args: [YUNZAI_I18N_TOKEN,] }] },
|
|
1489
|
+
{ type: SettingsService },
|
|
1490
|
+
{ type: ACLService },
|
|
1491
|
+
{ type: TitleService },
|
|
1492
|
+
{ type: YzAuthService },
|
|
1493
|
+
{ type: CacheService },
|
|
1494
|
+
{ type: YunzaiConfigService$1 }
|
|
1495
|
+
];
|
|
1496
|
+
function YzStartupServiceFactory(startupService) {
|
|
1497
|
+
return () => startupService.load();
|
|
1498
|
+
}
|
|
1499
|
+
//@ts-ignore
|
|
1500
|
+
const YZ_APPINIT_PROVIDES = [
|
|
1501
|
+
YzStartupService,
|
|
1502
|
+
{
|
|
1503
|
+
provide: APP_INITIALIZER,
|
|
1504
|
+
useFactory: YzStartupServiceFactory,
|
|
1505
|
+
deps: [YzStartupService],
|
|
1506
|
+
multi: true
|
|
1507
|
+
}
|
|
1508
1508
|
];
|
|
1509
1509
|
|
|
1510
|
-
/**
|
|
1511
|
-
* Generated bundle index. Do not edit.
|
|
1510
|
+
/**
|
|
1511
|
+
* Generated bundle index. Do not edit.
|
|
1512
1512
|
*/
|
|
1513
1513
|
|
|
1514
1514
|
export { BUSINESS_DEFAULT_CONFIG, STOMP_DEFAULT_CONFIG, TOPIC, YZ_APPINIT_PROVIDES, YunzaiLayoutModule, YzAuthService, YzDefaultInterceptor, YzHeaderApplicationComponent, YzHeaderClearStorageComponent, YzHeaderFullScreenComponent, YzHeaderI18NComponent, YzHeaderNotifyComponent, YzHeaderThemBtnComponent, YzHeaderUserComponent, YzI18NService, YzLayoutBasicComponent, YzStartupService, YzStartupServiceFactory, YzStompService, generateAbility, mapYzSideToYelonMenu, mergeBisConfig, mergeStompConfig, ɵ0, YzHeaderApplicationComponent as ɵa, YzHeaderNotifyComponent as ɵb, YzHeaderThemBtnComponent as ɵc, YzHeaderUserComponent as ɵd, YzHeaderFullScreenComponent as ɵe, YzHeaderClearStorageComponent as ɵf, YzHeaderI18NComponent as ɵg };
|