Ver código fonte

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

使用新的fullPath变量保存原始路径,避免在拼接查询参数时修改原始path变量
feige996 8 meses atrás
pai
commit
aef66ee6df
1 arquivos alterados com 3 adições e 2 exclusões
  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)