Skip to content

Commit a327656

Browse files
JingyuanZhangallen-zh
authored andcommitted
feat(update api): add history list to global api getCurrentPages (#39)
feat(build): H5 getCurrentPages 支持返回历史页面栈信息
1 parent 2dceb39 commit a327656

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

packages/mars-build/src/h5/template/router.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,6 @@ router.beforeEach(function (to, from, next) {
2424
to.query._ = guid();
2525
}
2626

27-
Vue.prototype.currentRoute = [{
28-
route: to.path.replace(/^\//, ''),
29-
uri: to.path.replace(/^\//, ''),
30-
options: to.query
31-
}];
3227
let toPath = decodeURI(to.fullPath); // 兼容 vue-router 浏览器前进/返回时的 decodeURI操作
3328
let fromPath = decodeURI(from.fullPath);
3429
const browserHistoryArr = browserHistory.list;
@@ -77,7 +72,10 @@ router.beforeEach(function (to, from, next) {
7772
|| -1 === browserHistoryIndex
7873
|| browserHistoryIndex !== browserHistoryLength - 1) {
7974
browserHistoryArr.push({
80-
path: toPath
75+
path: toPath,
76+
route: to.path.replace(/^\//, ''),
77+
uri: to.path.replace(/^\//, ''),
78+
options: to.query
8179
});
8280
}
8381
}
@@ -86,6 +84,7 @@ router.beforeEach(function (to, from, next) {
8684
// browserHistoryArr = [];
8785
// browserHistoryArr.push({path: to.fullPath});
8886
// }
87+
Vue.prototype.currentRoute = browserHistoryArr;
8988
browserHistory.set(browserHistoryArr);
9089
router.app.$nextTick(() => {
9190
const browserHistoryArr = browserHistory.list;

0 commit comments

Comments
 (0)