fix(测试跟踪): 编辑用例页面切换项目无法跳转

--bug=1022821 --user=陈建星 【测试跟踪】功能用例,在编辑页面通过左上角的下拉列表切换项目失败 https://www.tapd.cn/55049933/s/1347922
This commit is contained in:
chenjianxing 2023-03-10 10:33:35 +08:00 committed by jianxing
parent 0ae8294305
commit 96b9ae1e38
3 changed files with 9 additions and 8 deletions

View File

@ -30,7 +30,7 @@ import {fullScreenLoading, stopFullScreenLoading} from "../../utils";
import {getCurrentProjectID, getCurrentUser, getCurrentUserId, getCurrentWorkspaceId} from "../../utils/token"; import {getCurrentProjectID, getCurrentUser, getCurrentUserId, getCurrentWorkspaceId} from "../../utils/token";
import {hasPermissions} from "../../utils/permission"; import {hasPermissions} from "../../utils/permission";
import {getUserProjectList, switchProject} from "../../api/project"; import {getUserProjectList, switchProject} from "../../api/project";
import {useUserStore} from "@/store"; import {useUserStore, useCommonStore} from "@/store";
import {getDefaultSecondLevelMenu} from "../../router"; import {getDefaultSecondLevelMenu} from "../../router";
export default { export default {
@ -42,6 +42,7 @@ export default {
created() { created() {
this.init(); this.init();
this.userStore = useUserStore(); this.userStore = useUserStore();
this.commonStore = useCommonStore();
}, },
inject: [ inject: [
'reload', 'reload',
@ -150,6 +151,7 @@ export default {
switchProject({id: this.userId, lastProjectId: projectId}) switchProject({id: this.userId, lastProjectId: projectId})
.then(response => { .then(response => {
this.userStore.switchProject(response); this.userStore.switchProject(response);
this.commonStore.projectChangeFlag = true;
this.$EventBus.$emit('projectChange'); this.$EventBus.$emit('projectChange');
this.changeProjectName(projectId); this.changeProjectName(projectId);
// //

View File

@ -2,6 +2,7 @@ export default {
id: "commonStore", id: "commonStore",
state: () => ({ state: () => ({
fileDownloadList: [], // 文件下载进度列表, fileDownloadList: [], // 文件下载进度列表,
projectChangeFlag: false
}), }),
persist: false, persist: false,
getters: {}, getters: {},

View File

@ -365,7 +365,7 @@ import TestCaseBaseInfo from "@/business/case/components/TestCaseBaseInfo";
import MsContainer from "metersphere-frontend/src/components/MsContainer"; import MsContainer from "metersphere-frontend/src/components/MsContainer";
import MsAsideContainer from "metersphere-frontend/src/components/MsAsideContainer"; import MsAsideContainer from "metersphere-frontend/src/components/MsAsideContainer";
import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer"; import MsMainContainer from "metersphere-frontend/src/components/MsMainContainer";
import { useStore } from "@/store"; import {useCommonStore, useStore} from "@/store";
import { getProjectApplicationConfig } from "@/api/project-application"; import { getProjectApplicationConfig } from "@/api/project-application";
import { import {
deleteTestCaseVersion, deleteTestCaseVersion,
@ -400,6 +400,7 @@ import CaseDiffSideViewer from "./case/diff/CaseDiffSideViewer";
import TestCaseEditNameView from "@/business/case/components/head/TestCaseEditNameView"; import TestCaseEditNameView from "@/business/case/components/head/TestCaseEditNameView";
const store = useStore(); const store = useStore();
const commonStore = useCommonStore();
export default { export default {
name: "TestCaseEdit", name: "TestCaseEdit",
components: { components: {
@ -709,10 +710,6 @@ export default {
this.loadTestCase(); this.loadTestCase();
}, },
created(){ created(){
this.$EventBus.$on('projectChange', () => {
localStorage.setItem('projectChangeFlag', 'true');
this.$router.push('/track/case/all');
});
this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent); this.$EventBus.$on("handleSaveCaseWithEvent", this.handleSaveCaseWithEvent);
this.setInitialVal(); this.setInitialVal();
}, },
@ -758,8 +755,9 @@ export default {
}, },
async loadTestCase() { async loadTestCase() {
if (localStorage.getItem('projectChangeFlag')) { if (commonStore.projectChangeFlag) {
localStorage.removeItem('projectChangeFlag'); commonStore.projectChangeFlag = false;
this.$router.push('/track/case/all');
return; return;
} }