Browse Source

fix(router): 修复登录跳转时路径参数丢失的问题

使用新的fullPath变量保存原始路径,避免在拼接查询参数时修改原始path变量
feige996 8 tháng trước cách đây
mục cha
commit
aef66ee6df
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      src/router/interceptor.ts

+ 3 - 2
src/router/interceptor.ts

@@ -39,11 +39,12 @@ export const navigateToInterceptor = {
       console.log('命中了 LOGIN_PAGE_LIST')
       return
     }
+    let fullPath = path
 
     if (myQuery) {
-      path += `?${Object.keys(myQuery).map(key => `${key}=${myQuery[key]}`).join('&')}`
+      fullPath += `?${Object.keys(myQuery).map(key => `${key}=${myQuery[key]}`).join('&')}`
     }
-    const redirectUrl = `${LOGIN_PAGE}?redirect=${encodeURIComponent(path)}`
+    const redirectUrl = `${LOGIN_PAGE}?redirect=${encodeURIComponent(fullPath)}`
 
     const tokenStore = useTokenStore()
     console.log('tokenStore.hasLogin:', tokenStore.hasLogin)