Skip to content

Commit

Permalink
Catch chart axios errors
Browse files Browse the repository at this point in the history
  • Loading branch information
OuOu2021 committed Nov 15, 2023
1 parent 002dd6e commit 191c1b5
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
31 changes: 21 additions & 10 deletions src/components/Chart/Chart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -497,6 +497,9 @@ const fetchData = async () => {
barChartData[task] = concatDate(res.data as number[]);
barCharts[task].hideLoading();
barCharts[task].setOption(getBarChartOption(task));
})
.catch(() => {
barCharts[task].hideLoading();
}),
);
}
Expand All @@ -515,6 +518,9 @@ const fetchData = async () => {
heatmapData.value = concatDate(res.data);
heatmap.hideLoading();
heatmap.setOption(getHeatmapOption());
})
.catch(() => {
heatmap.hideLoading();
}),
);
Expand All @@ -525,16 +531,21 @@ const fetchData = async () => {
else showProgress.value = false;
for (const [index, dict] of dictsToGenerateProgress.entries()) {
promises.push(
axios.get(`/api/dicts/${dict.id}/progress`).then((res) => {
const data = res.data as progressVo;
progressData.value.name[index] = dict.name;
progressData.value.mastered[index] = data.mastered;
progressData.value.sum[index] = data.sum;
progressData.value.studied[index] = data.studied;
if (dict.name.includes("For Test")) showProgress.value = false;
progress.hideLoading();
progress.setOption(getProgressOption());
}),
axios
.get(`/api/dicts/${dict.id}/progress`)
.then((res) => {
const data = res.data as progressVo;
progressData.value.name[index] = dict.name;
progressData.value.mastered[index] = data.mastered;
progressData.value.sum[index] = data.sum;
progressData.value.studied[index] = data.studied;
if (dict.name.includes("For Test")) showProgress.value = false;
progress.hideLoading();
progress.setOption(getProgressOption());
})
.catch(() => {
progress.hideLoading();
}),
);
}
await Promise.all(promises);
Expand Down
8 changes: 5 additions & 3 deletions src/components/QwertyMode.vue
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ function inputDone(isCorrect: boolean): void {
function finish(): void {
isAllFinished.value = true;
stopwatch.pause();
axios.post(`/api/dicts/${props.dictId}/qwerty`, {num: props.num} ).catch((error) => {
throwError(error, "learn.errUploadRec", t);
});;
axios
.post(`/api/dicts/${props.dictId}/qwerty`, { num: props.num })
.catch((error) => {
throwError(error, "learn.errUploadRec", t);
});
}
function goBack(): void {
Expand Down

0 comments on commit 191c1b5

Please sign in to comment.