raise-common-lib 0.0.24 → 0.0.26

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.
@@ -1300,7 +1300,7 @@ CommonFunctionService.ctorParameters = () => [];
1300
1300
  * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
1301
1301
  */
1302
1302
  /** @type {?} */
1303
- const storedRoutes = {};
1303
+ const storedRoutes = new Map();
1304
1304
  /** @type {?} */
1305
1305
  let toBeDeleteUrl;
1306
1306
  /** @type {?} */
@@ -1319,12 +1319,21 @@ class KeepAliveService {
1319
1319
  * @return {?}
1320
1320
  */
1321
1321
  shouldDetach(route) {
1322
+ /** @type {?} */
1323
+ let config = route.routeConfig;
1324
+ // console.log("shouldDetach", toBeDeleteUrl, this.getRoutePath(route));
1322
1325
  if (toBeDeleteUrl === this.getRoutePath(route)) {
1323
1326
  // 对于新开的又即将关闭的tab,不缓存
1324
- toBeDeleteUrl = "";
1327
+ if (route.children.length === 0) {
1328
+ toBeDeleteUrl = "";
1329
+ }
1330
+ return false;
1331
+ }
1332
+ if (config && excludeRoutes.includes(this.getRoutePath(route))) {
1325
1333
  return false;
1326
1334
  }
1327
- return !excludeRoutes.includes(route.routeConfig.path);
1335
+ //Don't store lazy loaded routes
1336
+ return config && !config.loadChildren;
1328
1337
  }
1329
1338
  /**
1330
1339
  * @param {?} route
@@ -1334,25 +1343,33 @@ class KeepAliveService {
1334
1343
  store(route, handle) {
1335
1344
  // console.log("store", this.getRoutePath(route));
1336
1345
  // console.log("store", storedRoutes);
1337
- storedRoutes[this.getRoutePath(route)] = handle;
1346
+ /** @type {?} */
1347
+ const key = this.getRoutePath(route);
1348
+ storedRoutes.set(key, handle);
1338
1349
  }
1339
1350
  /**
1340
1351
  * @param {?} route
1341
1352
  * @return {?}
1342
1353
  */
1343
1354
  shouldAttach(route) {
1344
- return !!storedRoutes[this.getRoutePath(route)];
1355
+ /** @type {?} */
1356
+ const key = this.getRoutePath(route);
1357
+ return !!route.routeConfig && storedRoutes.has(key);
1345
1358
  }
1346
1359
  /**
1347
1360
  * @param {?} route
1348
1361
  * @return {?}
1349
1362
  */
1350
1363
  retrieve(route) {
1351
- if (!route.routeConfig)
1352
- return null;
1353
- if (route.routeConfig.loadChildren)
1354
- return null;
1355
- return storedRoutes[this.getRoutePath(route)];
1364
+ /** @type {?} */
1365
+ let config = route.routeConfig;
1366
+ /** @type {?} */
1367
+ const key = this.getRoutePath(route);
1368
+ //We don't store lazy loaded routes, so don't even bother trying to retrieve them
1369
+ if (!config || config.loadChildren) {
1370
+ return false;
1371
+ }
1372
+ return storedRoutes.get(key) || null;
1356
1373
  }
1357
1374
  /**
1358
1375
  * @param {?} future
@@ -1360,6 +1377,8 @@ class KeepAliveService {
1360
1377
  * @return {?}
1361
1378
  */
1362
1379
  shouldReuseRoute(future, curr) {
1380
+ // console.log("shouldReuseRoute", future, curr);
1381
+ // return future.routeConfig === curr.routeConfig;
1363
1382
  if (future.routeConfig === curr.routeConfig) {
1364
1383
  if (future.children.length === 0 && curr.children.length === 0) {
1365
1384
  // 无子路由时, 通过params和queryParams判断是否复用路由
@@ -1377,6 +1396,7 @@ class KeepAliveService {
1377
1396
  */
1378
1397
  getRoutePath(route) {
1379
1398
  if (route.routeConfig) {
1399
+ // const pathParams = JSON.stringify(route.params);
1380
1400
  /** @type {?} */
1381
1401
  const queryParams = new URLSearchParams(route.queryParams).toString();
1382
1402
  /** @type {?} */
@@ -1396,7 +1416,13 @@ class KeepAliveService {
1396
1416
  clearCache(path) {
1397
1417
  // console.log("clearCache", storedRoutes, path);
1398
1418
  toBeDeleteUrl = path;
1399
- delete storedRoutes[path]; // 清除指定路径的缓存
1419
+ storedRoutes.delete(path);
1420
+ }
1421
+ /**
1422
+ * @return {?}
1423
+ */
1424
+ clearAllCache() {
1425
+ storedRoutes.clear();
1400
1426
  }
1401
1427
  }
1402
1428
  KeepAliveService.decorators = [
@@ -1449,6 +1475,16 @@ class MultiTabComponent {
1449
1475
  */
1450
1476
  ngOnInit() {
1451
1477
  this.initTab();
1478
+ // 解决刷新页面后,选中的 tab 丢失问题
1479
+ /** @type {?} */
1480
+ const isExistIdx = this.tabList.findIndex((/**
1481
+ * @param {?} ele
1482
+ * @return {?}
1483
+ */
1484
+ (ele) => ele.url === this.router.url));
1485
+ if (isExistIdx !== -1) {
1486
+ this.selectedTab = isExistIdx;
1487
+ }
1452
1488
  this.router.events
1453
1489
  .pipe(filter((/**
1454
1490
  * @param {?} event
@@ -1466,8 +1502,11 @@ class MultiTabComponent {
1466
1502
  const state = navigation.extras.state;
1467
1503
  // 获取传递的 state
1468
1504
  /** @type {?} */
1505
+ const skipLocationChange = navigation.extras.skipLocationChange;
1506
+ // 获取是否跳过 location change
1507
+ /** @type {?} */
1469
1508
  const currentRoute = this.router.routerState.root.firstChild;
1470
- if (currentRoute) {
1509
+ if (currentRoute && !skipLocationChange) {
1471
1510
  this.setTab(this.router.url, currentRoute.snapshot.routeConfig.path, state && state.title);
1472
1511
  }
1473
1512
  }
@@ -1598,8 +1637,8 @@ class MultiTabComponent {
1598
1637
  }
1599
1638
  /**
1600
1639
  * @param {?} url
1601
- * @param {?} pureUrl
1602
- * @param {?} title
1640
+ * @param {?=} pureUrl
1641
+ * @param {?=} title
1603
1642
  * @return {?}
1604
1643
  */
1605
1644
  setTab(url, pureUrl, title) {
@@ -1731,11 +1770,13 @@ class RSHeaderComponent {
1731
1770
  set langOptions(options) {
1732
1771
  this._langOptions = options;
1733
1772
  if (options && options.length > 0) {
1773
+ /** @type {?} */
1774
+ const languageCode = localStorage.getItem("language");
1734
1775
  this.currentLang = options.find((/**
1735
1776
  * @param {?} e
1736
1777
  * @return {?}
1737
1778
  */
1738
- (e) => e.defaultLang));
1779
+ (e) => e.languageCode === languageCode));
1739
1780
  }
1740
1781
  }
1741
1782
  /**