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.
@@ -1734,7 +1734,7 @@
1734
1734
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1735
1735
  */
1736
1736
  /** @type {?} */
1737
- var storedRoutes = {};
1737
+ var storedRoutes = new Map();
1738
1738
  /** @type {?} */
1739
1739
  var toBeDeleteUrl;
1740
1740
  /** @type {?} */
@@ -1763,12 +1763,21 @@
1763
1763
  * @return {?}
1764
1764
  */
1765
1765
  function (route) {
1766
+ /** @type {?} */
1767
+ var config = route.routeConfig;
1768
+ // console.log("shouldDetach", toBeDeleteUrl, this.getRoutePath(route));
1766
1769
  if (toBeDeleteUrl === this.getRoutePath(route)) {
1767
1770
  // 对于新开的又即将关闭的tab,不缓存
1768
- toBeDeleteUrl = "";
1771
+ if (route.children.length === 0) {
1772
+ toBeDeleteUrl = "";
1773
+ }
1769
1774
  return false;
1770
1775
  }
1771
- return !excludeRoutes.includes(route.routeConfig.path);
1776
+ if (config && excludeRoutes.includes(this.getRoutePath(route))) {
1777
+ return false;
1778
+ }
1779
+ //Don't store lazy loaded routes
1780
+ return config && !config.loadChildren;
1772
1781
  };
1773
1782
  /**
1774
1783
  * @param {?} route
@@ -1783,7 +1792,9 @@
1783
1792
  function (route, handle) {
1784
1793
  // console.log("store", this.getRoutePath(route));
1785
1794
  // console.log("store", storedRoutes);
1786
- storedRoutes[this.getRoutePath(route)] = handle;
1795
+ /** @type {?} */
1796
+ var key = this.getRoutePath(route);
1797
+ storedRoutes.set(key, handle);
1787
1798
  };
1788
1799
  /**
1789
1800
  * @param {?} route
@@ -1794,7 +1805,9 @@
1794
1805
  * @return {?}
1795
1806
  */
1796
1807
  function (route) {
1797
- return !!storedRoutes[this.getRoutePath(route)];
1808
+ /** @type {?} */
1809
+ var key = this.getRoutePath(route);
1810
+ return !!route.routeConfig && storedRoutes.has(key);
1798
1811
  };
1799
1812
  /**
1800
1813
  * @param {?} route
@@ -1805,11 +1818,15 @@
1805
1818
  * @return {?}
1806
1819
  */
1807
1820
  function (route) {
1808
- if (!route.routeConfig)
1809
- return null;
1810
- if (route.routeConfig.loadChildren)
1811
- return null;
1812
- return storedRoutes[this.getRoutePath(route)];
1821
+ /** @type {?} */
1822
+ var config = route.routeConfig;
1823
+ /** @type {?} */
1824
+ var key = this.getRoutePath(route);
1825
+ //We don't store lazy loaded routes, so don't even bother trying to retrieve them
1826
+ if (!config || config.loadChildren) {
1827
+ return false;
1828
+ }
1829
+ return storedRoutes.get(key) || null;
1813
1830
  };
1814
1831
  /**
1815
1832
  * @param {?} future
@@ -1822,6 +1839,8 @@
1822
1839
  * @return {?}
1823
1840
  */
1824
1841
  function (future, curr) {
1842
+ // console.log("shouldReuseRoute", future, curr);
1843
+ // return future.routeConfig === curr.routeConfig;
1825
1844
  if (future.routeConfig === curr.routeConfig) {
1826
1845
  if (future.children.length === 0 && curr.children.length === 0) {
1827
1846
  // 无子路由时, 通过params和queryParams判断是否复用路由
@@ -1843,6 +1862,7 @@
1843
1862
  */
1844
1863
  function (route) {
1845
1864
  if (route.routeConfig) {
1865
+ // const pathParams = JSON.stringify(route.params);
1846
1866
  /** @type {?} */
1847
1867
  var queryParams = new URLSearchParams(route.queryParams).toString();
1848
1868
  /** @type {?} */
@@ -1866,7 +1886,16 @@
1866
1886
  function (path) {
1867
1887
  // console.log("clearCache", storedRoutes, path);
1868
1888
  toBeDeleteUrl = path;
1869
- delete storedRoutes[path]; // 清除指定路径的缓存
1889
+ storedRoutes.delete(path);
1890
+ };
1891
+ /**
1892
+ * @return {?}
1893
+ */
1894
+ KeepAliveService.prototype.clearAllCache = /**
1895
+ * @return {?}
1896
+ */
1897
+ function () {
1898
+ storedRoutes.clear();
1870
1899
  };
1871
1900
  KeepAliveService.decorators = [
1872
1901
  { type: core.Injectable, args: [{
@@ -1940,8 +1969,11 @@
1940
1969
  var state = navigation.extras.state;
1941
1970
  // 获取传递的 state
1942
1971
  /** @type {?} */
1972
+ var skipLocationChange = navigation.extras.skipLocationChange;
1973
+ // 获取是否跳过 location change
1974
+ /** @type {?} */
1943
1975
  var currentRoute = _this.router.routerState.root.firstChild;
1944
- if (currentRoute) {
1976
+ if (currentRoute && !skipLocationChange) {
1945
1977
  _this.setTab(_this.router.url, currentRoute.snapshot.routeConfig.path, state && state.title);
1946
1978
  }
1947
1979
  }