瀏覽代碼

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

使用新的fullPath变量保存原始路径,避免在拼接查询参数时修改原始path变量
feige996 8 月之前
父節點
當前提交
aef66ee6df
共有 1 個文件被更改,包括 3 次插入2 次删除
  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)