From ffe0451e3f91ebd493a83cb3d7fbbd5d5918644b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 29 Mar 2023 10:53:12 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E5=AD=A6=E4=B9=A0=E8=BF=9B?= =?UTF-8?q?=E5=BA=A6=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.tsx | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 47e0868..c03056e 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -17,6 +17,7 @@ const IndexPage = () => { const [tabKey, setTabKey] = useState(0); const [coursesList, setCoursesList] = useState([]); const [learnCourseRecords, setLearnCourseRecords] = useState({}); + const [learnCourseHourCount, setLearnCourseHourCount] = useState({}); const [stats, setStats] = useState({}); const departments = useSelector( @@ -36,6 +37,7 @@ const IndexPage = () => { const records = res.data.learn_course_records; setStats(res.data.stats); setLearnCourseRecords(records); + setLearnCourseHourCount(res.data.user_course_hour_count); if (tabKey === 0) { setCoursesList(res.data.courses); } else if (tabKey === 1) { @@ -271,15 +273,28 @@ const IndexPage = () => { progress={learnCourseRecords[item.id].progress / 100} > )} - {!learnCourseRecords[item.id] && ( - - )} + + {!learnCourseRecords[item.id] && + learnCourseHourCount[item.id] && + learnCourseHourCount[item.id] > 0 && ( + + )} + {!learnCourseRecords[item.id] && + !learnCourseHourCount[item.id] && ( + + )} ))}