From aa54835a7b835044c179955868f2978cc425f90c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 4 Jul 2023 22:22:32 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E6=9C=80=E8=BF=91=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E9=94=99=E8=AF=AF=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/study/index.tsx | 22 ++++++++-------------- src/utils/index.ts | 2 +- 2 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/pages/study/index.tsx b/src/pages/study/index.tsx index 34b6aa5..aca8264 100644 --- a/src/pages/study/index.tsx +++ b/src/pages/study/index.tsx @@ -29,27 +29,21 @@ const StudyPage = () => { let box: CourseModel[] = []; if (data && data.length > 0) { data.map((item: any) => { - if ( - item.hour_record && - moment(item.hour_record.updated_at).isSame(moment(), "day") - ) { + let time = moment(item.hour_record.updated_at) + .utcOffset(0) + .format("YYYY-MM-DD HH:mm:ss"); + if (moment(time).isSame(moment(), "day")) { today.push(item); - } else if ( - item.hour_record && - moment(item.hour_record.updated_at).isSame( - moment().subtract(1, "day"), - "day" - ) - ) { + } else if (moment(time).isSame(moment().subtract(1, "day"), "day")) { yesterday.push(item); } else { box.push(item); } - setTodayCourses(today); - setYesterdayCourses(yesterday); - setCourses(box); }); } + setTodayCourses(today); + setYesterdayCourses(yesterday); + setCourses(box); setLoading(false); }); }; diff --git a/src/utils/index.ts b/src/utils/index.ts index 9471155..38ba46f 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -13,7 +13,7 @@ export function clearToken() { } 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() { From 2859caf7a50111a9b9d39238aa41c19d48bb8b88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 4 Jul 2023 22:25:00 +0800 Subject: [PATCH 2/9] =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=92=AD=E6=94=BE?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/video.tsx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/pages/course/video.tsx b/src/pages/course/video.tsx index 8f2265d..e540291 100644 --- a/src/pages/course/video.tsx +++ b/src/pages/course/video.tsx @@ -44,7 +44,6 @@ const CoursePlayPage = () => { const totalRef = useRef(0); useEffect(() => { - window.player && window.player.destroy(); getCourse(); getDetail(); }, [params.courseId, params.hourId]); @@ -129,6 +128,7 @@ const CoursePlayPage = () => { const getVideoUrl = (data: any) => { Course.playUrl(Number(params.courseId), Number(params.hourId)).then( (res: any) => { + window.player && window.player.destroy(); setPlayUrl(res.data.url); initDPlayer(res.data.url, 0, data); } @@ -236,7 +236,6 @@ const CoursePlayPage = () => { }; const playVideo = (cid: number, id: number) => { - window.player && window.player.destroy(); navigate(`/course/${cid}/hour/${id}`, { replace: true }); }; From b6902e00bc7b5c47ca1a740a8443dc33e71ad873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Tue, 4 Jul 2023 22:31:19 +0800 Subject: [PATCH 3/9] =?UTF-8?q?=E6=9C=80=E8=BF=91=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/study/compenents/courses-model.module.scss | 1 + src/pages/study/compenents/courses-model.tsx | 1 - src/pages/study/index.module.scss | 4 ++-- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pages/study/compenents/courses-model.module.scss b/src/pages/study/compenents/courses-model.module.scss index 4489140..40bcef5 100644 --- a/src/pages/study/compenents/courses-model.module.scss +++ b/src/pages/study/compenents/courses-model.module.scss @@ -4,6 +4,7 @@ display: flex; flex-direction: row; align-items: center; + margin-bottom: 20px; .info { flex: 1; height: 75px; diff --git a/src/pages/study/compenents/courses-model.tsx b/src/pages/study/compenents/courses-model.tsx index 0a78b6d..a92a6e1 100644 --- a/src/pages/study/compenents/courses-model.tsx +++ b/src/pages/study/compenents/courses-model.tsx @@ -91,7 +91,6 @@ export const CoursesModel: React.FC = ({ -
); }; diff --git a/src/pages/study/index.module.scss b/src/pages/study/index.module.scss index 8b3df06..eaea589 100644 --- a/src/pages/study/index.module.scss +++ b/src/pages/study/index.module.scss @@ -13,14 +13,14 @@ float: left; height: auto; box-sizing: border-box; - padding: 0px 20px 80px 20px; + padding: 0px 20px 60px 20px; text-align: left; overflow-x: hidden; overflow-y: auto; padding-bottom: calc( 80px + constant(safe-area-inset-bottom) ); /* 兼容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 { width: 100%; height: 40px; From dabac610c23885953314024fd760b8343a42aba0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 09:19:17 +0800 Subject: [PATCH 4/9] =?UTF-8?q?=E6=9C=80=E8=BF=91=E5=AD=A6=E4=B9=A0?= =?UTF-8?q?=E5=87=BA=E7=8E=B0=E7=A9=BA=E6=95=B0=E6=8D=AE=E5=92=8C=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E5=90=8C=E6=97=B6=E5=B1=95=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/study/index.tsx | 63 +++++++++++++++++++++++---------------- 1 file changed, 38 insertions(+), 25 deletions(-) diff --git a/src/pages/study/index.tsx b/src/pages/study/index.tsx index aca8264..f327744 100644 --- a/src/pages/study/index.tsx +++ b/src/pages/study/index.tsx @@ -21,31 +21,41 @@ const StudyPage = () => { }, []); const getCourses = () => { + if (loading) { + return; + } setLoading(true); - course.latestLearn().then((res: any) => { - let data = res.data; - let today: CourseModel[] = []; - let yesterday: CourseModel[] = []; - let box: CourseModel[] = []; - if (data && data.length > 0) { - data.map((item: any) => { - let time = moment(item.hour_record.updated_at) - .utcOffset(0) - .format("YYYY-MM-DD HH:mm:ss"); - if (moment(time).isSame(moment(), "day")) { - today.push(item); - } else if (moment(time).isSame(moment().subtract(1, "day"), "day")) { - yesterday.push(item); - } else { - box.push(item); - } - }); - } - setTodayCourses(today); - setYesterdayCourses(yesterday); - setCourses(box); - setLoading(false); - }); + course + .latestLearn() + .then((res: any) => { + let data = res.data; + let today: CourseModel[] = []; + let yesterday: CourseModel[] = []; + let box: CourseModel[] = []; + if (data && data.length > 0) { + data.map((item: any) => { + let time = moment(item.hour_record.updated_at) + .utcOffset(0) + .format("YYYY-MM-DD HH:mm:ss"); + if (moment(time).isSame(moment(), "day")) { + today.push(item); + } else if ( + moment(time).isSame(moment().subtract(1, "day"), "day") + ) { + yesterday.push(item); + } else { + box.push(item); + } + }); + } + setTodayCourses(today); + setYesterdayCourses(yesterday); + setCourses(box); + setLoading(false); + }) + .catch((e) => { + setLoading(false); + }); }; return ( @@ -70,7 +80,10 @@ const StudyPage = () => { ))} - {!loading && courses.length === 0 && } + {!loading && + courses.length === 0 && + todayCourses.length === 0 && + yesterdayCourses.length === 0 && } {!loading && ( <> {todayCourses.length > 0 && ( From 90a54d1b9bf9fe6eb4cd3a5d2092c3157a445de5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 09:38:10 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/index.tsx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 71e4705..d555192 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -29,6 +29,7 @@ const CoursePage = () => { useState({}); const [courseTypeText, setCourseTypeText] = useState(""); + const [courseTitle, setCourseTitle] = useState(""); const [userCourseProgress, setUserCourseProgress] = useState(0); useEffect(() => { @@ -51,7 +52,7 @@ const CoursePage = () => { setLearnRecord(res.data.learn_record); } - if (res.data.learn_hour_records) { + if (JSON.stringify(res.data.learn_hour_records) !== "{}") { setLearnHourRecord(res.data.learn_hour_records); } }); @@ -60,13 +61,14 @@ const CoursePage = () => { useEffect(() => { if (course) { setCourseTypeText(course.is_required === 1 ? "必修课" : "选修课"); + setCourseTitle(course.title); } }, [course]); useEffect(() => { if (learnRecord?.progress) { setUserCourseProgress(Math.floor(learnRecord.progress / 100)); - } else if (learnHourRecord) { + } else if (learnHourRecord && JSON.stringify(learnHourRecord) !== "{}") { setUserCourseProgress(1); } else { setUserCourseProgress(0); @@ -87,7 +89,7 @@ const CoursePage = () => { />
-
{course?.title}
+
{courseTitle}
From 25867876d410ada833a29d608228d04aadda5b3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 09:39:52 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index d555192..94abde3 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -52,7 +52,7 @@ const CoursePage = () => { setLearnRecord(res.data.learn_record); } - if (JSON.stringify(res.data.learn_hour_records) !== "{}") { + if (res.data.learn_hour_records) { setLearnHourRecord(res.data.learn_hour_records); } }); From 00b74f5ab0820ff4e86c8f50f481899f6a79af6d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 09:44:52 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=A7=86=E9=A2=91=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/index.tsx | 3 ++- src/utils/index.ts | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 94abde3..3dfd318 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -4,6 +4,7 @@ import styles from "./index.module.scss"; import { useNavigate, useParams } from "react-router-dom"; import backIcon from "../../assets/images/commen/icon-back-n.png"; import { course as vod } from "../../api/index"; +import { isEmptyObject } from "../../utils/index"; import { Empty } from "../../components"; import { HourCompenent } from "./compenents/hour"; @@ -68,7 +69,7 @@ const CoursePage = () => { useEffect(() => { if (learnRecord?.progress) { setUserCourseProgress(Math.floor(learnRecord.progress / 100)); - } else if (learnHourRecord && JSON.stringify(learnHourRecord) !== "{}") { + } else if (learnHourRecord && !isEmptyObject(learnHourRecord)) { setUserCourseProgress(1); } else { setUserCourseProgress(0); diff --git a/src/utils/index.ts b/src/utils/index.ts index 38ba46f..4b06c5e 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -76,3 +76,7 @@ export function isMobile() { ); return flag; } + +export function isEmptyObject(obj: Object) { + return Object.keys(obj).length === 0; +} From b0b26d8e4763ea331d68316bf0adef6946f58681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A6=BA=E7=8B=A8?= <18119604035@163.com> Date: Wed, 5 Jul 2023 10:09:48 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/index/index.tsx | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 733ee82..d7ff20f 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -7,6 +7,7 @@ import { useSelector } from "react-redux"; import { useNavigate, useLocation } from "react-router-dom"; import { Footer, TabBarFooter, Empty } from "../../components"; import { CoursesModel } from "./compenents/courses-model"; +import { isEmptyObject } from "../../utils/index"; type LocalUserLearnHourRecordModel = { [key: number]: UserLearnHourRecordModel; @@ -74,7 +75,7 @@ const IndexPage = () => { return; } getData(); - }, [tabKey, currentDepId, categoryId]); + }, [currentDepId, categoryId]); const getData = () => { setLoading(true); @@ -127,7 +128,7 @@ const IndexPage = () => { const getParams = () => { user.coursesCategories().then((res: any) => { const categories = res.data.categories; - if (JSON.stringify(categories) !== "{}") { + if (!isEmptyObject(categories)) { const new_arr: any[] = checkArr(categories, 0); new_arr.unshift({ key: 0, @@ -204,9 +205,16 @@ const IndexPage = () => { activeKey={tabKey} onChange={(key: any) => { setTabKey(key); - navigate( - "/?cid=" + categoryId + "&catName=" + categoryText + "&tab=" + key - ); + setTimeout(() => { + navigate( + "/?cid=" + + categoryId + + "&catName=" + + categoryText + + "&tab=" + + key + ); + }, 250); }} style={{ "--fixed-active-line-width": "20px", From ef6c6029fd49b530d8406a2cf5dd4a60deba61fc Mon Sep 17 00:00:00 2001 From: none Date: Wed, 5 Jul 2023 10:46:08 +0800 Subject: [PATCH 9/9] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=AF=BE=E7=A8=8B?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E9=A1=B5=E9=9D=A2=E6=A0=87=E9=A2=98=E6=B8=B2?= =?UTF-8?q?=E6=9F=93=E7=BC=93=E6=85=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/index.tsx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 3dfd318..ea7ff95 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -30,7 +30,6 @@ const CoursePage = () => { useState({}); const [courseTypeText, setCourseTypeText] = useState(""); - const [courseTitle, setCourseTitle] = useState(""); const [userCourseProgress, setUserCourseProgress] = useState(0); useEffect(() => { @@ -62,7 +61,6 @@ const CoursePage = () => { useEffect(() => { if (course) { setCourseTypeText(course.is_required === 1 ? "必修课" : "选修课"); - setCourseTitle(course.title); } }, [course]); @@ -90,7 +88,7 @@ const CoursePage = () => { />
-
{courseTitle}
+
{course?.title + ""}