refactor: 修改 Header 上注册事件的方式

This commit is contained in:
Captain.B 2020-09-03 10:02:51 +08:00
parent 5b750fe55f
commit ec931d038c
3 changed files with 28 additions and 18 deletions

View File

@ -87,13 +87,17 @@ export default {
} }
} }
}, },
methods: {
registerEvents() {
ApiEvent.$on(LIST_CHANGE, () => {
this.$refs.projectRecent.recent();
this.$refs.testRecent.recent();
this.$refs.reportRecent.recent();
});
}
},
mounted() { mounted() {
let self = this; this.registerEvents();
ApiEvent.$on(LIST_CHANGE, () => {
self.$refs.projectRecent.recent();
self.$refs.testRecent.recent();
self.$refs.reportRecent.recent();
});
} }
} }

View File

@ -95,13 +95,17 @@ export default {
} }
} }
}, },
methods: {
registerEvents() {
PerformanceEvent.$on(LIST_CHANGE, () => {
this.$refs.projectRecent.recent();
this.$refs.testRecent.recent();
this.$refs.reportRecent.recent();
});
}
},
mounted() { mounted() {
let self = this; this.registerEvents();
PerformanceEvent.$on(LIST_CHANGE, () => {
self.$refs.projectRecent.recent();
self.$refs.testRecent.recent();
self.$refs.reportRecent.recent();
});
} }
} }

View File

@ -100,12 +100,7 @@ export default {
}, },
mounted() { mounted() {
this.init(); this.init();
let self = this; this.registerEvents();
TrackEvent.$on(LIST_CHANGE, () => {
self.$refs.projectRecent.recent();
self.$refs.planRecent.recent();
self.$refs.caseRecent.recent();
});
}, },
methods: { methods: {
reload() { reload() {
@ -132,6 +127,13 @@ export default {
this.testCaseEditPath = path; this.testCaseEditPath = path;
this.reload(); this.reload();
} }
},
registerEvents() {
TrackEvent.$on(LIST_CHANGE, () => {
this.$refs.projectRecent.recent();
this.$refs.planRecent.recent();
this.$refs.caseRecent.recent();
});
} }
} }
} }