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 (