mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-12-24 05:49:50 +08:00
Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
96da44a884 | ||
|
|
39250531fb | ||
|
|
490ea214b3 | ||
|
|
b0d0063fc1 | ||
|
|
8614d4ebaf | ||
|
|
46bb144f0a | ||
|
|
6e920d8ea1 | ||
|
|
8154ee3130 | ||
|
|
e056775fc0 | ||
|
|
f5b4a70741 | ||
|
|
e1bca31883 | ||
|
|
f1985d0b8f | ||
|
|
3eafab1d41 | ||
|
|
66fd8486db | ||
|
|
30612785b5 | ||
|
|
1fbe67f228 | ||
|
|
7a64180d04 | ||
|
|
eaee82649e |
@@ -1,2 +1 @@
|
||||
VITE_APP_URL=
|
||||
VITE_G_ID=
|
||||
VITE_APP_URL=
|
||||
4
.gitignore
vendored
4
.gitignore
vendored
@@ -32,4 +32,6 @@ yarn.lock
|
||||
|
||||
deploy-test.sh
|
||||
deploy-prod.sh
|
||||
deploy-demo.sh
|
||||
deploy-demo.sh
|
||||
|
||||
pnpm-lock.yaml
|
||||
@@ -13,10 +13,5 @@
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="module" src="/src/main.tsx"></script>
|
||||
<script
|
||||
crossorigin="anonymous"
|
||||
integrity="sha512-oHrfR/z2wkuRuaHrdZ9NhoT/o/1kteub+QvmQgVzOKK7NTvIKQMvnY9+/RR0+eW311o4lAE/YzzLXXmP2XUvig=="
|
||||
src="https://lib.baomitu.com/hls.js/1.1.4/hls.min.js"
|
||||
></script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"private": true,
|
||||
"name": "playedu-pc-interface",
|
||||
"private": false,
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
@@ -9,28 +9,31 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@ant-design/icons": "^5.3.0",
|
||||
"@reduxjs/toolkit": "^1.9.3",
|
||||
"add": "^2.0.6",
|
||||
"antd": "^5.3.2",
|
||||
"axios": "^1.3.4",
|
||||
"dayjs": "^1.11.10",
|
||||
"localforage": "^1.10.0",
|
||||
"match-sorter": "^6.3.1",
|
||||
"moment": "^2.29.4",
|
||||
"prop-types": "^15.8.1",
|
||||
"react": "^18.2.0",
|
||||
"react-dom": "^18.2.0",
|
||||
"react-ga": "^3.3.1",
|
||||
"react-redux": "^8.0.5",
|
||||
"react-router-dom": "^6.9.0",
|
||||
"redux": "^4.2.1",
|
||||
"sort-by": "^1.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.28",
|
||||
"@types/react-dom": "^18.0.11",
|
||||
"@types/react": "^18.2.0",
|
||||
"@types/react-dom": "^18.2.0",
|
||||
"@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"
|
||||
}
|
||||
|
||||
1
public/js/xg/hls.min.js
vendored
1
public/js/xg/hls.min.js
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
24
src/App.tsx
24
src/App.tsx
@@ -1,31 +1,13 @@
|
||||
import { Suspense, useEffect } from "react";
|
||||
import ReactGA from "react-ga";
|
||||
import { useLocation, useRoutes } from "react-router-dom";
|
||||
import { Suspense } from "react";
|
||||
import { useRoutes } from "react-router-dom";
|
||||
import routes from "./routes";
|
||||
import "./App.scss";
|
||||
import LoadingPage from "./pages/loading";
|
||||
|
||||
const G_ID = import.meta.env.VITE_G_ID || "";
|
||||
if (G_ID) {
|
||||
ReactGA.initialize(G_ID);
|
||||
}
|
||||
|
||||
const App = () => {
|
||||
const views = useRoutes(routes);
|
||||
|
||||
const location = useLocation();
|
||||
useEffect(() => {
|
||||
if (!G_ID) {
|
||||
return;
|
||||
}
|
||||
ReactGA.pageview(location.pathname + location.search);
|
||||
}, [location]);
|
||||
|
||||
return (
|
||||
<Suspense fallback={<LoadingPage />}>
|
||||
{views}
|
||||
</Suspense>
|
||||
);
|
||||
return <Suspense fallback={<LoadingPage />}>{views}</Suspense>;
|
||||
};
|
||||
|
||||
export default App;
|
||||
|
||||
@@ -1,14 +1,21 @@
|
||||
import axios, { Axios, AxiosResponse } from "axios";
|
||||
import { message } from "antd";
|
||||
import { getToken, clearToken } from "../../utils/index";
|
||||
import {
|
||||
getToken,
|
||||
clearToken,
|
||||
clearDepKey,
|
||||
clearDepName,
|
||||
} from "../../utils/index";
|
||||
|
||||
const GoLogin = () => {
|
||||
clearToken();
|
||||
clearDepName();
|
||||
clearDepKey();
|
||||
window.location.href = "/login";
|
||||
};
|
||||
|
||||
const GoError = () => {
|
||||
window.location.href = "/error";
|
||||
const GoError = (status: number) => {
|
||||
window.location.href = "/error?status=" + status;
|
||||
};
|
||||
|
||||
export class HttpClient {
|
||||
@@ -56,13 +63,13 @@ export class HttpClient {
|
||||
GoLogin();
|
||||
} else if (status === 404) {
|
||||
// 跳转到404页面
|
||||
GoError();
|
||||
GoError(404);
|
||||
} else if (status === 403) {
|
||||
// 跳转到无权限页面
|
||||
GoError();
|
||||
GoError(403);
|
||||
} else if (status === 500) {
|
||||
// 跳转到500异常页面
|
||||
GoError();
|
||||
GoError(500);
|
||||
}
|
||||
return Promise.reject(error.response);
|
||||
}
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 64 KiB |
@@ -1,5 +1,3 @@
|
||||
@import "./assets/iconfont/iconfont.css";
|
||||
|
||||
$primaryColor: #ff4d4f;
|
||||
|
||||
:root {
|
||||
@@ -35,6 +33,18 @@ body {
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.layout-box {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 100vh;
|
||||
}
|
||||
|
||||
.footer-box {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column-reverse;
|
||||
}
|
||||
|
||||
.main-body {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
|
||||
@@ -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(
|
||||
</BrowserRouter>
|
||||
</ConfigProvider>
|
||||
</Provider>
|
||||
);
|
||||
);
|
||||
|
||||
@@ -101,7 +101,7 @@
|
||||
align-items: center;
|
||||
position: relative;
|
||||
.tab-item {
|
||||
width: 64px;
|
||||
min-width: 64px;
|
||||
height: 48px;
|
||||
margin-right: 50px;
|
||||
transition: all 0.2s;
|
||||
@@ -114,7 +114,7 @@
|
||||
}
|
||||
}
|
||||
.tit {
|
||||
width: 64px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
font-size: 16px;
|
||||
font-weight: 400;
|
||||
@@ -123,7 +123,7 @@
|
||||
}
|
||||
}
|
||||
.tab-active-item {
|
||||
width: 64px;
|
||||
min-width: 64px;
|
||||
height: 48px;
|
||||
cursor: pointer;
|
||||
margin-right: 50px;
|
||||
@@ -133,7 +133,7 @@
|
||||
opacity: 0.8;
|
||||
}
|
||||
.tit {
|
||||
width: 64px;
|
||||
width: 100%;
|
||||
height: 40px;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
@@ -234,6 +258,7 @@ const CoursePalyPage = () => {
|
||||
<div
|
||||
className={styles["close-btn"]}
|
||||
onClick={() => {
|
||||
timer && clearInterval(timer);
|
||||
window.player && window.player.destroy();
|
||||
document.oncontextmenu = function (e) {
|
||||
/*恢复浏览器默认右键事件*/
|
||||
@@ -256,6 +281,13 @@ const CoursePalyPage = () => {
|
||||
id="meedu-player-container"
|
||||
style={{ borderRadius: 8 }}
|
||||
></div>
|
||||
{checkPlayerStatus && (
|
||||
<div className={styles["alert-message"]}>
|
||||
<div className={styles["des-video"]}>
|
||||
您已打开新视频,暂停本视频播放
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
{playendedStatus && (
|
||||
<div className={styles["alert-message"]}>
|
||||
{isLastpage && (
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
import { useState } from "react";
|
||||
import { Button, Result } from "antd";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useNavigate, useLocation } from "react-router-dom";
|
||||
import styles from "./index.module.scss";
|
||||
|
||||
const ErrorPage = () => {
|
||||
const navigate = useNavigate();
|
||||
const result = new URLSearchParams(useLocation().search);
|
||||
const [status, setStatus] = useState(String(result.get("status") || "404"));
|
||||
|
||||
return (
|
||||
<Result
|
||||
status="404"
|
||||
title="404"
|
||||
title={status}
|
||||
subTitle="您访问的页面不存在"
|
||||
className={styles["main"]}
|
||||
extra={
|
||||
|
||||
@@ -298,27 +298,17 @@ const IndexPage = () => {
|
||||
{studyTimeFormat(stats.today_learn_duration)[0] ||
|
||||
0}{" "}
|
||||
</strong>
|
||||
天
|
||||
</>
|
||||
)}
|
||||
{studyTimeFormat(stats.today_learn_duration)[1] !== 0 && (
|
||||
<>
|
||||
<strong>
|
||||
{" "}
|
||||
{studyTimeFormat(stats.today_learn_duration)[1] ||
|
||||
0}{" "}
|
||||
</strong>
|
||||
小时
|
||||
</>
|
||||
)}
|
||||
<strong>
|
||||
{" "}
|
||||
{studyTimeFormat(stats.today_learn_duration)[2] || 0}{" "}
|
||||
{studyTimeFormat(stats.today_learn_duration)[1] || 0}{" "}
|
||||
</strong>
|
||||
分钟
|
||||
<strong>
|
||||
{" "}
|
||||
{studyTimeFormat(stats.today_learn_duration)[3] || 0}{" "}
|
||||
{studyTimeFormat(stats.today_learn_duration)[2] || 0}{" "}
|
||||
</strong>
|
||||
秒
|
||||
</div>
|
||||
@@ -331,27 +321,17 @@ const IndexPage = () => {
|
||||
{studyTimeFormat(stats.learn_duration || 0)[0] ||
|
||||
0}{" "}
|
||||
</strong>
|
||||
天
|
||||
</>
|
||||
)}
|
||||
{studyTimeFormat(stats.learn_duration || 0)[1] !== 0 && (
|
||||
<>
|
||||
<strong>
|
||||
{" "}
|
||||
{studyTimeFormat(stats.learn_duration || 0)[1] ||
|
||||
0}{" "}
|
||||
</strong>
|
||||
小时
|
||||
</>
|
||||
)}
|
||||
<strong>
|
||||
{" "}
|
||||
{studyTimeFormat(stats.learn_duration || 0)[2] || 0}{" "}
|
||||
{studyTimeFormat(stats.learn_duration || 0)[1] || 0}{" "}
|
||||
</strong>
|
||||
分钟
|
||||
<strong>
|
||||
{" "}
|
||||
{studyTimeFormat(stats.learn_duration || 0)[3] || 0}{" "}
|
||||
{studyTimeFormat(stats.learn_duration || 0)[2] || 0}{" "}
|
||||
</strong>
|
||||
秒
|
||||
</div>
|
||||
|
||||
@@ -5,13 +5,15 @@ import LoadingPage from "../../loading";
|
||||
|
||||
const WithHeaderWithFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<div className="layout-box">
|
||||
<Header></Header>
|
||||
<Suspense fallback={<LoadingPage height="100vh" />}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
<Footer></Footer>
|
||||
</>
|
||||
<div className="footer-box">
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -5,12 +5,14 @@ import LoadingPage from "../../loading";
|
||||
|
||||
const WithoutHeaderWithFooter = () => {
|
||||
return (
|
||||
<>
|
||||
<div className="layout-box">
|
||||
<Suspense fallback={<LoadingPage height="100vh" />}>
|
||||
<Outlet />
|
||||
</Suspense>
|
||||
<Footer></Footer>
|
||||
</>
|
||||
<div className="footer-box">
|
||||
<Footer></Footer>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ const loginUserSlice = createSlice({
|
||||
stage.value.user = e.payload.user;
|
||||
stage.value.departments = e.payload.departments;
|
||||
stage.value.isLogin = true;
|
||||
if (e.payload.departments.length > 0 && stage.value.currentDepId === 0) {
|
||||
if (e.payload.departments.length > 0 && !getDepKey()) {
|
||||
stage.value.currentDepId = e.payload.departments[0].id;
|
||||
setDepName(e.payload.departments[0].name);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ export function durationFormat(dateStr: number) {
|
||||
export function studyTimeFormat(dateStr: number) {
|
||||
var d = moment.duration(dateStr / 1000, "seconds");
|
||||
let value = [];
|
||||
value.push(Math.floor(d.asDays()));
|
||||
value.push(d.hours());
|
||||
value.push(d.minutes());
|
||||
value.push(d.seconds());
|
||||
@@ -111,3 +110,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");
|
||||
}
|
||||
|
||||
@@ -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()],
|
||||
|
||||
Reference in New Issue
Block a user