소스 검색

feat: 优化微应用404匹配逻辑

cuiyalong 2 년 전
부모
커밋
f37ec85803
1개의 변경된 파일12개의 추가작업 그리고 12개의 파일을 삭제
  1. 12 12
      src/web/staticres/micro/js/qiankun-common-functions.js

+ 12 - 12
src/web/staticres/micro/js/qiankun-common-functions.js

@@ -3,20 +3,20 @@
  * @param router
  * @returns {boolean}
  */
-function getHasRouteMatched(router) {
-  var pathName = location.pathname;
-  var baseName = router.options.base;
-  var pathIndex = pathName.indexOf(baseName);
-
+function getHasRouteMatched (router) {
+  var pathName = location.pathname
+  var baseName = router.options.base
+  var pathIndex = pathName.indexOf(baseName)
+  // 存在别名情况,需要额外匹配
+  var nowPath = pathName
   if (pathIndex > -1) {
-    var nowPath = pathName.slice(pathIndex + baseName.length);
-    var { route } = router.resolve({
-      path: nowPath,
-    });
-    var hasRouteMatched = route.matched.length > 0;
-    return hasRouteMatched;
+    nowPath = pathName.slice(pathIndex + baseName.length)
   }
-  return false;
+  var { route } = router.resolve({
+    path: nowPath
+  })
+  var hasRouteMatched = route.matched.length > 0
+  return hasRouteMatched
 }
 
 /**