From 0a1d91e42e6c5af96e1108e9ebcc37e99eb3b22c Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期四, 02 四月 2026 15:55:58 +0800
Subject: [PATCH] #路由修复

---
 rsf-design/src/router/guards/beforeEach.js |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/rsf-design/src/router/guards/beforeEach.js b/rsf-design/src/router/guards/beforeEach.js
index ff63662..1b797f0 100644
--- a/rsf-design/src/router/guards/beforeEach.js
+++ b/rsf-design/src/router/guards/beforeEach.js
@@ -19,6 +19,7 @@
 let pendingLoading = false
 let routeInitFailed = false
 let routeInitInProgress = false
+let pendingRouteLocation = null
 function getPendingLoading() {
   return pendingLoading
 }
@@ -31,6 +32,23 @@
 function resetRouteInitState() {
   routeInitFailed = false
   routeInitInProgress = false
+  pendingRouteLocation = null
+}
+function createRouteLocation(route) {
+  return {
+    path: route.path,
+    query: route.query,
+    hash: route.hash,
+    replace: true
+  }
+}
+function queuePendingRoute(route) {
+  pendingRouteLocation = createRouteLocation(route)
+}
+function consumePendingRoute() {
+  const queuedRoute = pendingRouteLocation
+  pendingRouteLocation = null
+  return queuedRoute
 }
 function setupBeforeEachGuard(router) {
   routeRegistry = new RouteRegistry(router)
@@ -71,6 +89,7 @@
   }
   if (!routeRegistry?.isRegistered() && userStore.isLogin) {
     if (routeInitInProgress) {
+      queuePendingRoute(to)
       next(false)
       return
     }
@@ -157,35 +176,30 @@
     menuStore.addRemoveRouteFns(routeRegistry?.getRemoveRouteFns() || [])
     IframeRouteManager.getInstance().save()
     useWorktabStore().validateWorktabs(router)
-    if (isStaticRoute(to.path)) {
+    const targetLocation = consumePendingRoute() || createRouteLocation(to)
+    if (isStaticRoute(targetLocation.path)) {
       routeInitInProgress = false
-      next({
-        path: to.path,
-        query: to.query,
-        hash: to.hash,
-        replace: true
-      })
+      next(targetLocation)
       return
     }
     const { homePath } = useCommon()
     const { path: validatedPath, hasPermission } = RoutePermissionValidator.validatePath(
-      to.path,
+      targetLocation.path,
       menuList,
       homePath.value || '/'
     )
     routeInitInProgress = false
     if (!hasPermission) {
       closeLoading()
-      console.warn(`[RouteGuard] 鐢ㄦ埛鏃犳潈闄愯闂矾寰�: ${to.path}锛屽凡璺宠浆鍒伴椤礰)
+      console.warn(`[RouteGuard] 鐢ㄦ埛鏃犳潈闄愯闂矾寰�: ${targetLocation.path}锛屽凡璺宠浆鍒伴椤礰)
       next({
         path: validatedPath,
         replace: true
       })
     } else {
       next({
-        path: to.path,
-        query: to.query,
-        hash: to.hash,
+        ...targetLocation,
+        path: validatedPath,
         replace: true
       })
     }

--
Gitblit v1.9.1