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