mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-12-23 17:29:47 +08:00
Compare commits
19 Commits
v1.0-beta.
...
v1.0-beta.
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25bb64a835 | ||
|
|
ccde01e6ff | ||
|
|
1996340699 | ||
|
|
c2420798d2 | ||
|
|
e04d63125a | ||
|
|
950fc74371 | ||
|
|
07cfa836a2 | ||
|
|
d922bb1b0b | ||
|
|
59b80c4158 | ||
|
|
465cc901b1 | ||
|
|
97f4abfe41 | ||
|
|
0075a848e3 | ||
|
|
58440be424 | ||
|
|
cec5251da4 | ||
|
|
c8e9f8cc7a | ||
|
|
1a9a20cbca | ||
|
|
537cac224a | ||
|
|
29630ec1ee | ||
|
|
01d2cf4e9b |
@@ -1,6 +1,6 @@
|
||||
import React, { useState, useEffect } from "react";
|
||||
import styles from "./index.module.scss";
|
||||
import { Modal, Button, Dropdown } from "antd";
|
||||
import { Modal, Button, Dropdown, Image } from "antd";
|
||||
import type { MenuProps } from "antd";
|
||||
import { useDispatch, useSelector } from "react-redux";
|
||||
import { Link, useNavigate, useLocation } from "react-router-dom";
|
||||
@@ -217,9 +217,11 @@ export const Header: React.FC = () => {
|
||||
<div className="d-flex" style={{ cursor: "pointer" }}>
|
||||
{user && user.name && (
|
||||
<>
|
||||
<img
|
||||
<Image
|
||||
loading="lazy"
|
||||
style={{ width: 36, height: 36, borderRadius: "50%" }}
|
||||
src={user.avatar}
|
||||
preview={false}
|
||||
/>
|
||||
<span className="ml-8 c-admin">{user.name}</span>
|
||||
</>
|
||||
|
||||
@@ -101,6 +101,7 @@ export const UserInfoModel: React.FC<PropInterface> = ({ open, onCancel }) => {
|
||||
<div className="d-flex">
|
||||
{avatar && (
|
||||
<Image
|
||||
loading="lazy"
|
||||
width={60}
|
||||
height={60}
|
||||
style={{ borderRadius: "50%" }}
|
||||
|
||||
@@ -291,9 +291,13 @@ h1 {
|
||||
}
|
||||
|
||||
#meedu-player-container {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
position: relative;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.ant-tree-switcher {
|
||||
@@ -375,3 +379,7 @@ h1 {
|
||||
.ant-popover-inner {
|
||||
padding: 8px 0px !important;
|
||||
}
|
||||
|
||||
.dplayer-notice {
|
||||
opacity: 0 !important;
|
||||
}
|
||||
|
||||
@@ -22,17 +22,46 @@ const CoursePalyPage = () => {
|
||||
const [loading, setLoading] = useState<Boolean>(false);
|
||||
const [isLastpage, setIsLastpage] = useState<Boolean>(false);
|
||||
const [totalHours, setTotalHours] = useState<any>([]);
|
||||
const [playingTime, setPlayingTime] = useState(0);
|
||||
const [watchedSeconds, setWatchedSeconds] = useState(0);
|
||||
const myRef = useRef(0);
|
||||
const playRef = useRef(0);
|
||||
const watchRef = useRef(0);
|
||||
const totalRef = useRef(0);
|
||||
|
||||
useEffect(() => {
|
||||
getCourse();
|
||||
getDetail();
|
||||
document.oncontextmenu = function (e) {
|
||||
/*屏蔽浏览器默认右键事件*/
|
||||
e = e || window.event;
|
||||
return false;
|
||||
};
|
||||
return () => {
|
||||
document.oncontextmenu = function (e) {
|
||||
/*恢复浏览器默认右键事件*/
|
||||
e = e || window.event;
|
||||
return true;
|
||||
};
|
||||
};
|
||||
}, [params.courseId, params.hourId]);
|
||||
|
||||
useEffect(() => {
|
||||
myRef.current = playDuration;
|
||||
}, [playDuration]);
|
||||
|
||||
useEffect(() => {
|
||||
playRef.current = playingTime;
|
||||
}, [playingTime]);
|
||||
|
||||
useEffect(() => {
|
||||
watchRef.current = watchedSeconds;
|
||||
}, [watchedSeconds]);
|
||||
|
||||
useEffect(() => {
|
||||
totalRef.current = hour.duration;
|
||||
}, [hour]);
|
||||
|
||||
const getCourse = () => {
|
||||
Course.detail(Number(params.courseId)).then((res: any) => {
|
||||
let totalHours: any = [];
|
||||
@@ -77,6 +106,9 @@ const CoursePalyPage = () => {
|
||||
};
|
||||
setLastSeeValue(params);
|
||||
setLastSeeValue(params);
|
||||
setWatchedSeconds(record.finished_duration);
|
||||
} else if (record && record.is_finished === 1) {
|
||||
setWatchedSeconds(res.data.hour.duration);
|
||||
}
|
||||
getVideoUrl(params);
|
||||
setLoading(false);
|
||||
@@ -96,6 +128,10 @@ const CoursePalyPage = () => {
|
||||
};
|
||||
|
||||
const initDPlayer = (playUrl: string, isTrySee: number, params: any) => {
|
||||
let banDrag =
|
||||
systemConfig.playerIsDisabledDrag &&
|
||||
watchRef.current < totalRef.current &&
|
||||
watchRef.current === 0;
|
||||
window.player = new window.DPlayer({
|
||||
container: document.getElementById("meedu-player-container"),
|
||||
autoplay: false,
|
||||
@@ -114,16 +150,38 @@ const CoursePalyPage = () => {
|
||||
color: systemConfig.playerBulletSecretColor || "red",
|
||||
opacity: Number(systemConfig.playerBulletSecretOpacity),
|
||||
},
|
||||
ban_drag: false,
|
||||
ban_drag: banDrag,
|
||||
last_see_pos: params,
|
||||
});
|
||||
// 监听播放进度更新evt
|
||||
window.player.on("timeupdate", () => {
|
||||
let currentTime = parseInt(window.player.video.currentTime);
|
||||
if (
|
||||
systemConfig.playerIsDisabledDrag &&
|
||||
watchRef.current < totalRef.current &&
|
||||
currentTime - playRef.current >= 2 &&
|
||||
currentTime > watchRef.current
|
||||
) {
|
||||
message.warning("首次学习禁止快进");
|
||||
window.player.seek(watchRef.current);
|
||||
} else {
|
||||
setPlayingTime(currentTime);
|
||||
playTimeUpdate(parseInt(window.player.video.currentTime), false);
|
||||
}
|
||||
});
|
||||
window.player.on("ended", () => {
|
||||
if (
|
||||
systemConfig.playerIsDisabledDrag &&
|
||||
watchRef.current < totalRef.current &&
|
||||
window.player.video.duration - playRef.current >= 2
|
||||
) {
|
||||
window.player.seek(playRef.current);
|
||||
return;
|
||||
}
|
||||
setPlayingTime(0);
|
||||
setPlayendedStatus(true);
|
||||
playTimeUpdate(parseInt(window.player.video.currentTime), true);
|
||||
exitFullscreen();
|
||||
window.player && window.player.destroy();
|
||||
});
|
||||
setLoading(false);
|
||||
@@ -157,6 +215,18 @@ const CoursePalyPage = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const exitFullscreen = () => {
|
||||
let de: any;
|
||||
de = document;
|
||||
if (de.fullscreenElement !== null) {
|
||||
de.exitFullscreen();
|
||||
} else if (de.mozCancelFullScreen) {
|
||||
de.mozCancelFullScreen();
|
||||
} else if (de.webkitCancelFullScreen) {
|
||||
de.webkitCancelFullScreen();
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className={styles["video-mask"]}>
|
||||
<div className={styles["top-cont"]}>
|
||||
@@ -165,6 +235,11 @@ const CoursePalyPage = () => {
|
||||
className={styles["close-btn"]}
|
||||
onClick={() => {
|
||||
window.player && window.player.destroy();
|
||||
document.oncontextmenu = function (e) {
|
||||
/*恢复浏览器默认右键事件*/
|
||||
e = e || window.event;
|
||||
return true;
|
||||
};
|
||||
navigate(-1);
|
||||
}}
|
||||
>
|
||||
|
||||
@@ -29,6 +29,7 @@ export const CoursesModel: React.FC<PropInterface> = ({
|
||||
>
|
||||
<div className={styles["top-content"]}>
|
||||
<Image
|
||||
loading="lazy"
|
||||
width={120}
|
||||
height={90}
|
||||
style={{ borderRadius: 10 }}
|
||||
@@ -65,7 +66,13 @@ export const CoursesModel: React.FC<PropInterface> = ({
|
||||
)}
|
||||
{progress >= 100 && (
|
||||
<div className={styles["success"]}>
|
||||
<Image width={24} height={24} src={mediaIcon} preview={false} />
|
||||
<Image
|
||||
loading="lazy"
|
||||
width={24}
|
||||
height={24}
|
||||
src={mediaIcon}
|
||||
preview={false}
|
||||
/>
|
||||
<span className="ml-8">恭喜你学完此课程!</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
@@ -187,8 +187,6 @@ const IndexPage = () => {
|
||||
overflowX: "hidden",
|
||||
overflowY: "auto",
|
||||
}}
|
||||
onMouseOut={() => setOpen(false)}
|
||||
onMouseOver={() => setOpen(true)}
|
||||
>
|
||||
<Tree
|
||||
selectedKeys={selectKey}
|
||||
@@ -332,10 +330,7 @@ const IndexPage = () => {
|
||||
trigger="click"
|
||||
onOpenChange={handleOpenChange}
|
||||
>
|
||||
<Space
|
||||
className={styles["dropButton"]}
|
||||
onMouseOver={() => setOpen(true)}
|
||||
>
|
||||
<Space className={styles["dropButton"]}>
|
||||
{categoryText}
|
||||
<i
|
||||
className="iconfont icon-icon-xiala"
|
||||
|
||||
@@ -22,6 +22,26 @@ export const InitPage = (props: Props) => {
|
||||
const [showHeader, setShowHeader] = useState<boolean>(true);
|
||||
const [showNoHeader, setShowNoHeader] = useState<boolean>(false);
|
||||
const [showFooter, setShowFooter] = useState<boolean>(true);
|
||||
const [init, setInit] = useState<boolean>(false);
|
||||
useEffect(() => {
|
||||
if (pathname) {
|
||||
if (pathname === "/login") {
|
||||
setShowNoHeader(true);
|
||||
setShowHeader(false);
|
||||
setShowFooter(false);
|
||||
} else if (!params.hourId) {
|
||||
setShowNoHeader(false);
|
||||
setShowHeader(true);
|
||||
setShowFooter(true);
|
||||
} else {
|
||||
setShowNoHeader(false);
|
||||
setShowHeader(false);
|
||||
setShowFooter(false);
|
||||
}
|
||||
}
|
||||
}, [pathname, params]);
|
||||
|
||||
useEffect(() => {
|
||||
if (props.loginData) {
|
||||
dispatch(loginAction(props.loginData));
|
||||
}
|
||||
@@ -41,6 +61,11 @@ export const InitPage = (props: Props) => {
|
||||
props.configData["player-is-enabled-bullet-secret"] === "1"
|
||||
? true
|
||||
: false,
|
||||
playerIsDisabledDrag:
|
||||
props.configData["player-disabled-drag"] &&
|
||||
props.configData["player-disabled-drag"] === "1"
|
||||
? true
|
||||
: false,
|
||||
playerBulletSecretText: props.configData["player-bullet-secret-text"],
|
||||
playerBulletSecretColor: props.configData["player-bullet-secret-color"],
|
||||
playerBulletSecretOpacity:
|
||||
@@ -48,34 +73,19 @@ export const InitPage = (props: Props) => {
|
||||
};
|
||||
dispatch(saveConfigAction(config));
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
setShowHeader(true);
|
||||
setShowNoHeader(false);
|
||||
setShowFooter(true);
|
||||
if (pathname === "/login") {
|
||||
setShowNoHeader(true);
|
||||
setShowHeader(false);
|
||||
setShowFooter(false);
|
||||
} else if (!params.hourId) {
|
||||
setShowNoHeader(false);
|
||||
setShowHeader(true);
|
||||
setShowFooter(true);
|
||||
} else {
|
||||
setShowNoHeader(false);
|
||||
setShowHeader(false);
|
||||
setShowFooter(false);
|
||||
}
|
||||
}, [pathname, params]);
|
||||
setInit(true);
|
||||
}, [props]);
|
||||
|
||||
return (
|
||||
<>
|
||||
{init && (
|
||||
<div>
|
||||
{showNoHeader && <NoHeader></NoHeader>}
|
||||
{showHeader && <Header></Header>}
|
||||
<Outlet />
|
||||
{showFooter && <Footer></Footer>}
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -56,6 +56,7 @@ const LatestLearnPage = () => {
|
||||
>
|
||||
<div style={{ width: 120 }}>
|
||||
<Image
|
||||
loading="lazy"
|
||||
src={item.course.thumb}
|
||||
width={120}
|
||||
height={90}
|
||||
@@ -91,6 +92,7 @@ const LatestLearnPage = () => {
|
||||
{item.record.progress >= 10000 && (
|
||||
<>
|
||||
<Image
|
||||
loading="lazy"
|
||||
width={24}
|
||||
height={24}
|
||||
src={mediaIcon}
|
||||
|
||||
@@ -9,6 +9,7 @@ type SystemConfigStoreInterface = {
|
||||
pcIndexFooterMsg: string;
|
||||
playerPoster: string;
|
||||
playerIsEnabledBulletSecret: boolean;
|
||||
playerIsDisabledDrag: boolean;
|
||||
playerBulletSecretText: string;
|
||||
playerBulletSecretColor: string;
|
||||
playerBulletSecretOpacity: string;
|
||||
@@ -23,6 +24,7 @@ let defaultValue: SystemConfigStoreInterface = {
|
||||
pcIndexFooterMsg: "",
|
||||
playerPoster: "",
|
||||
playerIsEnabledBulletSecret: false,
|
||||
playerIsDisabledDrag: false,
|
||||
playerBulletSecretText: "",
|
||||
playerBulletSecretColor: "",
|
||||
playerBulletSecretOpacity: "",
|
||||
|
||||
Reference in New Issue
Block a user