Skip to content

Commit

Permalink
Merge pull request #35 from sapphi-red/fix/switch-tabs-no-content-change
Browse files Browse the repository at this point in the history
同じ種類のタブ同士を切り替えたときに内容が更新されていなかった
  • Loading branch information
kaz authored Nov 24, 2023
2 parents 7a39730 + 9143040 commit 8e867dc
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 14 deletions.
14 changes: 11 additions & 3 deletions view/src/components/HttpLogEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ export default defineComponent({
tsv: "",
};
},
async beforeCreate() {
const resp = await fetch(`/api/httplog/${this.$route.params.id}`);
this.tsv = await resp.text();
async created() {
await this.updateTsv(this.$route.params.id);
},
async beforeRouteUpdate(route) {
await this.updateTsv(route.params.id);
},
methods: {
async updateTsv(id: string | string[]) {
const resp = await fetch(`/api/httplog/${id}`);
this.tsv = await resp.text();
},
},
});
</script>
24 changes: 16 additions & 8 deletions view/src/components/MemoEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ export default defineComponent({
memo: { Text: null },
};
},
async beforeCreate() {
try {
const resp = await fetch(`/api/memo/${this.$route.params.id}`);
this.memo = await resp.json();
} catch (e) {
this.summary = `Error: ${e instanceof Error ? e.message : e}`;
}
async created() {
await this.updateMemo(this.$route.params.id);
},
async beforeRouteUpdate(route) {
await this.updateMemo(route.params.id);
},
methods: {
async updateMemo(id: string | string[]) {
try {
const resp = await fetch(`/api/memo/${id}`);
this.memo = await resp.json();
} catch (e) {
this.summary = `Error: ${e instanceof Error ? e.message : e}`;
}
},
},
});
</script>
</script>
14 changes: 11 additions & 3 deletions view/src/components/SlowLogEntry.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ export default defineComponent({
tsv: "",
};
},
async beforeCreate() {
const resp = await fetch(`/api/slowlog/${this.$route.params.id}`);
this.tsv = await resp.text();
async created() {
await this.updateTsv(this.$route.params.id);
},
async beforeRouteUpdate(route) {
await this.updateTsv(route.params.id);
},
methods: {
async updateTsv(id: string | string[]) {
const resp = await fetch(`/api/slowlog/${id}`);
this.tsv = await resp.text();
},
},
});
</script>

0 comments on commit 8e867dc

Please sign in to comment.