From 19aef84d40fbe37b8ee49cdc14186261d8b928f5 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期三, 18 六月 2025 17:09:28 +0800
Subject: [PATCH] '路由配置'

---
 src/router/utils.ts |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/router/utils.ts b/src/router/utils.ts
index 1e91571..da5f0cd 100644
--- a/src/router/utils.ts
+++ b/src/router/utils.ts
@@ -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) {
@@ -158,14 +158,14 @@
       (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);

--
Gitblit v1.9.1