@yelon/bis 12.0.8 → 12.0.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/bundles/bis.umd.js +3 -3
  2. package/bundles/layout.umd.js +176 -41
  3. package/bundles/layout.umd.js.map +1 -1
  4. package/bundles/shared.umd.js +4 -17
  5. package/bundles/shared.umd.js.map +1 -1
  6. package/esm2015/{shared → layout}/bis.config.js +2 -2
  7. package/esm2015/layout/public_api.js +4 -1
  8. package/esm2015/layout/stomp.config.js +20 -0
  9. package/esm2015/layout/widgets/yz.application.component.js +5 -5
  10. package/esm2015/layout/widgets/yz.notify.component.js +3 -3
  11. package/esm2015/layout/widgets/yz.them-btn.component.js +32 -12
  12. package/esm2015/layout/widgets/yz.user.component.js +3 -3
  13. package/esm2015/layout/yz.auth.service.js +2 -2
  14. package/esm2015/layout/yz.basic.component.js +11 -4
  15. package/esm2015/layout/yz.default.interceptor.js +7 -4
  16. package/esm2015/layout/yz.startup.service.js +4 -3
  17. package/esm2015/layout/yz.stomp.service.js +91 -0
  18. package/esm2015/shared/public_api.js +1 -2
  19. package/fesm2015/layout.js +170 -30
  20. package/fesm2015/layout.js.map +1 -1
  21. package/fesm2015/shared.js +1 -12
  22. package/fesm2015/shared.js.map +1 -1
  23. package/{shared → layout}/bis.config.d.ts +1 -1
  24. package/layout/layout.metadata.json +1 -1
  25. package/layout/public_api.d.ts +3 -0
  26. package/layout/stomp.config.d.ts +3 -0
  27. package/layout/style/index.less +10 -2
  28. package/layout/yz.basic.component.d.ts +6 -3
  29. package/layout/yz.default.interceptor.d.ts +1 -0
  30. package/layout/yz.stomp.service.d.ts +39 -0
  31. package/package.json +10 -10
  32. package/shared/public_api.d.ts +0 -1
  33. package/shared/shared.metadata.json +1 -1
  34. package/theme-dark.less +15 -19
  35. package/theme-default.less +7 -8
@@ -1,5 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Injectable, Component, ChangeDetectionStrategy, Injector, Inject, Input, ChangeDetectorRef, Renderer2, Optional, HostListener, NgModule, APP_INITIALIZER } from '@angular/core';
2
+ import { Injectable, Component, ChangeDetectionStrategy, Injector, Inject, Input, ChangeDetectorRef, Renderer2, Optional, HostListener, isDevMode, NgModule, APP_INITIALIZER } from '@angular/core';
3
+ import * as i2$1 from '@yelon/cache';
3
4
  import { CacheService } from '@yelon/cache';
4
5
  import * as i1 from '@yelon/theme';
5
6
  import { zh_CN as zh_CN$1, zh_TW as zh_TW$1, en_US as en_US$1, YunzaiI18nBaseService, _HttpClient, SettingsService, YelonLocaleService, YUNZAI_I18N_TOKEN, MenuService, TitleService } from '@yelon/theme';
@@ -24,13 +25,15 @@ import { NzMessageService } from 'ng-zorro-antd/message';
24
25
  import { log } from '@yelon/util/other';
25
26
  import { Directionality } from '@angular/cdk/bidi';
26
27
  import { YUNZAI_THEME_BTN_KEYS } from '@yelon/theme/theme-btn';
27
- import { YA_SERVICE_TOKEN, mergeConfig as mergeConfig$1 } from '@yelon/auth';
28
- import { mergeConfig, YzSharedModule, BUSINESS_DEFAULT_CONFIG, ICONS } from '@yelon/bis/shared';
28
+ import { YA_SERVICE_TOKEN, mergeConfig } from '@yelon/auth';
29
29
  import { NzModalService } from 'ng-zorro-antd/modal';
30
30
  import * as screenfull from 'screenfull';
31
31
  import { HttpClientModule, HttpResponse, HttpErrorResponse, HttpResponseBase } from '@angular/common/http';
32
32
  import { FormsModule, ReactiveFormsModule } from '@angular/forms';
33
33
  import { RouterModule, Router } from '@angular/router';
34
+ import { YzSharedModule, ICONS } from '@yelon/bis/shared';
35
+ import { RxStomp } from '@stomp/rx-stomp';
36
+ import * as i3$1 from 'ng-zorro-antd/notification';
34
37
  import { NzNotificationService } from 'ng-zorro-antd/notification';
35
38
  import { NzIconService } from 'ng-zorro-antd/icon';
36
39
  import { ACLService } from '@yelon/acl';
@@ -249,7 +252,7 @@ YzHeaderApplicationComponent.decorators = [
249
252
  <input
250
253
  type="text"
251
254
  nz-input
252
- [placeholder]="'请输入要搜索的应用名称!'"
255
+ placeholder="{{ 'application.search' | i18n }}"
253
256
  [(ngModel)]="searchValue"
254
257
  (ngModelChange)="onSearch()"
255
258
  />
@@ -272,14 +275,14 @@ YzHeaderApplicationComponent.decorators = [
272
275
  <!-- template end-->
273
276
 
274
277
  <!-- button start-->
275
- <div class="yunzai-default__nav-item" (click)="diffChange()"> 应用与服务</div>
278
+ <div class="yunzai-default__nav-item" (click)="diffChange()"> {{ 'application.button' | i18n }}</div>
276
279
  <!-- button end-->
277
280
 
278
281
  <!-- header start-->
279
282
  <div class="yz-application" nz-row *ngIf="active">
280
283
  <div nz-col [nzSpan]="3" class="yz-application-topic">
281
- <div class="yz-application-text" (click)="full()">全部应用</div>
282
- <div class="yz-application-text" (click)="own()">我的应用</div>
284
+ <div class="yz-application-text" (click)="full()">{{ 'application.all' | i18n }}</div>
285
+ <div class="yz-application-text" (click)="own()">{{ 'application.mine' | i18n }}</div>
283
286
  <div class="yz-application-text" *ngFor="let d of topicData" (click)="every(d)">
284
287
  {{ d.name }}
285
288
  </div>
@@ -460,7 +463,7 @@ class YzHeaderNotifyComponent {
460
463
  .pipe(map((response) => {
461
464
  const viewMessage = this.data.filter(d => d.key === 'msg')[0];
462
465
  viewMessage.list = response.data.list.map((m) => {
463
- return Object.assign(Object.assign({}, m), { avatar: './assets/tmp/img/message.png', title: m.systemName, description: m.content, extra: formatMessageStatus(m.status).extra, color: formatMessageStatus(m.status).color, datetime: formatDistanceToNow(new Date(m.date), { locale: this.nzI18n.getDateLocale() }) });
466
+ 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() }) });
464
467
  });
465
468
  this.count += viewMessage.list.length;
466
469
  }));
@@ -486,7 +489,7 @@ class YzHeaderNotifyComponent {
486
489
  .pipe(map((response) => {
487
490
  const viewTodo = this.data.filter(d => d.key === 'todo')[0];
488
491
  viewTodo.list = response.data.list.map((t) => {
489
- return Object.assign(Object.assign({}, t), { avatar: './assets/tmp/img/todo.png', title: t.systemName, description: t.content, datetime: formatDistanceToNow(new Date(t.date), { locale: this.nzI18n.getDateLocale() }), extra: formatTodoStatus(t.status).extra, color: formatTodoStatus(t.status).color });
492
+ 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 });
490
493
  });
491
494
  this.count += viewTodo.list.length;
492
495
  }));
@@ -546,9 +549,18 @@ class YzHeaderThemBtnComponent {
546
549
  this.KEYS = KEYS;
547
550
  this.theme = 'default';
548
551
  this.types = [
549
- { key: 'default', text: 'Default Theme', color: '#2163ff' },
550
- { key: 'compact', text: 'Compact Theme', color: '#2163ff' },
551
- { key: 'dark', text: 'Dark Theme', color: '#020202' }
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' }
552
564
  ];
553
565
  this.devTips = `When the dark.css file can't be found, you need to run it once: npm run theme`;
554
566
  this.deployUrl = '';
@@ -627,14 +639,25 @@ YzHeaderThemBtnComponent.decorators = [
627
639
  </svg>
628
640
  </div>
629
641
  <nz-dropdown-menu #iconMenu="nzDropdownMenu">
630
- <div nz-menu class="wd-xl animated jello">
631
- <div nz-row [nzJustify]="'space-between'" [nzAlign]="'middle'" class="app-icons">
632
- <div nz-col [nzSpan]="6" *ngFor="let theme of types" (click)="onThemeChange(theme.key)">
633
- <i nz-icon nzType="bg-colors" class="text-white" [style]="{ backgroundColor: theme.color }"></i>
634
- <span [ngStyle]="{ color: theme.color }">{{ theme.key }}</span>
635
- </div>
636
- </div>
637
- </div>
642
+ <ul nz-menu>
643
+ <li
644
+ nz-menu-item
645
+ *ngFor="let theme of types"
646
+ (click)="onThemeChange(theme.key)"
647
+ [style]="{ color: theme.color }"
648
+ >
649
+ <i nz-icon nzType="bg-colors"></i>
650
+ {{ theme.text | i18n }}
651
+ </li>
652
+ </ul>
653
+ <!-- <div nz-menu class="wd-xl animated jello">-->
654
+ <!-- <div nz-row [nzJustify]="'space-between'" [nzAlign]="'middle'" class="app-icons">-->
655
+ <!-- <div nz-col [nzSpan]="4" *ngFor="let theme of types" (click)="onThemeChange(theme.key)">-->
656
+ <!-- <i nz-icon nzType="bg-colors" class="text-white" [style]="{ backgroundColor: theme.color }"></i>-->
657
+ <!-- <span [ngStyle]="{ color: theme.color }">{{ theme.text | i18n }}</span>-->
658
+ <!-- </div>-->
659
+ <!-- </div>-->
660
+ <!-- </div>-->
638
661
  </nz-dropdown-menu>
639
662
  `,
640
663
  changeDetection: ChangeDetectionStrategy.OnPush
@@ -654,6 +677,17 @@ YzHeaderThemBtnComponent.propDecorators = {
654
677
  deployUrl: [{ type: Input }]
655
678
  };
656
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);
689
+ }
690
+
657
691
  class YzHeaderUserComponent {
658
692
  constructor(injector, msg, tokenService,
659
693
  // @ts-ignore
@@ -666,7 +700,7 @@ class YzHeaderUserComponent {
666
700
  this.icon = '';
667
701
  this.username = '';
668
702
  this.menus = [];
669
- this.config = mergeConfig(configService);
703
+ this.config = mergeBisConfig(configService);
670
704
  }
671
705
  ngOnInit() {
672
706
  const projectInfo = this.cacheService.get('_yz_project_info', { mode: 'none' });
@@ -799,9 +833,107 @@ YzHeaderFullScreenComponent.propDecorators = {
799
833
  _click: [{ type: HostListener, args: ['click',] }]
800
834
  };
801
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);
852
+ }
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 ${JSON.stringify(this.config)}`);
875
+ this.rxStomp.configure(this.config);
876
+ return;
877
+ }
878
+ const { location } = this.injector.get(DOCUMENT);
879
+ const { protocol, host } = location;
880
+ log$1('yz.stomp.service: ', `protocol is ${protocol},host is ${host}`);
881
+ if (protocol.includes('http') && !protocol.includes('https')) {
882
+ this.config.brokerURL = `ws://${host}${this.config.brokerURL}`;
883
+ }
884
+ if (protocol.includes('https')) {
885
+ this.config.brokerURL = `wss://${host}${this.config.brokerURL}`;
886
+ }
887
+ log$1('yz.stomp.service: ', `config is ${this.config}`);
888
+ this.rxStomp.configure(this.config);
889
+ }
890
+ }
891
+ listen() {
892
+ this.subs.push(this.rxStomp.watch(`/topic/layout_${this.user.username}`).subscribe(message => {
893
+ this.createNotification(JSON.parse(message.body));
894
+ }));
895
+ this.subs.push(this.rxStomp.watch(`/topic/layout_xx_${this.user.username}`).subscribe((message) => {
896
+ this.logoutNotification(JSON.parse(message.body));
897
+ }));
898
+ this.rxStomp.activate();
899
+ }
900
+ createNotification(message) {
901
+ this.notification.create(message.type, message.title, `<a href=${message.href}>${message.content}</a>`);
902
+ }
903
+ logoutNotification(message) {
904
+ this.notification.create(message.type, message.title, `${message.content},剩余时间5秒`);
905
+ setTimeout(() => {
906
+ this.cache.clear();
907
+ localStorage.clear();
908
+ this.injector.get(WINDOW).location.href = `${this.bisConfig.baseUrl}/cas-proxy/app/logout`;
909
+ }, 5000);
910
+ }
911
+ unListen() {
912
+ this.subs.forEach(s => s.unsubscribe());
913
+ this.rxStomp.deactivate().then();
914
+ }
915
+ publish(parameters) {
916
+ this.rxStomp.publish(parameters);
917
+ }
918
+ watch(destination, headers) {
919
+ return this.rxStomp.watch(destination, headers);
920
+ }
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
+ ];
932
+
802
933
  class YzLayoutBasicComponent {
803
- constructor(cacheService) {
934
+ constructor(cacheService, yzStompService) {
804
935
  this.cacheService = cacheService;
936
+ this.yzStompService = yzStompService;
805
937
  this.options = {
806
938
  logoExpanded: `./assets/logo-full.svg`,
807
939
  logoCollapsed: `./assets/logo.svg`
@@ -818,6 +950,10 @@ class YzLayoutBasicComponent {
818
950
  this.icon = current.icon ? current.icon : `./assets/tmp/img/avatar.jpg`;
819
951
  this.options.logoExpanded = project.maxLogoUrl ? project.maxLogoUrl : `./assets/logo-full.svg`;
820
952
  this.options.logoCollapsed = project.miniLogoUrl ? project.miniLogoUrl : `./assets/logo.svg`;
953
+ this.yzStompService.listen();
954
+ }
955
+ ngOnDestroy() {
956
+ this.yzStompService.unListen();
821
957
  }
822
958
  }
823
959
  YzLayoutBasicComponent.decorators = [
@@ -874,7 +1010,7 @@ YzLayoutBasicComponent.decorators = [
874
1010
  </div>
875
1011
  <nz-dropdown-menu #userMenu="nzDropdownMenu">
876
1012
  <ul nz-menu>
877
- <li nz-menu-item routerLink="/">回到首页</li>
1013
+ <li nz-menu-item routerLink="/">{{ 'menu.backtohome' | i18n }}</li>
878
1014
  </ul>
879
1015
  </nz-dropdown-menu>
880
1016
  </ng-template>
@@ -888,7 +1024,8 @@ YzLayoutBasicComponent.decorators = [
888
1024
  },] }
889
1025
  ];
890
1026
  YzLayoutBasicComponent.ctorParameters = () => [
891
- { type: CacheService }
1027
+ { type: CacheService },
1028
+ { type: YzStompService }
892
1029
  ];
893
1030
 
894
1031
  const COMPONENTS = [
@@ -920,8 +1057,8 @@ YunzaiLayoutModule.decorators = [
920
1057
  class YzAuthService {
921
1058
  constructor(injector) {
922
1059
  this.injector = injector;
923
- this.option = mergeConfig$1(this.csr);
924
- this.bis = mergeConfig(this.csr);
1060
+ this.option = mergeConfig(this.csr);
1061
+ this.bis = mergeBisConfig(this.csr);
925
1062
  }
926
1063
  get csr() {
927
1064
  return this.injector.get(YunzaiConfigService);
@@ -1087,6 +1224,7 @@ const CODEMESSAGE = {
1087
1224
  class YzDefaultInterceptor {
1088
1225
  constructor(injector) {
1089
1226
  this.injector = injector;
1227
+ this.jump = false;
1090
1228
  this.refreshToking = false;
1091
1229
  this.refreshToken$ = new BehaviorSubject(null);
1092
1230
  if (this.config.refreshTokenType === 'auth-refresh') {
@@ -1103,7 +1241,7 @@ class YzDefaultInterceptor {
1103
1241
  return this.injector.get(_HttpClient);
1104
1242
  }
1105
1243
  get config() {
1106
- return mergeConfig(this.injector.get(YunzaiConfigService));
1244
+ return mergeBisConfig(this.injector.get(YunzaiConfigService));
1107
1245
  }
1108
1246
  goTo(url) {
1109
1247
  setTimeout(() => this.injector.get(Router).navigateByUrl(url));
@@ -1200,7 +1338,9 @@ class YzDefaultInterceptor {
1200
1338
  case 403:
1201
1339
  case 404:
1202
1340
  case 500:
1203
- this.goTo(`/exception/${ev.status}`);
1341
+ if (this.jump) {
1342
+ this.goTo(`/exception/${ev.status}`);
1343
+ }
1204
1344
  break;
1205
1345
  default:
1206
1346
  if (ev instanceof HttpErrorResponse) {
@@ -1285,7 +1425,7 @@ class YzStartupService {
1285
1425
  this.cacheService = cacheService;
1286
1426
  this.configService = configService;
1287
1427
  this.bis = BUSINESS_DEFAULT_CONFIG;
1288
- this.bis = mergeConfig(this.configService);
1428
+ this.bis = mergeBisConfig(this.configService);
1289
1429
  iconSrv.addIcon(...ICONS);
1290
1430
  }
1291
1431
  load() {
@@ -1374,5 +1514,5 @@ const YZ_APPINIT_PROVIDES = [
1374
1514
  * Generated bundle index. Do not edit.
1375
1515
  */
1376
1516
 
1377
- export { TOPIC, YZ_APPINIT_PROVIDES, YunzaiLayoutModule, YzAuthService, YzDefaultInterceptor, YzHeaderApplicationComponent, YzHeaderClearStorageComponent, YzHeaderFullScreenComponent, YzHeaderI18NComponent, YzHeaderNotifyComponent, YzHeaderThemBtnComponent, YzHeaderUserComponent, YzI18NService, YzLayoutBasicComponent, YzStartupService, YzStartupServiceFactory, generateAbility, mapYzSideToYelonMenu, YzHeaderApplicationComponent as ɵa, YzHeaderNotifyComponent as ɵb, YzHeaderThemBtnComponent as ɵc, YzHeaderUserComponent as ɵd, YzHeaderFullScreenComponent as ɵe, YzHeaderClearStorageComponent as ɵf, YzHeaderI18NComponent as ɵg };
1517
+ 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 };
1378
1518
  //# sourceMappingURL=layout.js.map