fix: 修复切换项目后显示上一个项目资源的问题

--bug=1012979 --user=刘瑞斌 [通用功能]github#13235切换项目后还会显示之前项目已打开的报告 https://www.tapd.cn/55049933/s/1152377

Closes #13235
This commit is contained in:
CaptainB 2022-05-04 20:09:52 +08:00 committed by 刘瑞斌
parent 3c046c7594
commit 15ae96e5a8
3 changed files with 28 additions and 4 deletions

View File

@ -540,13 +540,19 @@ export default {
},
exportReportReset() {
this.$router.go(0);
}
},
handleProjectChange() {
this.$router.push('/api/automation/report');
},
},
created() {
this.getReport();
this.$EventBus.$on('projectChange', this.handleProjectChange);
},
destroyed () {
this.$EventBus.$off('projectChange', this.handleProjectChange);
},
computed: {
path() {
return "/api/test/edit?id=" + this.report.testId;

View File

@ -491,7 +491,12 @@ export default {
}
}
localStorage.setItem("reportRefreshTime", this.refreshTime);
}
},
handleProjectChange() {
if (this.$route.name === 'perReportView') {
this.$router.push('/performance/report/all');
}
},
},
created() {
this.isReadOnly = !hasPermission('PROJECT_PERFORMANCE_REPORT:READ+DELETE');
@ -500,6 +505,10 @@ export default {
this.reportId = this.perReportId;
}
this.getReport(this.reportId);
this.$EventBus.$on('projectChange', this.handleProjectChange);
},
destroyed () {
this.$EventBus.$off('projectChange', this.handleProjectChange);
},
watch: {
'$route'(to) {

View File

@ -184,6 +184,10 @@ export default {
if (hasLicense()) {
this.getVersionHistory();
}
this.$EventBus.$on('projectChange', this.handleProjectChange);
},
destroyed () {
this.$EventBus.$off('projectChange', this.handleProjectChange);
},
mounted() {
this.importAPITest();
@ -619,7 +623,12 @@ export default {
}
}
});
}
},
handleProjectChange() {
if (this.$route.name === 'editPerTest') {
this.$router.push('/performance/test/all');
}
},
}
};
</script>