视频详情加载优化

This commit is contained in:
禺狨 2023-07-04 09:38:32 +08:00
parent 21f84323c2
commit 4f3759938f
2 changed files with 14 additions and 7 deletions

View File

@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import { Image, ProgressCircle, SpinLoading } from "antd-mobile";
import { Image, ProgressCircle } from "antd-mobile";
import styles from "./index.module.scss";
import { useNavigate, useParams } from "react-router-dom";
import backIcon from "../../assets/images/commen/icon-back-n.png";
@ -8,7 +8,7 @@ import { Empty } from "../../components";
import { HourCompenent } from "./compenents/hour";
const CoursePage = () => {
const params = useParams();
const { courseId } = useParams();
const navigate = useNavigate();
const [loading, setLoading] = useState<boolean>(false);
const [course, setCourse] = useState<any>({});
@ -18,12 +18,17 @@ const CoursePage = () => {
const [learnHourRecord, setLearnHourRecord] = useState<any>({});
useEffect(() => {
getDetail();
}, [params.courseId]);
if (courseId !== undefined) {
getDetail();
}
}, [courseId]);
const getDetail = () => {
if (loading) {
return;
}
setLoading(true);
Course.detail(Number(params.courseId))
Course.detail(Number(courseId))
.then((res: any) => {
document.title = res.data.course.title;
setCourse(res.data.course);

View File

@ -37,8 +37,10 @@ const CoursePlayPage = () => {
useEffect(() => {
window.player && window.player.destroy();
getCourse();
getDetail();
if (params.courseId && params.hourId) {
getCourse();
getDetail();
}
}, [params.courseId, params.hourId]);
useEffect(() => {