raise-common-lib 0.0.24 → 0.0.25

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.
@@ -1536,7 +1536,7 @@ var CommonFunctionService = /** @class */ (function () {
1536
1536
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1537
1537
  */
1538
1538
  /** @type {?} */
1539
- var storedRoutes = {};
1539
+ var storedRoutes = new Map();
1540
1540
  /** @type {?} */
1541
1541
  var toBeDeleteUrl;
1542
1542
  /** @type {?} */
@@ -1565,12 +1565,21 @@ var KeepAliveService = /** @class */ (function () {
1565
1565
  * @return {?}
1566
1566
  */
1567
1567
  function (route) {
1568
+ /** @type {?} */
1569
+ var config = route.routeConfig;
1570
+ // console.log("shouldDetach", toBeDeleteUrl, this.getRoutePath(route));
1568
1571
  if (toBeDeleteUrl === this.getRoutePath(route)) {
1569
1572
  // 对于新开的又即将关闭的tab,不缓存
1570
- toBeDeleteUrl = "";
1573
+ if (route.children.length === 0) {
1574
+ toBeDeleteUrl = "";
1575
+ }
1571
1576
  return false;
1572
1577
  }
1573
- return !excludeRoutes.includes(route.routeConfig.path);
1578
+ if (config && excludeRoutes.includes(this.getRoutePath(route))) {
1579
+ return false;
1580
+ }
1581
+ //Don't store lazy loaded routes
1582
+ return config && !config.loadChildren;
1574
1583
  };
1575
1584
  /**
1576
1585
  * @param {?} route
@@ -1585,7 +1594,9 @@ var KeepAliveService = /** @class */ (function () {
1585
1594
  function (route, handle) {
1586
1595
  // console.log("store", this.getRoutePath(route));
1587
1596
  // console.log("store", storedRoutes);
1588
- storedRoutes[this.getRoutePath(route)] = handle;
1597
+ /** @type {?} */
1598
+ var key = this.getRoutePath(route);
1599
+ storedRoutes.set(key, handle);
1589
1600
  };
1590
1601
  /**
1591
1602
  * @param {?} route
@@ -1596,7 +1607,9 @@ var KeepAliveService = /** @class */ (function () {
1596
1607
  * @return {?}
1597
1608
  */
1598
1609
  function (route) {
1599
- return !!storedRoutes[this.getRoutePath(route)];
1610
+ /** @type {?} */
1611
+ var key = this.getRoutePath(route);
1612
+ return !!route.routeConfig && storedRoutes.has(key);
1600
1613
  };
1601
1614
  /**
1602
1615
  * @param {?} route
@@ -1607,11 +1620,15 @@ var KeepAliveService = /** @class */ (function () {
1607
1620
  * @return {?}
1608
1621
  */
1609
1622
  function (route) {
1610
- if (!route.routeConfig)
1611
- return null;
1612
- if (route.routeConfig.loadChildren)
1613
- return null;
1614
- return storedRoutes[this.getRoutePath(route)];
1623
+ /** @type {?} */
1624
+ var config = route.routeConfig;
1625
+ /** @type {?} */
1626
+ var key = this.getRoutePath(route);
1627
+ //We don't store lazy loaded routes, so don't even bother trying to retrieve them
1628
+ if (!config || config.loadChildren) {
1629
+ return false;
1630
+ }
1631
+ return storedRoutes.get(key) || null;
1615
1632
  };
1616
1633
  /**
1617
1634
  * @param {?} future
@@ -1624,6 +1641,8 @@ var KeepAliveService = /** @class */ (function () {
1624
1641
  * @return {?}
1625
1642
  */
1626
1643
  function (future, curr) {
1644
+ // console.log("shouldReuseRoute", future, curr);
1645
+ // return future.routeConfig === curr.routeConfig;
1627
1646
  if (future.routeConfig === curr.routeConfig) {
1628
1647
  if (future.children.length === 0 && curr.children.length === 0) {
1629
1648
  // 无子路由时, 通过params和queryParams判断是否复用路由
@@ -1645,6 +1664,7 @@ var KeepAliveService = /** @class */ (function () {
1645
1664
  */
1646
1665
  function (route) {
1647
1666
  if (route.routeConfig) {
1667
+ // const pathParams = JSON.stringify(route.params);
1648
1668
  /** @type {?} */
1649
1669
  var queryParams = new URLSearchParams(route.queryParams).toString();
1650
1670
  /** @type {?} */
@@ -1668,7 +1688,16 @@ var KeepAliveService = /** @class */ (function () {
1668
1688
  function (path) {
1669
1689
  // console.log("clearCache", storedRoutes, path);
1670
1690
  toBeDeleteUrl = path;
1671
- delete storedRoutes[path]; // 清除指定路径的缓存
1691
+ storedRoutes.delete(path);
1692
+ };
1693
+ /**
1694
+ * @return {?}
1695
+ */
1696
+ KeepAliveService.prototype.clearAllCache = /**
1697
+ * @return {?}
1698
+ */
1699
+ function () {
1700
+ storedRoutes.clear();
1672
1701
  };
1673
1702
  KeepAliveService.decorators = [
1674
1703
  { type: Injectable, args: [{
@@ -1742,8 +1771,11 @@ var MultiTabComponent = /** @class */ (function () {
1742
1771
  var state = navigation.extras.state;
1743
1772
  // 获取传递的 state
1744
1773
  /** @type {?} */
1774
+ var skipLocationChange = navigation.extras.skipLocationChange;
1775
+ // 获取是否跳过 location change
1776
+ /** @type {?} */
1745
1777
  var currentRoute = _this.router.routerState.root.firstChild;
1746
- if (currentRoute) {
1778
+ if (currentRoute && !skipLocationChange) {
1747
1779
  _this.setTab(_this.router.url, currentRoute.snapshot.routeConfig.path, state && state.title);
1748
1780
  }
1749
1781
  }