From ce5e84197b43dec8c01717b116cb77535ad3c91e Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期三, 25 六月 2025 16:21:42 +0800
Subject: [PATCH] '登录注册'

---
 src/router/utils.ts |   31 ++++++++++++++++---------------
 1 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/src/router/utils.ts b/src/router/utils.ts
index 1e91571..bb895a1 100644
--- a/src/router/utils.ts
+++ b/src/router/utils.ts
@@ -33,7 +33,7 @@
   const { name, path, parentId, meta } = routeInfo;
   return isAllEmpty(parentId)
     ? isAllEmpty(meta?.rank) ||
-      (meta?.rank === 0 && name !== "Home" && path !== "/")
+      (meta?.rank === 0 && name !== "Welcome" && path !== "/welcome")
       ? true
       : false
     : false;
@@ -120,14 +120,14 @@
 
 /** 鏌ユ壘瀵瑰簲 `path` 鐨勮矾鐢变俊鎭� */
 function findRouteByPath(path: string, routes: RouteRecordRaw[]) {
-  let res = routes.find((item: { path: string }) => item.path == path);
+  let res = routes?.find((item: { path: string }) => item.path == path);
   if (res) {
     return isProxy(res) ? toRaw(res) : res;
   } else {
-    for (let i = 0; i < routes.length; i++) {
+    for (let i = 0; i < routes?.length; i++) {
       if (
-        routes[i].children instanceof Array &&
-        routes[i].children.length > 0
+        routes[i]?.children instanceof Array &&
+        routes[i]?.children.length > 0
       ) {
         res = findRouteByPath(path, routes[i].children);
         if (res) {
@@ -151,27 +151,27 @@
 
 /** 澶勭悊鍔ㄦ�佽矾鐢憋紙鍚庣杩斿洖鐨勮矾鐢憋級 */
 function handleAsyncRoutes(routeList) {
-  if (routeList.length === 0) {
+  if (routeList?.length === 0) {
     usePermissionStoreHook().handleWholeMenus(routeList);
   } else {
     formatFlatteningRoutes(addAsyncRoutes(routeList)).map(
       (v: RouteRecordRaw) => {
         // 闃叉閲嶅娣诲姞璺敱
         if (
-          router.options.routes[0].children.findIndex(
+          router.options.routes[0].children?.findIndex(
             value => value.path === v.path
           ) !== -1
         ) {
           return;
         } else {
           // 鍒囪灏嗚矾鐢眕ush鍒皉outes鍚庤繕闇�瑕佷娇鐢╝ddRoute锛岃繖鏍疯矾鐢辨墠鑳芥甯歌烦杞�
-          router.options.routes[0].children.push(v);
+          router.options.routes[0].children?.push(v);
           // 鏈�缁堣矾鐢辫繘琛屽崌搴�
           ascending(router.options.routes[0].children);
           if (!router.hasRoute(v?.name)) router.addRoute(v);
           const flattenRouters: any = router
             .getRoutes()
-            .find(n => n.path === "/");
+            .find(n => n.path === "/welcome");
           // 淇濇寔router.options.routes[0].children涓巔ath涓�"/"鐨刢hildren涓�鑷达紝闃叉鏁版嵁涓嶄竴鑷村鑷村紓甯�
           flattenRouters.children = router.options.routes[0].children;
           router.addRoute(flattenRouters);
@@ -205,8 +205,8 @@
     } else {
       return new Promise(resolve => {
         getAsyncRoutes().then(({ data }) => {
-          handleAsyncRoutes(cloneDeep(data));
-          storageLocal().setItem(key, data);
+          // handleAsyncRoutes(cloneDeep(data));
+          // storageLocal().setItem(key, data);
           resolve(router);
         });
       });
@@ -214,7 +214,7 @@
   } else {
     return new Promise(resolve => {
       getAsyncRoutes().then(({ data }) => {
-        handleAsyncRoutes(cloneDeep(data));
+        // handleAsyncRoutes(cloneDeep(data));
         resolve(router);
       });
     });
@@ -227,7 +227,7 @@
  * @returns 杩斿洖澶勭悊鍚庣殑涓�缁磋矾鐢�
  */
 function formatFlatteningRoutes(routesList: RouteRecordRaw[]) {
-  if (routesList.length === 0) return routesList;
+  if (routesList?.length === 0) return routesList;
   let hierarchyList = buildHierarchyTree(routesList);
   for (let i = 0; i < hierarchyList.length; i++) {
     if (hierarchyList[i].children) {
@@ -246,10 +246,10 @@
  * @returns 杩斿洖灏嗕竴缁存暟缁勯噸鏂板鐞嗘垚瑙勫畾璺敱鐨勬牸寮�
  */
 function formatTwoStageRoutes(routesList: RouteRecordRaw[]) {
-  if (routesList.length === 0) return routesList;
+  if (routesList?.length === 0) return routesList;
   const newRoutesList: RouteRecordRaw[] = [];
   routesList.forEach((v: RouteRecordRaw) => {
-    if (v.path === "/") {
+    if (v.path === "/welcome") {
       newRoutesList.push({
         component: v.component,
         name: v.name,
@@ -387,6 +387,7 @@
     usePermissionStoreHook().wholeMenus[0]?.children[0]
   );
   tag && useMultiTagsStoreHook().handleTags("push", topMenu);
+  console.log(topMenu, "topMenu");
   return topMenu;
 }
 

--
Gitblit v1.9.1