@tarojs/router 3.3.15 → 3.3.16
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.
- package/dist/index.js +13 -6
- package/dist/index.js.map +1 -1
- package/dist/router.esm.js +13 -6
- package/dist/router.esm.js.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -86,16 +86,23 @@ Stacks.prototype.get = function get () {
|
|
|
86
86
|
Stacks.prototype.getItem = function getItem (index) {
|
|
87
87
|
return this.stacks[index];
|
|
88
88
|
};
|
|
89
|
+
Stacks.prototype.getLastIndex = function getLastIndex (pathname) {
|
|
90
|
+
var list = [].concat( this.stacks ).reverse();
|
|
91
|
+
return list.findIndex(function (page) { var _a; return ((_a = page.path) === null || _a === void 0 ? void 0 : _a.replace(/\?.*/g, '')) === pathname; });
|
|
92
|
+
};
|
|
89
93
|
Stacks.prototype.getDelta = function getDelta (pathname) {
|
|
90
94
|
if (this.backDelta >= 1) {
|
|
91
95
|
return this.backDelta;
|
|
92
96
|
}
|
|
93
97
|
// NOTE: 此处为了修复浏览器后退多级页面,在大量重复路由状况下可能出现判断错误的情况 (增强判断能力只能考虑在 query 中新增参数来判断,暂时搁置)
|
|
94
|
-
|
|
95
|
-
return this.length - 1 - prevIndex;
|
|
98
|
+
return this.getLastIndex(pathname) || 1;
|
|
96
99
|
};
|
|
97
100
|
Stacks.prototype.getPrevIndex = function getPrevIndex (pathname) {
|
|
98
|
-
|
|
101
|
+
var lastIndex = this.getLastIndex(pathname);
|
|
102
|
+
if (lastIndex < 0) {
|
|
103
|
+
return -1;
|
|
104
|
+
}
|
|
105
|
+
return this.length - 1 - lastIndex;
|
|
99
106
|
};
|
|
100
107
|
Stacks.prototype.pop = function pop () {
|
|
101
108
|
return this.stacks.pop();
|
|
@@ -1551,11 +1558,11 @@ var qs = function (stamp) {
|
|
|
1551
1558
|
function pageOnReady(page, onLoad) {
|
|
1552
1559
|
if ( onLoad === void 0 ) onLoad = true;
|
|
1553
1560
|
|
|
1554
|
-
var _a;
|
|
1561
|
+
var _a, _b;
|
|
1555
1562
|
var pageEl = document.getElementById(page.path);
|
|
1556
1563
|
if (pageEl && !(pageEl === null || pageEl === void 0 ? void 0 : pageEl['__isReady'])) {
|
|
1557
1564
|
var el = pageEl.firstElementChild;
|
|
1558
|
-
(_a = el === null || el === void 0 ? void 0 : el['componentOnReady']) === null || _a === void 0 ? void 0 : _a.call(el).then(function () {
|
|
1565
|
+
(_b = (_a = el === null || el === void 0 ? void 0 : el['componentOnReady']) === null || _a === void 0 ? void 0 : _a.call(el)) === null || _b === void 0 ? void 0 : _b.then(function () {
|
|
1559
1566
|
runtime.requestAnimationFrame(function () {
|
|
1560
1567
|
page.onReady();
|
|
1561
1568
|
pageEl['__isReady'] = true;
|
|
@@ -1710,7 +1717,7 @@ function createRouter(app, config, framework) {
|
|
|
1710
1717
|
}
|
|
1711
1718
|
shouldLoad = true;
|
|
1712
1719
|
}
|
|
1713
|
-
if (shouldLoad) {
|
|
1720
|
+
if (shouldLoad || stacks.length < 1) {
|
|
1714
1721
|
var el = (_c = element.default) !== null && _c !== void 0 ? _c : element;
|
|
1715
1722
|
var loadConfig = Object.assign({}, pageConfig);
|
|
1716
1723
|
var stacksIndex = stacks.length;
|