From aaf8a50511d77dbc209ca93bbba308c21179a8bc Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期二, 31 三月 2026 15:38:47 +0800
Subject: [PATCH] #前端

---
 rsf-design/src/router/core/RouteRegistry.js |   34 +++++++++++++++++++++++++---------
 1 files changed, 25 insertions(+), 9 deletions(-)

diff --git a/rsf-design/src/router/core/RouteRegistry.js b/rsf-design/src/router/core/RouteRegistry.js
index bccc392..3132e78 100644
--- a/rsf-design/src/router/core/RouteRegistry.js
+++ b/rsf-design/src/router/core/RouteRegistry.js
@@ -1,10 +1,10 @@
-import { ComponentLoader } from './ComponentLoader'
-import { RouteValidator } from './RouteValidator'
-import { RouteTransformer } from './RouteTransformer'
+import { ComponentLoader } from './ComponentLoader.js'
+import { RouteValidator } from './RouteValidator.js'
+import { RouteTransformer } from './RouteTransformer.js'
 class RouteRegistry {
-  constructor(router) {
+  constructor(router, options = {}) {
     this.router = router
-    this.componentLoader = new ComponentLoader()
+    this.componentLoader = options.componentLoader || new ComponentLoader()
     this.validator = new RouteValidator()
     this.transformer = new RouteTransformer(this.componentLoader)
     this.removeRouteFns = []
@@ -23,11 +23,27 @@
       throw new Error(`璺敱閰嶇疆楠岃瘉澶辫触: ${validationResult.errors.join(', ')}`)
     }
     const removeRouteFns = []
+    const existingRoutePaths = new Set(
+      (this.router.getRoutes?.() || []).map((route) => route?.path).filter(Boolean)
+    )
     menuList.forEach((route) => {
-      if (route.name && !this.router.hasRoute(route.name)) {
-        const routeConfig = this.transformer.transform(route)
-        const removeRouteFn = this.router.addRoute(routeConfig)
-        removeRouteFns.push(removeRouteFn)
+      const routeConfig = this.transformer.transform(route)
+      const routePath = routeConfig?.path
+
+      if (routePath && existingRoutePaths.has(routePath)) {
+        console.warn(`[RouteRegistry] 妫�娴嬪埌閲嶅璺緞锛屽凡璺宠繃鍔ㄦ�佹敞鍐�: ${routePath}`)
+        return
+      }
+
+      if (route.name && this.router.hasRoute(route.name)) {
+        console.warn(`[RouteRegistry] 妫�娴嬪埌閲嶅鍚嶇О锛屽凡璺宠繃鍔ㄦ�佹敞鍐�: ${route.name}`)
+        return
+      }
+
+      const removeRouteFn = this.router.addRoute(routeConfig)
+      removeRouteFns.push(removeRouteFn)
+      if (routePath) {
+        existingRoutePaths.add(routePath)
       }
     })
     this.removeRouteFns = removeRouteFns

--
Gitblit v1.9.1