From 4856f06f41563b8fa2d12aaa1247d8925eb43aa3 Mon Sep 17 00:00:00 2001
From: chenghongxing <1126263215@qq.com>
Date: 星期四, 03 九月 2020 18:47:03 +0800
Subject: [PATCH] fix: configuration problem of first route's path; :bug: 修复:一级路由 path 配置问题;

---
 src/utils/routerUtil.js |   18 ++++++++++++++++--
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/utils/routerUtil.js b/src/utils/routerUtil.js
index dfab740..34a8941 100644
--- a/src/utils/routerUtil.js
+++ b/src/utils/routerUtil.js
@@ -66,7 +66,7 @@
   if (asyncRoutes) {
     if (routesConfig && routesConfig.length > 0) {
       const routes = parseRoutes(routesConfig, routerMap)
-      formatAuthority(routes)
+      formatRoutes(routes)
       const finalRoutes = mergeRoutes(router.options.routes, routes)
       router.options = {...router.options, routes: finalRoutes}
       router.matcher = new Router({...router.options, routes:[]}).matcher
@@ -132,6 +132,20 @@
     })
   }
   return parseRoutesMap(merge)
+}
+
+/**
+ * 鏍煎紡鍖栬矾鐢�
+ * @param routes 璺敱閰嶇疆
+ */
+function formatRoutes(routes) {
+  routes.forEach(route => {
+    const {path} = route
+    if (!path.startsWith('/') && path !== '*') {
+      route.path = '/' + path
+    }
+  })
+  formatAuthority(routes)
 }
 
 /**
@@ -203,4 +217,4 @@
   })
 }
 
-export {parseRoutes, loadRoutes, formatAuthority, getI18nKey, loadGuards, deepMergeRoutes}
+export {parseRoutes, loadRoutes, formatAuthority, getI18nKey, loadGuards, deepMergeRoutes, formatRoutes}

--
Gitblit v1.9.1