From 0074e5978f6ecd94ea6f808c922063f4397fdb2d Mon Sep 17 00:00:00 2001 From: yanlongqi Date: Tue, 2 Dec 2025 00:52:40 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=A6=96=E9=A1=B5=E6=AF=8F?= =?UTF-8?q?=E6=97=A5=E4=B8=80=E7=BB=83=E5=BF=AB=E6=8D=B7=E5=85=A5=E5=8F=A3?= =?UTF-8?q?=E5=B9=B6=E4=BF=AE=E5=A4=8DAPI=E8=B0=83=E7=94=A8=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 主要改动: 1. 修复每日一练排行榜API调用bug(request.get替代request) 2. 在首页快速开始区域添加每日一练快捷入口卡片 3. 实现点击卡片直接跳转到今日每日一练答题页面 4. 添加每日一练状态检测和错误提示 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- web/src/api/exam.ts | 2 +- web/src/pages/Home.tsx | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) diff --git a/web/src/api/exam.ts b/web/src/api/exam.ts index 887a5cf..224df15 100644 --- a/web/src/api/exam.ts +++ b/web/src/api/exam.ts @@ -97,7 +97,7 @@ export const submitExam = (examId: number, data: SubmitExamRequest) => { // 获取每日一练排行榜 export const getDailyExamRanking = () => { - return request<{ + return request.get<{ success: boolean data: { exam_id: number diff --git a/web/src/pages/Home.tsx b/web/src/pages/Home.tsx index bb26ec4..34c4020 100644 --- a/web/src/pages/Home.tsx +++ b/web/src/pages/Home.tsx @@ -604,6 +604,52 @@ const Home: React.FC = () => { 快速开始 + {/* 每日一练快捷入口 */} + + { + // 检查今日每日一练是否存在 + if (dailyExamRanking.exam_id) { + try { + // 调用开始考试API,创建考试记录 + const res = await examApi.startExam(dailyExamRanking.exam_id) + if (res.success && res.data) { + // 跳转到考试答题页面(注意路由是 /taking 不是 /take) + navigate(`/exam/${dailyExamRanking.exam_id}/taking/${res.data.record_id}`) + } else { + message.error(res.message || '开始考试失败') + } + } catch (error) { + console.error('开始每日一练失败:', error) + message.error('开始考试失败,请稍后再试') + } + } else { + message.warning('今日每日一练尚未生成,请稍后再试') + } + }} + > + +
+ +
+
+ 每日一练 + + {dailyExamRanking.exam_title ? dailyExamRanking.exam_title : '今日练习,冲刺高分'} + +
+
+
+ +