From 331e7dc95f68283d32e148d02f54af965a4b6cc3 Mon Sep 17 00:00:00 2001 From: king <2229249788@qq.com> Date: Wed, 26 Jul 2023 09:53:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E6=96=AD=E7=82=B9=E7=AD=94?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/index.js | 5 +- src/api/curriculum.ts | 27 +++++-- src/api/user.ts | 7 ++ src/app.config.ts | 7 +- src/components/video/video.tsx | 7 +- src/components/videoCover/videoCover.tsx | 3 +- src/hooks/unique_ident.ts | 38 +++++++++ .../business/curHistory/curHistory.config.ts | 3 + .../curHistory/curHistory.module.scss | 55 +++++++++++++ src/pages/business/curHistory/curHistory.tsx | 76 ++++++++++++++++++ .../history/components/CategoryTabs.tsx | 35 +++++++++ src/pages/business/history/history.config.ts | 3 + .../business/history/history.module.scss | 50 ++++++++++++ src/pages/business/history/history.tsx | 45 +++++++++++ src/pages/business/test/test.tsx | 8 +- src/pages/business/test/text.module.scss | 4 + .../business/userInfo/userInfo.module.scss | 7 +- .../videoInfo/components/catalogue.tsx | 77 +++++++++---------- .../business/videoInfo/components/course.tsx | 38 +++++++-- .../business/videoInfo/components/hours.tsx | 4 +- .../videoInfo/components/studentRecord.tsx | 41 ---------- src/pages/business/videoInfo/videoInfo.scss | 21 ++++- src/pages/business/videoInfo/videoInfo.tsx | 17 ++-- src/pages/index/components/videoList.tsx | 49 +++++++++++- src/pages/index/index.tsx | 4 +- src/pages/manage/addStudent/addStudent.scss | 6 +- src/pages/manage/addStudent/addStudent.tsx | 7 +- src/pages/manage/depAdmin/depAdmin.scss | 15 +++- src/pages/manage/depAdmin/depAdmin.tsx | 28 +++---- src/pages/my/components/header/service.tsx | 4 +- src/utils/time.ts | 27 +++++++ types/curriculum.d.ts | 18 ++++- types/user.d.ts | 17 ++++ 33 files changed, 603 insertions(+), 150 deletions(-) create mode 100644 src/hooks/unique_ident.ts create mode 100644 src/pages/business/curHistory/curHistory.config.ts create mode 100644 src/pages/business/curHistory/curHistory.module.scss create mode 100644 src/pages/business/curHistory/curHistory.tsx create mode 100644 src/pages/business/history/components/CategoryTabs.tsx create mode 100644 src/pages/business/history/history.config.ts create mode 100644 src/pages/business/history/history.module.scss create mode 100644 src/pages/business/history/history.tsx create mode 100644 src/pages/business/test/text.module.scss delete mode 100644 src/pages/business/videoInfo/components/studentRecord.tsx diff --git a/config/index.js b/config/index.js index 7ae8ff1..39d86b5 100644 --- a/config/index.js +++ b/config/index.js @@ -47,7 +47,10 @@ const config = { generateScopedName: '[name]__[local]___[hash:base64:5]' } } - } + }, + optimizeMainPackage: { + enable: true, + }, }, h5: { publicPath: '/', diff --git a/src/api/curriculum.ts b/src/api/curriculum.ts index e780da9..9b887b4 100644 --- a/src/api/curriculum.ts +++ b/src/api/curriculum.ts @@ -17,16 +17,18 @@ export interface CourseDepData { } export interface HourPlayData { + /** 独特的识别 */ + unique_ident: number /** 时间 */ duration: number /** 格式 */ extension: string /** 地址 */ url: string - hourExamQuestions: { - count: Record - data: Record - } + /** 断点题 */ + hourExamQuestions: Record + /** 次数 */ + count: Record /** 断点 */ timeList: number[] hour_test?: { id: number } @@ -56,9 +58,16 @@ interface RecordTextParam { user_id: number; } +export interface CurEndParam { + duration: number + unique_ident: number + /** 开始时间时间戳 */ + start_date: number +} + export const curriculum = { department() { - return request<{data: Manage[] }>('/api/v1/department/index', 'GET') + return request<{ data: Manage[] }>('/api/v1/department/index', 'GET') }, /** 学习记录 */ record(id: number) { @@ -81,8 +90,8 @@ export const curriculum = { return request(`/api/v1/user/courses`, "GET") }, /** 课程结束 */ - curEnd(courseId: number, id: number, duration: number) { - return request(`/api/v1/course/${courseId}/hour/${id}/record`, "POST", {duration}) + curEnd(courseId: number, id: number, data: CurEndParam) { + return request(`/api/v1/course/${courseId}/hour/${id}/record`, "POST", data) }, answerRecord(hourId: number, data: AnswerRecord) { return request<{ time: number }>(`/api/v1/test/video/record/${hourId}`, "POST", data) @@ -97,5 +106,9 @@ export const curriculum = { }, putRecordText(hour_id: number, is_pass: boolean) { return request(`/api/v1/test/record/${hour_id}`, "PUT", {is_pass}) + }, + /** 学习记录 */ + hourCache(courseId: number, data: HourCacheParam) { + return request(`/api/v1/course/${courseId}/hour/cache`, "PUT", data) } } diff --git a/src/api/user.ts b/src/api/user.ts index 5603c23..98404c5 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -58,5 +58,12 @@ export const userApi = { }, learningRecord(courseId?: number) { return request(`/api/v1/user/record/course`, "GET", courseId ? {courseId} : {}) + }, + /** 学习记录 */ + record(category_id: number) { + return request>(`/api/v1/course/${category_id}/record`, "GET") + }, + courseRecord(course_id: number) { + return request>(`/api/v1/course/${course_id}/info`, "GET") } } diff --git a/src/app.config.ts b/src/app.config.ts index 51a9fff..d66a073 100644 --- a/src/app.config.ts +++ b/src/app.config.ts @@ -11,6 +11,8 @@ export default defineAppConfig({ navigationBarTextStyle: 'black' }, tabBar: { + color: '#909795', + selectedColor: '#45D4A8', list: [ { text: '课题', @@ -43,6 +45,8 @@ export default defineAppConfig({ 'userInfo/userInfo', 'videoInfo/videoInfo', 'test/test', + 'history/history', + 'curHistory/curHistory', ] }, { @@ -56,5 +60,6 @@ export default defineAppConfig({ 'addCur/addCur', ] } - ] + ], + lazyCodeLoading: "requiredComponents" }) diff --git a/src/components/video/video.tsx b/src/components/video/video.tsx index 826c53f..2cb9e12 100644 --- a/src/components/video/video.tsx +++ b/src/components/video/video.tsx @@ -2,12 +2,12 @@ import {BaseEventOrig, Video, VideoProps} from "@tarojs/components"; import {HVideoOptions} from "@/components/video/type"; import Taro from "@tarojs/taro"; import {FC, useState} from "react"; -import {Profile} from '@/store' +// import {Profile} from '@/store' const deviation: number = 0.5 const HVideo: FC = (opt: HVideoOptions) => { - const {user} = Profile.useContainer() + // const {user} = Profile.useContainer() const video = Taro.createVideoContext('myVideo') const [currentTime, setCurrentTime] = useState(0) @@ -25,6 +25,7 @@ const HVideo: FC = (opt: HVideoOptions) => { /** 判断是否进入断点 */ opt.breakpoint.forEach(d => { if (time < d + deviation && time > d - deviation) { + video.exitFullScreen() video.pause() video.seek(d - deviation) opt.onBreakpoint(d) @@ -52,7 +53,7 @@ const HVideo: FC = (opt: HVideoOptions) => { return (