From 1bf55a4a5459f4168caa686ee18e5fbaed221d3d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Mon, 27 Mar 2023 15:33:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE=E4=BB=A5?= =?UTF-8?q?=E5=8F=8A=E6=92=AD=E6=94=BE=E8=AE=B0=E5=BD=95=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/compenents/hour.tsx | 10 ++++-- src/pages/course/index.tsx | 52 ++++++++++++++++++++++------ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/src/pages/course/compenents/hour.tsx b/src/pages/course/compenents/hour.tsx index 64ecdc5..9e2f918 100644 --- a/src/pages/course/compenents/hour.tsx +++ b/src/pages/course/compenents/hour.tsx @@ -11,6 +11,7 @@ interface PropInterface { duration: number; record: any; progress: number; + onChange: () => void; } export const HourCompenent: React.FC = ({ @@ -20,6 +21,7 @@ export const HourCompenent: React.FC = ({ duration, record, progress, + onChange, }) => { // const navigate = useNavigate(); const [visible, setVisible] = useState(false); @@ -30,7 +32,10 @@ export const HourCompenent: React.FC = ({ id={id} title={title} open={visible} - onCancel={() => setVisible(false)} + onCancel={() => { + setVisible(false); + onChange(); + }} >
@@ -54,7 +59,8 @@ export const HourCompenent: React.FC = ({ {progress !== 0 && ( <>
- 上次学习到{durationFormat(Number(record.duration || 0))} + 上次学习到 + {durationFormat(Number(record.finished_duration || 0))}
{
- `${percent}%`} - /> + {JSON.stringify(learnRecord) === "{}" && + JSON.stringify(learnHourRecord) === "{}" && ( + `${percent}%`} + /> + )} + {JSON.stringify(learnRecord) === "{}" && + JSON.stringify(learnHourRecord) !== "{}" && ( + `${percent}%`} + /> + )} + {JSON.stringify(learnRecord) !== "{}" && + JSON.stringify(learnHourRecord) !== "{}" && ( + `${percent}%`} + /> + )} {course.short_desc && (
{course.short_desc}
@@ -99,7 +126,11 @@ const CoursePage = () => { title={item.title} record={learnHourRecord[item.id]} duration={item.duration} - progress={learnHourRecord[item.id].progress} + progress={ + (learnHourRecord[item.id].finished_duration * 100) / + learnHourRecord[item.id].total_duration + } + onChange={() => getDetail()} > )} {!learnHourRecord[item.id] && ( @@ -110,6 +141,7 @@ const CoursePage = () => { record={null} duration={item.duration} progress={0} + onChange={() => getDetail()} > )}