raise-common-lib 0.0.175 → 0.0.176

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.
@@ -7,7 +7,7 @@ import { MAT_SNACK_BAR_DATA, MatSnackBar, MatSnackBarModule } from '@angular/mat
7
7
  import { MAT_DIALOG_DATA, MatDialogRef, MatDialog, MatDialogModule } from '@angular/material/dialog';
8
8
  import { TreeGridComponent } from '@syncfusion/ej2-angular-treegrid';
9
9
  import { CarouselAllModule, ToolbarModule, TabModule, TreeViewModule } from '@syncfusion/ej2-angular-navigations';
10
- import { NavigationEnd, Router, ActivatedRoute, RouteReuseStrategy } from '@angular/router';
10
+ import { NavigationEnd, Router, NavigationStart, ActivatedRoute, RouteReuseStrategy } from '@angular/router';
11
11
  import { filter } from 'rxjs/operators';
12
12
  import { moveItemInArray, DragDropModule } from '@angular/cdk/drag-drop';
13
13
  import { HttpClient, HttpClientModule } from '@angular/common/http';
@@ -2725,6 +2725,40 @@ class MultiTabComponent {
2725
2725
  if (isExistIdx !== -1) {
2726
2726
  this.selectedTab = isExistIdx;
2727
2727
  }
2728
+ this.subscriptions.push(this.router.events
2729
+ .pipe(filter((/**
2730
+ * @param {?} event
2731
+ * @return {?}
2732
+ */
2733
+ (event) => event instanceof NavigationStart)))
2734
+ .subscribe((/**
2735
+ * @param {?} event
2736
+ * @return {?}
2737
+ */
2738
+ (event) => {
2739
+ /** @type {?} */
2740
+ const navigation = this.router.getCurrentNavigation();
2741
+ if (navigation) {
2742
+ /** @type {?} */
2743
+ const state = navigation.extras.state;
2744
+ // 获取传递的 state
2745
+ /** @type {?} */
2746
+ let noReused = (state && state["noReused"]) || false;
2747
+ // 当前tab不复用,新开一个tab,当有已经存在的tab时候也是新开
2748
+ /** @type {?} */
2749
+ const isExistIdx = this.tabList.findIndex((/**
2750
+ * @param {?} ele
2751
+ * @return {?}
2752
+ */
2753
+ (ele) => this.urlWithoutQuery(ele.url) ===
2754
+ this.urlWithoutQuery(event.url)));
2755
+ if (isExistIdx !== -1 &&
2756
+ (noReused || this.tabList[isExistIdx].url !== event.url)) {
2757
+ // 如果当前tab已经存在,并且是新开的tab
2758
+ this.closeTab(isExistIdx, true); // 关闭当前tab
2759
+ }
2760
+ }
2761
+ })));
2728
2762
  this.subscriptions.push(this.router.events
2729
2763
  .pipe(filter((/**
2730
2764
  * @param {?} event
@@ -2732,9 +2766,10 @@ class MultiTabComponent {
2732
2766
  */
2733
2767
  (event) => event instanceof NavigationEnd)))
2734
2768
  .subscribe((/**
2769
+ * @param {?} event
2735
2770
  * @return {?}
2736
2771
  */
2737
- () => {
2772
+ (event) => {
2738
2773
  /** @type {?} */
2739
2774
  const navigation = this.router.getCurrentNavigation();
2740
2775
  if (navigation) {
@@ -2765,13 +2800,11 @@ class MultiTabComponent {
2765
2800
  navigationInfo.title ||
2766
2801
  navigationInfo.subTitle ||
2767
2802
  navigationInfo.name;
2768
- /** @type {?} */
2769
- let noReused = (state && state["noReused"]) || false;
2770
2803
  if (currentRoute && !skipLocationChange) {
2771
2804
  if (this.noGenerateTabUrls.includes(this.urlWithoutQuery(this.router.url))) {
2772
2805
  return; // 排除不生成tab的url
2773
2806
  }
2774
- this.setTab(this.router.url, currentRoute.snapshot.routeConfig.path, title, noReused);
2807
+ this.setTab(this.router.url, currentRoute.snapshot.routeConfig.path, title);
2775
2808
  }
2776
2809
  }
2777
2810
  })));
@@ -2980,10 +3013,9 @@ class MultiTabComponent {
2980
3013
  * @param {?} url
2981
3014
  * @param {?} pureUrl
2982
3015
  * @param {?} title
2983
- * @param {?} noReused
2984
3016
  * @return {?}
2985
3017
  */
2986
- setTab(url, pureUrl, title, noReused) {
3018
+ setTab(url, pureUrl, title) {
2987
3019
  /** @type {?} */
2988
3020
  const isExistIdx = this.tabList.findIndex((/**
2989
3021
  * @param {?} ele
@@ -3009,30 +3041,7 @@ class MultiTabComponent {
3009
3041
  this.addTab(url, title);
3010
3042
  }
3011
3043
  else {
3012
- /** @type {?} */
3013
- const targetTabUrl = this.tabList[isExistIdx].url;
3014
- if (targetTabUrl !== url || noReused) {
3015
- // 当缓存一致时候,但是url不一致,重新按照新的url生成tab
3016
- this.closeTab(isExistIdx, true);
3017
- setTimeout((/**
3018
- * @return {?}
3019
- */
3020
- () => {
3021
- this.keepAlive.clearCache(url);
3022
- this.drawer.deleteCache(url);
3023
- this.router
3024
- .navigateByUrl("/", { skipLocationChange: true })
3025
- .then((/**
3026
- * @return {?}
3027
- */
3028
- () => {
3029
- this.router.navigateByUrl(url); // 重新导航到当前 URL
3030
- }));
3031
- }), 30);
3032
- }
3033
- else {
3034
- this.changeTab(this.tabList[isExistIdx], isExistIdx);
3035
- }
3044
+ this.changeTab(this.tabList[isExistIdx], isExistIdx);
3036
3045
  this.ref.markForCheck();
3037
3046
  }
3038
3047
  }
@@ -3042,7 +3051,7 @@ class MultiTabComponent {
3042
3051
  */
3043
3052
  onTabDrop(event) {
3044
3053
  const { previousIndex, currentIndex } = event;
3045
- console.log("previousIndex", previousIndex, "currentIndex", currentIndex);
3054
+ // console.log("previousIndex", previousIndex, "currentIndex", currentIndex);
3046
3055
  if (previousIndex === 0 || currentIndex === 0) {
3047
3056
  return;
3048
3057
  }