Merge pull request #1 from PlayEdu/dev

Dev
This commit is contained in:
Teng 2023-07-05 10:53:40 +08:00 committed by GitHub
commit 02254ab9e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 63 additions and 44 deletions

View File

@ -4,6 +4,7 @@ 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 vod } from "../../api/index"; import { course as vod } from "../../api/index";
import { isEmptyObject } from "../../utils/index";
import { Empty } from "../../components"; import { Empty } from "../../components";
import { HourCompenent } from "./compenents/hour"; import { HourCompenent } from "./compenents/hour";
@ -66,7 +67,7 @@ const CoursePage = () => {
useEffect(() => { useEffect(() => {
if (learnRecord?.progress) { if (learnRecord?.progress) {
setUserCourseProgress(Math.floor(learnRecord.progress / 100)); setUserCourseProgress(Math.floor(learnRecord.progress / 100));
} else if (learnHourRecord) { } else if (learnHourRecord && !isEmptyObject(learnHourRecord)) {
setUserCourseProgress(1); setUserCourseProgress(1);
} else { } else {
setUserCourseProgress(0); setUserCourseProgress(0);
@ -87,7 +88,7 @@ const CoursePage = () => {
/> />
</div> </div>
<div className={styles["top-content"]}> <div className={styles["top-content"]}>
<div className={styles["title"]}>{course?.title}</div> <div className={styles["title"]}>{course?.title + ""}</div>
<div className={styles["info-content"]}> <div className={styles["info-content"]}>
<div className={styles["info"]}> <div className={styles["info"]}>
<div className={styles["record"]}> <div className={styles["record"]}>

View File

@ -44,7 +44,6 @@ const CoursePlayPage = () => {
const totalRef = useRef(0); const totalRef = useRef(0);
useEffect(() => { useEffect(() => {
window.player && window.player.destroy();
getCourse(); getCourse();
getDetail(); getDetail();
}, [params.courseId, params.hourId]); }, [params.courseId, params.hourId]);
@ -129,6 +128,7 @@ const CoursePlayPage = () => {
const getVideoUrl = (data: any) => { const getVideoUrl = (data: any) => {
Course.playUrl(Number(params.courseId), Number(params.hourId)).then( Course.playUrl(Number(params.courseId), Number(params.hourId)).then(
(res: any) => { (res: any) => {
window.player && window.player.destroy();
setPlayUrl(res.data.url); setPlayUrl(res.data.url);
initDPlayer(res.data.url, 0, data); initDPlayer(res.data.url, 0, data);
} }
@ -236,7 +236,6 @@ const CoursePlayPage = () => {
}; };
const playVideo = (cid: number, id: number) => { const playVideo = (cid: number, id: number) => {
window.player && window.player.destroy();
navigate(`/course/${cid}/hour/${id}`, { replace: true }); navigate(`/course/${cid}/hour/${id}`, { replace: true });
}; };

View File

@ -7,6 +7,7 @@ import { useSelector } from "react-redux";
import { useNavigate, useLocation } from "react-router-dom"; import { useNavigate, useLocation } from "react-router-dom";
import { Footer, TabBarFooter, Empty } from "../../components"; import { Footer, TabBarFooter, Empty } from "../../components";
import { CoursesModel } from "./compenents/courses-model"; import { CoursesModel } from "./compenents/courses-model";
import { isEmptyObject } from "../../utils/index";
type LocalUserLearnHourRecordModel = { type LocalUserLearnHourRecordModel = {
[key: number]: UserLearnHourRecordModel; [key: number]: UserLearnHourRecordModel;
@ -74,7 +75,7 @@ const IndexPage = () => {
return; return;
} }
getData(); getData();
}, [tabKey, currentDepId, categoryId]); }, [currentDepId, categoryId]);
const getData = () => { const getData = () => {
setLoading(true); setLoading(true);
@ -127,7 +128,7 @@ const IndexPage = () => {
const getParams = () => { const getParams = () => {
user.coursesCategories().then((res: any) => { user.coursesCategories().then((res: any) => {
const categories = res.data.categories; const categories = res.data.categories;
if (JSON.stringify(categories) !== "{}") { if (!isEmptyObject(categories)) {
const new_arr: any[] = checkArr(categories, 0); const new_arr: any[] = checkArr(categories, 0);
new_arr.unshift({ new_arr.unshift({
key: 0, key: 0,
@ -204,9 +205,16 @@ const IndexPage = () => {
activeKey={tabKey} activeKey={tabKey}
onChange={(key: any) => { onChange={(key: any) => {
setTabKey(key); setTabKey(key);
navigate( setTimeout(() => {
"/?cid=" + categoryId + "&catName=" + categoryText + "&tab=" + key navigate(
); "/?cid=" +
categoryId +
"&catName=" +
categoryText +
"&tab=" +
key
);
}, 250);
}} }}
style={{ style={{
"--fixed-active-line-width": "20px", "--fixed-active-line-width": "20px",

View File

@ -4,6 +4,7 @@
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;
margin-bottom: 20px;
.info { .info {
flex: 1; flex: 1;
height: 75px; height: 75px;

View File

@ -91,7 +91,6 @@ export const CoursesModel: React.FC<PropInterface> = ({
</div> </div>
</div> </div>
</div> </div>
<div className="sp-line"></div>
</> </>
); );
}; };

View File

@ -13,14 +13,14 @@
float: left; float: left;
height: auto; height: auto;
box-sizing: border-box; box-sizing: border-box;
padding: 0px 20px 80px 20px; padding: 0px 20px 60px 20px;
text-align: left; text-align: left;
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
padding-bottom: calc( padding-bottom: calc(
80px + constant(safe-area-inset-bottom) 80px + constant(safe-area-inset-bottom)
); /* 兼容iOS 11.0 - 11.2 */ ); /* 兼容iOS 11.0 - 11.2 */
padding-bottom: calc(80px + env(safe-area-inset-bottom)); /* 兼容iOS 11.2+ */ padding-bottom: calc(60px + env(safe-area-inset-bottom)); /* 兼容iOS 11.2+ */
.label { .label {
width: 100%; width: 100%;
height: 40px; height: 40px;

View File

@ -21,37 +21,41 @@ const StudyPage = () => {
}, []); }, []);
const getCourses = () => { const getCourses = () => {
if (loading) {
return;
}
setLoading(true); setLoading(true);
course.latestLearn().then((res: any) => { course
let data = res.data; .latestLearn()
let today: CourseModel[] = []; .then((res: any) => {
let yesterday: CourseModel[] = []; let data = res.data;
let box: CourseModel[] = []; let today: CourseModel[] = [];
if (data && data.length > 0) { let yesterday: CourseModel[] = [];
data.map((item: any) => { let box: CourseModel[] = [];
if ( if (data && data.length > 0) {
item.hour_record && data.map((item: any) => {
moment(item.hour_record.updated_at).isSame(moment(), "day") let time = moment(item.hour_record.updated_at)
) { .utcOffset(0)
today.push(item); .format("YYYY-MM-DD HH:mm:ss");
} else if ( if (moment(time).isSame(moment(), "day")) {
item.hour_record && today.push(item);
moment(item.hour_record.updated_at).isSame( } else if (
moment().subtract(1, "day"), moment(time).isSame(moment().subtract(1, "day"), "day")
"day" ) {
) yesterday.push(item);
) { } else {
yesterday.push(item); box.push(item);
} else { }
box.push(item); });
} }
setTodayCourses(today); setTodayCourses(today);
setYesterdayCourses(yesterday); setYesterdayCourses(yesterday);
setCourses(box); setCourses(box);
}); setLoading(false);
} })
setLoading(false); .catch((e) => {
}); setLoading(false);
});
}; };
return ( return (
@ -76,7 +80,10 @@ const StudyPage = () => {
</div> </div>
</div> </div>
))} ))}
{!loading && courses.length === 0 && <Empty></Empty>} {!loading &&
courses.length === 0 &&
todayCourses.length === 0 &&
yesterdayCourses.length === 0 && <Empty></Empty>}
{!loading && ( {!loading && (
<> <>
{todayCourses.length > 0 && ( {todayCourses.length > 0 && (

View File

@ -13,7 +13,7 @@ export function clearToken() {
} }
export function dateFormat(dateStr: string) { export function dateFormat(dateStr: string) {
return moment(dateStr).format("YYYY-MM-DD HH:mm"); return moment(dateStr).utcOffset(0).format("YYYY-MM-DD HH:mm");
} }
export function getHost() { export function getHost() {
@ -76,3 +76,7 @@ export function isMobile() {
); );
return flag; return flag;
} }
export function isEmptyObject(obj: Object) {
return Object.keys(obj).length === 0;
}