Skip to content

Commit 01c36d7

Browse files
committed
feat: 添加提交答案的错误处理和通知功能
1 parent 1aa422b commit 01c36d7

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

app/(root)/survey/[id]/page.tsx

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -94,15 +94,23 @@ export default function SurveyPage({ params }: { params: { id: number } }) {
9494
return;
9595
}
9696

97-
await ScoreApi.finishAnswer(answerId);
97+
try {
98+
await ScoreApi.finishAnswer(answerId);
9899

99-
notifications.show({
100-
title: '提交成功',
101-
message: '试卷已成功提交',
102-
color: 'green',
103-
});
100+
notifications.show({
101+
title: '提交成功',
102+
message: '试卷已成功提交',
103+
color: 'green',
104+
});
104105

105-
router.push(`/survey/${params.id}/completed?fs=true`);
106+
router.push(`/survey/${params.id}/completed?fs=true`);
107+
} catch (error) {
108+
notifications.show({
109+
title: '提交失败',
110+
message: '试卷提交时发生错误,请重试',
111+
color: 'red',
112+
});
113+
}
106114
}
107115

108116
function prevPage() {

0 commit comments

Comments
 (0)