diff --git a/src/api/user.ts b/src/api/user.ts index 5583425..637208c 100644 --- a/src/api/user.ts +++ b/src/api/user.ts @@ -13,9 +13,13 @@ export function password(oldPassword: string, newPassword: string) { } // 学员课程 -export function courses(depId: number) { +export function coursesCategories() { + return client.get("/api/v1/category/all", {}); +} +export function courses(depId: number, categoryId: number) { return client.get("/api/v1/user/courses", { dep_id: depId, + category_id: categoryId, }); } diff --git a/src/index.scss b/src/index.scss index b2dd0e6..f4b5992 100644 --- a/src/index.scss +++ b/src/index.scss @@ -295,3 +295,76 @@ h1 { height: auto; position: relative; } + +.ant-tree-switcher { + display: none !important; +} + +.ant-tree-treenode { + width: 100% !important; + height: 40px !important; + padding: 0 !important; + margin-bottom: 8px !important; + display: flex; + align-items: center !important; + &.ant-tree-treenode-selected { + background-color: #fff2f0 !important; + border-radius: 0px !important; + overflow: hidden; + .ant-tree-node-content-wrapper { + background-color: transparent !important; + } + .ant-tree-node-content-wrapper-normal { + background-color: transparent !important; + } + } + .ant-tree-node-content-wrapper { + width: 100% !important; + height: 40px !important; + display: flex; + align-items: center; + } + &:hover { + background-color: #fff2f0 !important; + border-radius: 0px !important; + overflow: hidden; + .ant-tree-node-content-wrapper { + background-color: transparent !important; + } + .ant-tree-node-content-wrapper-normal { + background-color: transparent !important; + } + } + .ant-tree-node-content-wrapper-normal { + width: 100% !important; + height: 40px !important; + display: flex; + align-items: center; + } + + .ant-tree-switcher { + height: 40px !important; + display: flex; + align-items: center; + } +} + +.ant-tree-title { + flex: 1; + padding-left: 20px; + box-sizing: border-box; + display: flex; + align-items: center; + justify-content: space-between; + .iconfont { + color: rgba(0, 0, 0, 0.2); + cursor: pointer; + &:hover { + opacity: 0.8; + } + } +} + +.ant-popover-inner{ + padding: 8px 0px !important; +} \ No newline at end of file diff --git a/src/pages/course/index.tsx b/src/pages/course/index.tsx index 220e1dd..dac59ec 100644 --- a/src/pages/course/index.tsx +++ b/src/pages/course/index.tsx @@ -124,7 +124,7 @@ const CoursePage = () => { trailColor="#F6F6F6" size={90} strokeWidth={8} - percent={learnRecord.progress / 100} + percent={Math.floor(learnRecord.progress / 100)} format={(percent) => `${percent}%`} /> )} diff --git a/src/pages/course/video.module.scss b/src/pages/course/video.module.scss index 8c91805..b193787 100644 --- a/src/pages/course/video.module.scss +++ b/src/pages/course/video.module.scss @@ -2,9 +2,11 @@ width: 100%; height: 100%; min-height: 100vh; + max-height: 900px; background-color: #0e0e1e; display: flex; justify-content: center; + overflow: hidden; .top-cont { position: fixed; top: 0; @@ -38,12 +40,13 @@ } .video-body { width: 62.5%; - height: auto; + height: 100%; display: flex; flex-direction: column; box-sizing: border-box; padding-top: 30px; margin-top: 60px; + overflow-y: auto; .video-title { width: 100%; height: 36px; @@ -57,7 +60,7 @@ .video-box { width: 100%; - padding-bottom: calc(9 / 16 * 50%); + padding-bottom: calc(9 / 16 * 100%); margin: 0 auto; border-radius: 8px; position: relative; diff --git a/src/pages/index/index.module.scss b/src/pages/index/index.module.scss index 06864d2..71a0be5 100644 --- a/src/pages/index/index.module.scss +++ b/src/pages/index/index.module.scss @@ -64,6 +64,7 @@ margin-top: 50px; display: flex; align-items: center; + position: relative; .tab-item { width: 64px; height: 48px; @@ -108,6 +109,19 @@ animation: scaleTransX 0.3s; } } + .dropButton { + height: 40px; + font-size: 14px; + font-weight: 400; + color: rgba(0, 0, 0, 0.45); + line-height: 40px; + display: flex; + align-items: center; + position: absolute; + right: 0; + top: 0; + cursor: pointer; + } } @keyframes scaleTransX { diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 377e284..96d45cf 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -1,6 +1,6 @@ import { useEffect, useState } from "react"; -import { Row, Col, Spin, Image } from "antd"; -import type { TabsProps } from "antd"; +import { Row, Col, Spin, Tree, Popover, Space, Image } from "antd"; +import type { MenuProps } from "antd"; import { user } from "../../api/index"; import styles from "./index.module.scss"; import { useSelector } from "react-redux"; @@ -11,11 +11,20 @@ import studyTime from "../../assets/images/commen/icon-studytime.png"; import iconRoute from "../../assets/images/commen/icon-route.png"; import { studyTimeFormat } from "../../utils/index"; +interface Option { + key: string | number; + title: any; + children?: Option[]; +} + const IndexPage = () => { const systemConfig = useSelector((state: any) => state.systemConfig.value); const [loading, setLoading] = useState(false); const [tabKey, setTabKey] = useState(0); const [coursesList, setCoursesList] = useState([]); + const [categories, setCategories] = useState([]); + const [categoryId, setCategoryId] = useState(0); + const [categoryText, setCategoryText] = useState("所有分类"); const [learnCourseRecords, setLearnCourseRecords] = useState({}); const [learnCourseHourCount, setLearnCourseHourCount] = useState({}); const [stats, setStats] = useState({}); @@ -27,12 +36,16 @@ const IndexPage = () => { (state: any) => state.loginUser.value.currentDepId ); + useEffect(() => { + getParams(); + }, []); + useEffect(() => { if (currentDepId === 0) { return; } getData(); - }, [tabKey, currentDepId]); + }, [tabKey, currentDepId, categoryId]); useEffect(() => { document.title = systemConfig.systemName || "首页"; @@ -40,7 +53,7 @@ const IndexPage = () => { const getData = () => { setLoading(true); - user.courses(currentDepId).then((res: any) => { + user.courses(currentDepId, categoryId).then((res: any) => { const records = res.data.learn_course_records; setStats(res.data.stats); setLearnCourseRecords(records); @@ -87,6 +100,40 @@ const IndexPage = () => { }); }; + const getParams = () => { + user.coursesCategories().then((res: any) => { + const categories = res.data.categories; + if (JSON.stringify(categories) !== "{}") { + const new_arr: Option[] = checkArr(categories, 0); + new_arr.unshift({ + key: 0, + title: "所有分类", + }); + setCategories(new_arr); + } + }); + }; + + const checkArr = (categories: any[], id: number) => { + const arr = []; + for (let i = 0; i < categories[id].length; i++) { + if (!categories[categories[id][i].id]) { + arr.push({ + title: categories[id][i].name, + key: categories[id][i].id, + }); + } else { + const new_arr: Option[] = checkArr(categories, categories[id][i].id); + arr.push({ + title: categories[id][i].name, + key: categories[id][i].id, + children: new_arr, + }); + } + } + return arr; + }; + const items = [ { key: 0, @@ -114,6 +161,29 @@ const IndexPage = () => { setTabKey(key); }; + const onSelect = (selectedKeys: any, info: any) => { + setCategoryId(selectedKeys[0]); + setCategoryText(info.node.title); + }; + + const dropItem = ( +
+ +
+ ); + return (
@@ -238,6 +308,15 @@ const IndexPage = () => { )}
))} + + + {categoryText} + + +
{loading && ( { title={item.title} thumb={item.thumb} isRequired={item.is_required} - progress={learnCourseRecords[item.id].progress / 100} + progress={Math.floor( + learnCourseRecords[item.id].progress / 100 + )} > )} diff --git a/src/pages/latest-learn/index.tsx b/src/pages/latest-learn/index.tsx index c9f4010..b600230 100644 --- a/src/pages/latest-learn/index.tsx +++ b/src/pages/latest-learn/index.tsx @@ -83,7 +83,7 @@ const LatestLearnPage = () => {
{item.record.progress < 10000 && (