From 96b9ae1e38f725c767263a53bb3dd20314bca17c Mon Sep 17 00:00:00 2001 From: chenjianxing Date: Fri, 10 Mar 2023 10:33:35 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA):=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E7=94=A8=E4=BE=8B=E9=A1=B5=E9=9D=A2=E5=88=87?= =?UTF-8?q?=E6=8D=A2=E9=A1=B9=E7=9B=AE=E6=97=A0=E6=B3=95=E8=B7=B3=E8=BD=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1022821 --user=陈建星 【测试跟踪】功能用例,在编辑页面通过左上角的下拉列表切换项目失败 https://www.tapd.cn/55049933/s/1347922 --- .../src/components/head/ProjectSearchList.vue | 4 +++- .../sdk-parent/frontend/src/store/modules/common.js | 1 + .../src/business/case/components/TestCaseEdit.vue | 12 +++++------- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue b/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue index 6181e5154c..44ab7851cb 100644 --- a/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue +++ b/framework/sdk-parent/frontend/src/components/head/ProjectSearchList.vue @@ -30,7 +30,7 @@ import {fullScreenLoading, stopFullScreenLoading} from "../../utils"; import {getCurrentProjectID, getCurrentUser, getCurrentUserId, getCurrentWorkspaceId} from "../../utils/token"; import {hasPermissions} from "../../utils/permission"; import {getUserProjectList, switchProject} from "../../api/project"; -import {useUserStore} from "@/store"; +import {useUserStore, useCommonStore} from "@/store"; import {getDefaultSecondLevelMenu} from "../../router"; export default { @@ -42,6 +42,7 @@ export default { created() { this.init(); this.userStore = useUserStore(); + this.commonStore = useCommonStore(); }, inject: [ 'reload', @@ -150,6 +151,7 @@ export default { switchProject({id: this.userId, lastProjectId: projectId}) .then(response => { this.userStore.switchProject(response); + this.commonStore.projectChangeFlag = true; this.$EventBus.$emit('projectChange'); this.changeProjectName(projectId); // 刷新路由 diff --git a/framework/sdk-parent/frontend/src/store/modules/common.js b/framework/sdk-parent/frontend/src/store/modules/common.js index cb54cf6d0e..76256703c9 100644 --- a/framework/sdk-parent/frontend/src/store/modules/common.js +++ b/framework/sdk-parent/frontend/src/store/modules/common.js @@ -2,6 +2,7 @@ export default { id: "commonStore", state: () => ({ fileDownloadList: [], // 文件下载进度列表, + projectChangeFlag: false }), persist: false, getters: {}, diff --git a/test-track/frontend/src/business/case/components/TestCaseEdit.vue b/test-track/frontend/src/business/case/components/TestCaseEdit.vue index d645a1b746..1dd61b26b7 100644 --- a/test-track/frontend/src/business/case/components/TestCaseEdit.vue +++ b/test-track/frontend/src/business/case/components/TestCaseEdit.vue @@ -365,7 +365,7 @@ import TestCaseBaseInfo from "@/business/case/components/TestCaseBaseInfo"; import MsContainer from "metersphere-frontend/src/components/MsContainer"; import MsAsideContainer from "metersphere-frontend/src/components/MsAsideContainer"; import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer"; -import { useStore } from "@/store"; +import {useCommonStore, useStore} from "@/store"; import { getProjectApplicationConfig } from "@/api/project-application"; import { deleteTestCaseVersion, @@ -400,6 +400,7 @@ import CaseDiffSideViewer from "./case/diff/CaseDiffSideViewer"; import TestCaseEditNameView from "@/business/case/components/head/TestCaseEditNameView"; const store = useStore(); +const commonStore = useCommonStore(); export default { name: "TestCaseEdit", components: { @@ -709,10 +710,6 @@ export default { this.loadTestCase(); }, created(){ - this.$EventBus.$on('projectChange', () => { - localStorage.setItem('projectChangeFlag', 'true'); - this.$router.push('/track/case/all'); - }); this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent); this.setInitialVal(); }, @@ -758,8 +755,9 @@ export default { }, async loadTestCase() { - if (localStorage.getItem('projectChangeFlag')) { - localStorage.removeItem('projectChangeFlag'); + if (commonStore.projectChangeFlag) { + commonStore.projectChangeFlag = false; + this.$router.push('/track/case/all'); return; }