From 61c332e0ebc21a5792d06a1fff9ef3d65777c511 Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Wed, 15 Mar 2023 14:09:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=94=A8=E4=BE=8B=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E5=88=87=E6=8D=A2=E9=A1=B9=E7=9B=AE=E5=A4=B1=E8=B4=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1024449 --user=陈建星 【测试跟踪】功能用例页面-切换项目失败 https://www.tapd.cn/55049933/s/1350390 --- .../src/components/head/ProjectSearchList.vue | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue b/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue index ec538382fa..1a3ecec8f7 100644 --- a/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue +++ b/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue @@ -110,6 +110,7 @@ export default { // 获取有权限的跳转路径 copyRedirectUrl = getDefaultSecondLevelMenu(copyRedirectUrl); if (copyRedirectUrl !== '/') { + copyRedirectUrl = this.rewriteProjectRouteUrl(copyRedirectUrl); this.$router.push(copyRedirectUrl); this.reload(); return; @@ -154,6 +155,46 @@ export default { }); } }, + rewriteProjectRouteUrl(url) { + // 切换项目的时候如果有项目 ID 参数,修改为切换后的项目 ID,模块参数置空 + // url 示例 /track/case/all?projectId=AAA&moduleId=BBB + let urlArray = url.split('?'); + let path = urlArray[0]; // /track/case/all + if (urlArray.length > 1) { + let query = urlArray[1]; + if (!query) { + return path; + } + path += '?'; + // projectId=AAA&moduleId=BBB + let queryParams = query.split('&'); + for (let queryParam of queryParams) { + if (!queryParam) { + break; + } + let kv = queryParam.split('='); + let paramKey = kv[0]; + if (kv.length < 1) { + break; + } + let paramValue = kv[1]; + if (!paramValue) { + continue; + } + if (paramKey === 'projectId') { + paramValue = getCurrentProjectID(); + } else if (paramKey === 'moduleId') { + break; + } + path += paramKey + '=' + paramValue + '&'; + } + } + if (path[path.length - 1] === '&') { + // 去掉末尾 & + return path.substring(0, path.length - 1); + } + return path; + }, change(projectId) { let currentProjectId = getCurrentProjectID(); if (projectId === currentProjectId) {