From 4820f4e2d0ebdf9ff0968d4a49431d68a8c70706 Mon Sep 17 00:00:00 2001 From: WANGFan <15871339963@163.com> Date: Sun, 18 May 2025 22:43:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A7=A3=E5=86=B3=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E4=B8=8B=E8=B7=AF=E7=94=B1=E4=B8=8D=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/router/route-output.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/router/route-output.ts b/src/router/route-output.ts index 91249eb..47e2e4c 100644 --- a/src/router/route-output.ts +++ b/src/router/route-output.ts @@ -22,7 +22,7 @@ export function linearArray(tree: any) { * @param {any} current 需要跳转的路由和路由参数 */ export const currentlyRoute = (current: any) => { - const route = deepClone(current); + const route = deepCloneRoute(current); const themeStore = useThemeConfig(); const { isTabs } = storeToRefs(themeStore); const store = useRoutesConfigStore(pinia); @@ -50,6 +50,21 @@ export const currentlyRoute = (current: any) => { store.setRouteNames(route.name); // 缓存路由name }; +/** + * 深拷贝路由,切断与原路由的联系,防止路由参数污染 + * @param route 当前路由 + * @returns 深拷贝后的路由 + */ +export const deepCloneRoute = (route: any) => { + return deepClone({ + path: route.path, + name: route.name, + meta: route.meta, + query: route.query, + params: route.params + }); +}; + /** * 模块替换,深层递归,对所有的路由中符合条件的模块进行转换 * @param {array} tree 过滤角色权限后的树