From 8414bbaa6896af0143ded066785e24b2832465da Mon Sep 17 00:00:00 2001
From: zoumiaojiang
Date: Fri, 5 Jul 2019 16:21:09 +0800
Subject: [PATCH] =?UTF-8?q?=E5=8D=95=E9=A1=B5=E8=B7=B3=E8=BD=AC=E9=80=8F?=
=?UTF-8?q?=E4=BC=A0=20hash?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
packages/mip/examples/page/index.html | 2 +-
packages/mip/src/viewer.js | 18 ++++++++++++++++--
2 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/packages/mip/examples/page/index.html b/packages/mip/examples/page/index.html
index 7d4d6cc4..cb74d498 100644
--- a/packages/mip/examples/page/index.html
+++ b/packages/mip/examples/page/index.html
@@ -124,7 +124,7 @@ 共享数据 checklist:
Login
- Go to Tree
+ Go to Tree
Go to Tree cache first
Prerender
diff --git a/packages/mip/src/viewer.js b/packages/mip/src/viewer.js
index 62094af6..23e12acb 100644
--- a/packages/mip/src/viewer.js
+++ b/packages/mip/src/viewer.js
@@ -4,7 +4,7 @@
* @author zhangzhiqiang(zhiqiangzhang37@163.com)
*/
-/* global top screen location */
+/* global top screen location, MIP */
import event from './util/dom/event'
import Gesture from './util/gesture/index'
@@ -266,9 +266,23 @@ let viewer = {
}
this.sendMessage(replace ? OUTER_MESSAGE_REPLACE_STATE : OUTER_MESSAGE_PUSH_STATE, pushMessage)
+ let routePath = (window.MIP.standalone && !window.MIP.util.isCacheUrl(location.href)) ? to : makeCacheUrl(to)
+ let routeSplits = routePath.split('#')
+ let hashStr = '#'
+ let curHashObj = MIP.hash._getHashObj(routeSplits[1] || '')
+ let targetHashObj = MIP.hash._getHashObj(location.hash)
+ let retObj = Object.assign({}, targetHashObj, curHashObj)
+
+ for (let key in retObj) {
+ hashStr += `${key}${retObj[key].sep}${retObj[key].value}&`
+ }
+
+ // hash 透传机制
+ routePath = routeSplits[0] + hashStr.substr(0, hashStr.length - 1)
+
// Create target route
let targetRoute = {
- path: (window.MIP.standalone && !window.MIP.util.isCacheUrl(location.href)) ? to : makeCacheUrl(to)
+ path: routePath
}
if (isMipLink) {