From eaee82649eac376684124733b047867eadb546ab Mon Sep 17 00:00:00 2001 From: xxx Date: Thu, 21 Sep 2023 10:32:21 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=85=BC=E5=AE=B9=E5=AE=89=E5=8D=93?= =?UTF-8?q?=E9=92=89=E9=92=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 ++ vite.config.ts | 11 ++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 2d56ee7..5edb50f 100644 --- a/package.json +++ b/package.json @@ -28,9 +28,11 @@ "devDependencies": { "@types/react": "^18.0.28", "@types/react-dom": "^18.0.11", + "@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-react-swc": "^3.0.0", "rollup-plugin-gzip": "^3.1.0", "sass": "^1.59.3", + "terser": "^5.20.0", "typescript": "^4.9.3", "vite": "^4.2.0" } diff --git a/vite.config.ts b/vite.config.ts index 940a1f6..0e35dd1 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ import { defineConfig } from "vite"; import react from "@vitejs/plugin-react-swc"; import gzipPlugin from "rollup-plugin-gzip"; +import legacy from "@vitejs/plugin-legacy"; // https://vitejs.dev/config/ export default defineConfig({ @@ -8,7 +9,15 @@ export default defineConfig({ host: "0.0.0.0", port: 9797, }, - plugins: [react()], + plugins: [ + react(), + legacy({ + targets: ["chrome 52"], + additionalLegacyPolyfills: ["regenerator-runtime/runtime"], + renderLegacyChunks: true, + modernPolyfills: true, + }), + ], build: { rollupOptions: { plugins: [gzipPlugin()], From 7a64180d04ad1112642dbf2f7e5026c60648281a Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Fri, 22 Sep 2023 15:28:35 +0800 Subject: [PATCH 2/4] =?UTF-8?q?iconfont=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/index.scss | 2 -- src/main.tsx | 3 ++- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/index.scss b/src/index.scss index 96b296f..cbc9dca 100644 --- a/src/index.scss +++ b/src/index.scss @@ -1,5 +1,3 @@ -@import "./assets/iconfont/iconfont.css"; - $primaryColor: #ff4d4f; :root { diff --git a/src/main.tsx b/src/main.tsx index fb65939..6ac745c 100644 --- a/src/main.tsx +++ b/src/main.tsx @@ -4,6 +4,7 @@ import store from "./store"; import { BrowserRouter } from "react-router-dom"; import { ConfigProvider } from "antd"; import zhCN from "antd/locale/zh_CN"; +import "./assets/iconfont/iconfont.css"; import App from "./App"; import "./index.scss"; //全局样式 import AutoScorllTop from "./AutoTop"; @@ -21,4 +22,4 @@ ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render( -); \ No newline at end of file +); From 1fbe67f228f4c6b977dc5e6ac518adda5c2a60c3 Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Fri, 22 Sep 2023 16:46:43 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/video.module.scss | 7 +++++++ src/pages/course/video.tsx | 31 ++++++++++++++++++++++++++++++ src/utils/index.ts | 12 ++++++++++++ 3 files changed, 50 insertions(+) diff --git a/src/pages/course/video.module.scss b/src/pages/course/video.module.scss index b9b23f2..17071fd 100644 --- a/src/pages/course/video.module.scss +++ b/src/pages/course/video.module.scss @@ -64,6 +64,7 @@ margin: 0 auto; border-radius: 8px; position: relative; + .alert-message { position: absolute; top: 0; @@ -80,6 +81,12 @@ font-size: 18px; color: white; z-index: 100; + .des-video { + font-size: 15px; + font-weight: 400; + color: #ffffff; + line-height: 15px; + } .alert-button { width: 200px; height: 54px; diff --git a/src/pages/course/video.tsx b/src/pages/course/video.tsx index c49117b..5f967da 100644 --- a/src/pages/course/video.tsx +++ b/src/pages/course/video.tsx @@ -5,8 +5,10 @@ import { useSelector } from "react-redux"; import { course as Course } from "../../api/index"; import { ArrowLeftOutlined } from "@ant-design/icons"; import { message } from "antd"; +import { getPlayId, savePlayId } from "../../utils"; declare const window: any; +var timer: any = null; const CoursePalyPage = () => { const navigate = useNavigate(); @@ -28,8 +30,10 @@ const CoursePalyPage = () => { const playRef = useRef(0); const watchRef = useRef(0); const totalRef = useRef(0); + const [checkPlayerStatus, setCheckPlayerStatus] = useState(false); useEffect(() => { + timer && clearInterval(timer); getCourse(); getDetail(); document.oncontextmenu = function (e) { @@ -37,7 +41,9 @@ const CoursePalyPage = () => { e = e || window.event; return false; }; + return () => { + timer && clearInterval(timer); document.oncontextmenu = function (e) { /*恢复浏览器默认右键事件*/ e = e || window.event; @@ -123,6 +129,7 @@ const CoursePalyPage = () => { (res: any) => { setPlayUrl(res.data.url); initDPlayer(res.data.url, 0, data); + savePlayId(String(params.courseId) + "-" + String(params.hourId)); } ); }; @@ -185,6 +192,7 @@ const CoursePalyPage = () => { window.player && window.player.destroy(); }); setLoading(false); + checkPlayer(); }; const playTimeUpdate = (duration: number, isEnd: boolean) => { @@ -201,6 +209,22 @@ const CoursePalyPage = () => { } }; + const checkPlayer = () => { + timer = setInterval(() => { + let playId = getPlayId(); + if ( + playId && + playId !== String(params.courseId) + "-" + String(params.hourId) + ) { + timer && clearInterval(timer); + window.player && window.player.destroy(); + setCheckPlayerStatus(true); + } else { + setCheckPlayerStatus(false); + } + }, 5000); + }; + const goNextVideo = () => { const index = totalHours.findIndex( (i: any) => i.id === Number(params.hourId) @@ -256,6 +280,13 @@ const CoursePalyPage = () => { id="meedu-player-container" style={{ borderRadius: 8 }} > + {checkPlayerStatus && ( +
+
+ 您已打开新视频,暂停本视频播放 +
+
+ )} {playendedStatus && (
{isLastpage && ( diff --git a/src/utils/index.ts b/src/utils/index.ts index 397f374..8bf5bef 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -111,3 +111,15 @@ export function isMobile() { ); return flag; } + +export function getPlayId(): string { + return window.localStorage.getItem("playedu-play-id") || ""; +} + +export function savePlayId(id: string) { + window.localStorage.setItem("playedu-play-id", id); +} + +export function clearPlayId() { + window.localStorage.removeItem("playedu-play-id"); +} From 30612785b5aa4ea5f553126ceefe53400a42efb9 Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Fri, 22 Sep 2023 16:50:31 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E8=A7=86=E9=A2=91?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E6=92=AD=E6=94=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/course/video.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/pages/course/video.tsx b/src/pages/course/video.tsx index 5f967da..844f29a 100644 --- a/src/pages/course/video.tsx +++ b/src/pages/course/video.tsx @@ -258,6 +258,7 @@ const CoursePalyPage = () => {
{ + timer && clearInterval(timer); window.player && window.player.destroy(); document.oncontextmenu = function (e) { /*恢复浏览器默认右键事件*/