|
|
|
@ -1,4 +1,4 @@ |
|
|
|
|
import {FC, useEffect, useState} from "react"; |
|
|
|
|
import {FC, useCallback, useEffect, useState} from "react"; |
|
|
|
|
import HVideo from "@/components/video/video"; |
|
|
|
|
import {curriculum, HourPlayData} from "@/api"; |
|
|
|
|
import {Profile} from '@/store' |
|
|
|
@ -13,11 +13,9 @@ interface Props { |
|
|
|
|
curEnd: (test?: boolean) => void |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Course: FC<Props> = ({id, courseId, preview, curEnd}) => { |
|
|
|
|
const [breakpoints, setBreakpoints] = useState<number[]>([]) // 断点
|
|
|
|
|
const [isFull, setIsFull] = useState(false) |
|
|
|
|
|
|
|
|
|
const [examAll, setExamAll] = useState<Record<number, ShareSubject[]>>([]) // 题库
|
|
|
|
|
const [data, setData] = useState<HourPlayData | null>(null) |
|
|
|
|
const [time, setTime] = useState<number>(0) // 进入断点的时间
|
|
|
|
@ -67,7 +65,8 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}) => { |
|
|
|
|
getData() |
|
|
|
|
}, [id]) |
|
|
|
|
|
|
|
|
|
function examination(result: boolean) { |
|
|
|
|
const examination = useCallback((result: boolean) => { |
|
|
|
|
if (!time) return |
|
|
|
|
const {id: question_id, question_type} = examAll?.[time]?.[0] |
|
|
|
|
curriculum.answerRecord(id, { |
|
|
|
|
is_pass: result, |
|
|
|
@ -77,8 +76,7 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}) => { |
|
|
|
|
question_id |
|
|
|
|
}) |
|
|
|
|
setTime(0) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}, [time]) |
|
|
|
|
|
|
|
|
|
return ( |
|
|
|
|
<> |
|
|
|
@ -88,9 +86,10 @@ const Course: FC<Props> = ({id, courseId, preview, curEnd}) => { |
|
|
|
|
src={data?.url || ''} |
|
|
|
|
onEnded={onEnded} |
|
|
|
|
breakpoint={breakpoints} |
|
|
|
|
onBreakpoint={(time) => setTime(time)} |
|
|
|
|
fullChange={(fullScreen) => setIsFull(fullScreen)} |
|
|
|
|
> |
|
|
|
|
onBreakpoint={(now) => { |
|
|
|
|
time !== now && setTime(now) |
|
|
|
|
}}> |
|
|
|
|
<Single |
|
|
|
|
full={isFull} |
|
|
|
|
examination={examination} |
|
|
|
|