mirror of
https://github.com/PlayEdu/h5.git
synced 2025-07-25 19:49:43 +08:00
视频详情加载优化
This commit is contained in:
parent
4f3759938f
commit
beb2bd6a89
@ -3,7 +3,7 @@ import { Image, ProgressCircle } from "antd-mobile";
|
|||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
import { useNavigate, useParams } from "react-router-dom";
|
import { useNavigate, useParams } from "react-router-dom";
|
||||||
import backIcon from "../../assets/images/commen/icon-back-n.png";
|
import backIcon from "../../assets/images/commen/icon-back-n.png";
|
||||||
import { course as Course } from "../../api/index";
|
import { course as vod } from "../../api/index";
|
||||||
import { Empty } from "../../components";
|
import { Empty } from "../../components";
|
||||||
import { HourCompenent } from "./compenents/hour";
|
import { HourCompenent } from "./compenents/hour";
|
||||||
|
|
||||||
@ -18,33 +18,24 @@ const CoursePage = () => {
|
|||||||
const [learnHourRecord, setLearnHourRecord] = useState<any>({});
|
const [learnHourRecord, setLearnHourRecord] = useState<any>({});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (courseId !== undefined) {
|
if (courseId) {
|
||||||
getDetail();
|
getDetail(Number(courseId));
|
||||||
}
|
}
|
||||||
}, [courseId]);
|
}, [courseId]);
|
||||||
|
|
||||||
const getDetail = () => {
|
const getDetail = (cid: number) => {
|
||||||
if (loading) {
|
vod.detail(cid).then((res: any) => {
|
||||||
return;
|
document.title = res.data.course.title;
|
||||||
}
|
setCourse(res.data.course);
|
||||||
setLoading(true);
|
setChapters(res.data.chapters);
|
||||||
Course.detail(Number(courseId))
|
setHours(res.data.hours);
|
||||||
.then((res: any) => {
|
if (res.data.learn_record) {
|
||||||
document.title = res.data.course.title;
|
setLearnRecord(res.data.learn_record);
|
||||||
setCourse(res.data.course);
|
}
|
||||||
setChapters(res.data.chapters);
|
if (res.data.learn_hour_records) {
|
||||||
setHours(res.data.hours);
|
setLearnHourRecord(res.data.learn_hour_records);
|
||||||
if (res.data.learn_record) {
|
}
|
||||||
setLearnRecord(res.data.learn_record);
|
});
|
||||||
}
|
|
||||||
if (res.data.learn_hour_records) {
|
|
||||||
setLearnHourRecord(res.data.learn_hour_records);
|
|
||||||
}
|
|
||||||
setLoading(false);
|
|
||||||
})
|
|
||||||
.catch((e) => {
|
|
||||||
setLoading(false);
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const playVideo = (cid: number, id: number) => {
|
const playVideo = (cid: number, id: number) => {
|
||||||
|
@ -37,10 +37,8 @@ const CoursePlayPage = () => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
window.player && window.player.destroy();
|
window.player && window.player.destroy();
|
||||||
if (params.courseId && params.hourId) {
|
getCourse();
|
||||||
getCourse();
|
getDetail();
|
||||||
getDetail();
|
|
||||||
}
|
|
||||||
}, [params.courseId, params.hourId]);
|
}, [params.courseId, params.hourId]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -242,7 +240,10 @@ const CoursePlayPage = () => {
|
|||||||
<Image
|
<Image
|
||||||
className={styles["back-icon"]}
|
className={styles["back-icon"]}
|
||||||
src={backIcon}
|
src={backIcon}
|
||||||
onClick={() => navigate(-1)}
|
onClick={() => {
|
||||||
|
window.player && window.player.destroy();
|
||||||
|
navigate(-1);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
<div className={styles["video-box"]}>
|
<div className={styles["video-box"]}>
|
||||||
<div className="play-box" id="meedu-player-container"></div>
|
<div className="play-box" id="meedu-player-container"></div>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user