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() { exportReportReset() {
this.$router.go(0); this.$router.go(0);
} },
handleProjectChange() {
this.$router.push('/api/automation/report');
},
}, },
created() { created() {
this.getReport(); this.getReport();
this.$EventBus.$on('projectChange', this.handleProjectChange);
},
destroyed () {
this.$EventBus.$off('projectChange', this.handleProjectChange);
}, },
computed: { computed: {
path() { path() {
return "/api/test/edit?id=" + this.report.testId; return "/api/test/edit?id=" + this.report.testId;

View File

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

View File

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