Compare commits

...

15 Commits
v1.2 ... main

Author SHA1 Message Date
xxx
387c930795 移除 react-ga 和 web-vitals 依赖 2024-02-20 14:56:48 +08:00
xxx
263a3abccb 移除xgplayer && 修复pnpm build 和 dev 报错 2024-02-20 14:54:17 +08:00
xxx
8a3bbd565b fixed: 底部导航栏悬浮bug 2024-01-09 09:32:46 +08:00
xxx
f71df2a461 移除hls.min.js的依赖 2024-01-08 16:14:56 +08:00
unknown
5e054cdd54 下拉刷新 2024-01-08 12:28:43 +08:00
unknown
19df4739ad 会员中心学习时间不显示天 2023-11-15 10:04:45 +08:00
白书科技
e5315f621f
!3 优化
Merge pull request !3 from 白书科技/fix/0922
2023-09-24 00:47:56 +00:00
unknown
0f811618b7 iconfont优化 2023-09-22 15:29:30 +08:00
xxx
21e152cb74 兼容安卓钉钉 2023-09-20 10:23:06 +08:00
滕勇志
23b332826d
Merge pull request #3 from PlayEdu/dev
v1.3
2023-09-06 17:10:42 +08:00
白书科技
95b7b2306e
!2 优化
Merge pull request !2 from 白书科技/fix/0906
2023-09-06 01:55:31 +00:00
unknown
e7ed87649d 登录页面文案修改 2023-09-06 09:49:21 +08:00
白书科技
c445b4c04e
!1 优化
Merge pull request !1 from 白书科技/fix/0904
2023-09-04 09:11:34 +00:00
unknown
34dd41a810 学员登录ldap优化 2023-09-04 17:03:19 +08:00
unknown
5d03a69888 学员登录ldap优化 2023-09-04 16:57:32 +08:00
22 changed files with 252 additions and 248 deletions

View File

@ -1,2 +1 @@
VITE_APP_URL=
VITE_G_ID=
VITE_APP_URL=

4
.gitignore vendored
View File

@ -31,4 +31,6 @@ yarn.lock
.env
deploy-test.sh
deploy-demo.sh
deploy-demo.sh
pnpm-lock.yaml

View File

@ -13,11 +13,6 @@
<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>
<script type="text/javascript">
if (
typeof WeixinJSBridge == "object" &&

View File

@ -1,6 +1,6 @@
{
"name": "frontend",
"private": true,
"name": "playedu-h5-interface",
"private": false,
"version": "0.0.0",
"type": "module",
"scripts": {
@ -10,6 +10,7 @@
},
"dependencies": {
"@reduxjs/toolkit": "^1.9.3",
"ahooks": "^3.7.10",
"antd-mobile": "^5.31.1",
"axios": "^1.3.4",
"localforage": "^1.10.0",
@ -18,19 +19,19 @@
"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",
"web-vitals": "^3.3.0"
"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.19.4",
"typescript": "^4.9.3",
"vite": "^4.2.0"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,26 +1,12 @@
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 />

View File

@ -10,3 +10,10 @@ export function login(email: string, password: string) {
export function logout() {
return client.post("/api/v1/auth/logout", {});
}
export function loginLdap(email: string, password: string) {
return client.post("/api/v1/auth/login/ldap", {
username: email,
password: password,
});
}

View File

@ -1,5 +1,3 @@
@import "./assets/iconfont/iconfont.css";
body {
margin: 0;
}
@ -34,6 +32,13 @@ code {
float: left;
height: auto;
}
.float-left {
width: 100%;
height: auto;
float: left;
}
.main-header {
position: relative;
width: 100%;

View File

@ -2,6 +2,7 @@ import ReactDOM from "react-dom/client";
import { Provider } from "react-redux";
import store from "./store";
import { BrowserRouter } from "react-router-dom";
import "./assets/iconfont/iconfont.css";
import "./main.scss";
import App from "./App";
import AutoScorllTop from "./AutoTop";

View File

@ -107,7 +107,7 @@
width: 100%;
height: auto;
box-sizing: border-box;
padding: 96px 20px 55px 20px;
padding: 0px 20px 55px 20px;
text-align: left;
overflow-x: hidden;
overflow-y: auto;

View File

@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from "react";
import { Dropdown, Skeleton, Tabs } from "antd-mobile";
import { Dropdown, PullToRefresh, Skeleton, Tabs } from "antd-mobile";
import { sleep } from "antd-mobile/es/utils/sleep";
import { DropdownRef } from "antd-mobile/es/components/dropdown";
import { user } from "../../api/index";
import styles from "./index.module.scss";
@ -71,14 +72,15 @@ const IndexPage = () => {
}, []);
useEffect(() => {
setLoading(true);
if (currentDepId === 0) {
setLoading(false);
return;
}
getData();
}, [currentDepId, categoryId]);
const getData = () => {
setLoading(true);
user.courses(currentDepId, categoryId).then((res: any) => {
const records = res.data.learn_course_records;
setLearnCourseRecords(records);
@ -265,61 +267,74 @@ const IndexPage = () => {
</Dropdown.Item>
</Dropdown>
</div>
<div className={styles["list-box"]}>
{loading &&
Array.from({ length: 2 }).map((_, i) => (
<div
style={{
width: "100%",
height: 75,
display: "flex",
alignItems: "center",
marginBottom: 30,
marginTop: 30,
}}
key={i}
>
<Skeleton
animated
style={{
width: 100,
height: 75,
borderRadius: 8,
marginRight: 15,
}}
/>
<div
style={{
flex: 1,
height: 75,
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
}}
>
<Skeleton animated style={{ width: "100%", height: 21 }} />
<Skeleton animated style={{ width: "100%", height: 24 }} />
</div>
</div>
))}
{!loading && coursesList.length === 0 && <Empty></Empty>}
{!loading && coursesList.length > 0 && (
<>
{coursesList.map((item: any) => (
<div className={styles["item"]} key={item.id}>
<CoursesModel
id={item.id}
title={item.title}
thumb={item.thumb}
isRequired={item.is_required}
record={learnCourseRecords[item.id]}
hourCount={learnCourseHourCount[item.id]}
></CoursesModel>
</div>
))}
<Footer></Footer>
</>
)}
<div
className="float-left"
style={{ position: "relative", paddingTop: 96 }}
>
<PullToRefresh
onRefresh={async () => {
setLoading(true);
await sleep(700);
getData();
}}
>
<div className={styles["list-box"]}>
{loading &&
Array.from({ length: 2 }).map((_, i) => (
<div
style={{
width: "100%",
height: 75,
display: "flex",
alignItems: "center",
marginBottom: 30,
marginTop: 30,
}}
key={i}
>
<Skeleton
animated
style={{
width: 100,
height: 75,
borderRadius: 8,
marginRight: 15,
}}
/>
<div
style={{
flex: 1,
height: 75,
display: "flex",
flexDirection: "column",
justifyContent: "space-between",
}}
>
<Skeleton animated style={{ width: "100%", height: 21 }} />
<Skeleton animated style={{ width: "100%", height: 24 }} />
</div>
</div>
))}
{!loading && coursesList.length === 0 && <Empty></Empty>}
{!loading && coursesList.length > 0 && (
<>
{coursesList.map((item: any) => (
<div className={styles["item"]} key={item.id}>
<CoursesModel
id={item.id}
title={item.title}
thumb={item.thumb}
isRequired={item.is_required}
record={learnCourseRecords[item.id]}
hourCount={learnCourseHourCount[item.id]}
></CoursesModel>
</div>
))}
<Footer></Footer>
</>
)}
</div>{" "}
</PullToRefresh>
</div>
</div>
);

View File

@ -24,6 +24,7 @@ export const InitPage = (props: Props) => {
if (props.configData) {
let config: SystemConfigStoreInterface = {
//系统配置
"ldap-enabled": props.configData["ldap-enabled"],
systemApiUrl: props.configData["system-api-url"],
systemH5Url: props.configData["system-h5-url"],
systemLogo: props.configData["system-logo"],

View File

@ -0,0 +1,7 @@
.playedu-app {
width: 100vw;
height: 100vh;
overflow-y: auto;
overflow-x: hidden;
position: relative;
}

View File

@ -2,15 +2,16 @@ import { Suspense } from "react";
import { Outlet } from "react-router-dom";
import LoadingPage from "../../loading";
import { TabBarFooter } from "../../../components";
import styles from "./index.module.scss";
const WithoutHeaderWithoutFooter = () => {
return (
<>
<div className={styles["playedu-app"]}>
<Suspense fallback={<LoadingPage />}>
<Outlet />
</Suspense>
<TabBarFooter></TabBarFooter>
</>
</div>
);
};

View File

@ -1,7 +1,7 @@
import { useState, useEffect } from "react";
import { Button, Toast, Input, Image } from "antd-mobile";
import styles from "./index.module.scss";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { useNavigate } from "react-router-dom";
import { login, system, user } from "../../api/index";
import { setToken } from "../../utils/index";
@ -19,6 +19,7 @@ const LoginPage = () => {
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const [bodyHeight, setBodyHeight] = useState(0);
const systemConfig = useSelector((state: any) => state.systemConfig.value);
useEffect(() => {
document.title = "登录";
@ -29,7 +30,7 @@ const LoginPage = () => {
const loginSubmit = async (e: any) => {
if (!email) {
Toast.show({
content: "请输入学员邮箱账号",
content: "请输入邮箱或UID",
});
return;
}
@ -47,17 +48,32 @@ const LoginPage = () => {
return;
}
setLoading(true);
try {
let res: any = await login.login(email, password);
setToken(res.data.token); //将token写入本地
await getSystemConfig(); //获取系统配置并写入store
await getUser(); //获取登录用户的信息并写入store
setLoading(false);
navigate("/member", { replace: true });
} catch (e) {
console.error("错误信息", e);
setLoading(false);
if (systemConfig["ldap-enabled"] === "1") {
try {
let res: any = await login.loginLdap(email, password);
setToken(res.data.token); //将token写入本地
await getSystemConfig(); //获取系统配置并写入store
await getUser(); //获取登录用户的信息并写入store
setLoading(false);
navigate("/member", { replace: true });
} catch (e) {
console.error("错误信息", e);
setLoading(false);
}
}else{
try {
let res: any = await login.login(email, password);
setToken(res.data.token); //将token写入本地
await getSystemConfig(); //获取系统配置并写入store
await getUser(); //获取登录用户的信息并写入store
setLoading(false);
navigate("/member", { replace: true });
} catch (e) {
console.error("错误信息", e);
setLoading(false);
}
}
};
const getUser = async () => {
@ -70,6 +86,7 @@ const LoginPage = () => {
if (configRes.data) {
let config: SystemConfigStoreInterface = {
//系统配置
"ldap-enabled": configRes.data["ldap-enabled"],
systemApiUrl: configRes.data["system-api-url"],
systemH5Url: configRes.data["system-h5-url"],
systemLogo: configRes.data["system-logo"],
@ -110,7 +127,7 @@ const LoginPage = () => {
<div className={styles["input-box"]}>
<Input
className={styles["input-item"]}
placeholder="请输入学员邮箱账号"
placeholder="请输入邮箱或UID"
value={email}
onChange={(val) => {
setEmail(val);

View File

@ -22,10 +22,8 @@ const MemberPage = () => {
url: "",
},
]);
const [learnTodayDay, setLearnTodayDay] = useState(0);
const [learnTodayHour, setLearnTodayHour] = useState(0);
const [learnTodayMin, setLearnTodayMin] = useState(0);
const [learnTotalDay, setLearnTotalDay] = useState(0);
const [learnTotalHour, setLearnTotalHour] = useState(0);
const [learnTotalMin, setLearnTotalMin] = useState(0);
const user = useSelector((state: any) => state.loginUser.value.user);
@ -60,19 +58,17 @@ const MemberPage = () => {
setStats(res.data.stats);
let todayData = studyTimeFormat(res.data.stats.today_learn_duration);
if (todayData) {
setLearnTodayDay(todayData[0]);
setLearnTodayHour(todayData[1]);
setLearnTodayMin(todayData[2]);
if (todayData[2] === 0 && todayData[3] > 0) {
setLearnTodayHour(todayData[0]);
setLearnTodayMin(todayData[1]);
if (todayData[1] === 0 && todayData[2] > 0) {
setLearnTodayMin(1);
}
}
let totalData = studyTimeFormat(res.data.stats.learn_duration);
if (totalData) {
setLearnTotalDay(totalData[0]);
setLearnTotalHour(totalData[1]);
setLearnTotalMin(totalData[2]);
if (totalData[2] === 0 && totalData[3] > 0) {
setLearnTotalHour(totalData[0]);
setLearnTotalMin(totalData[1]);
if (totalData[1] === 0 && totalData[2] > 0) {
setLearnTodayMin(1);
}
}
@ -191,11 +187,6 @@ const MemberPage = () => {
<div className={styles["stats-content"]}>
<div className={styles["stat-item"]}>
<span className={styles["time"]}>
{learnTodayDay > 0 && (
<>
<strong>{learnTodayDay} </strong>
</>
)}
<strong> {learnTodayHour} </strong>
<strong> {learnTodayMin} </strong>
</span>
@ -203,11 +194,6 @@ const MemberPage = () => {
</div>
<div className={styles["stat-item"]}>
<span className={styles["time"]}>
{learnTotalDay > 0 && (
<>
<strong>{learnTotalDay} </strong>
</>
)}
<strong> {learnTotalHour} </strong>
<strong> {learnTotalMin} </strong>
</span>

View File

@ -1,5 +1,6 @@
import { useState, useEffect } from "react";
import { Skeleton } from "antd-mobile";
import { PullToRefresh, Skeleton } from "antd-mobile";
import { sleep } from "antd-mobile/es/utils/sleep";
import styles from "./index.module.scss";
import { course } from "../../api/index";
import { Empty } from "../../components";
@ -17,14 +18,11 @@ const StudyPage = () => {
}, []);
useEffect(() => {
setLoading(true);
getCourses();
}, []);
const getCourses = () => {
if (loading) {
return;
}
setLoading(true);
course
.latestLearn()
.then((res: any) => {
@ -61,87 +59,97 @@ const StudyPage = () => {
return (
<div className="main-body">
<div className={styles["title"]}></div>
<div className={styles["list-box"]}>
{loading &&
Array.from({ length: 2 }).map((_, i) => (
<div className={styles["item"]} key={i}>
<Skeleton
animated
style={{
width: 100,
height: 75,
borderRadius: 8,
marginRight: 15,
}}
/>
<div className={styles["item-info"]}>
<Skeleton animated style={{ width: "100%", height: 21 }} />
<Skeleton animated style={{ width: "100%", height: 24 }} />
</div>
</div>
))}
{!loading &&
courses.length === 0 &&
todayCourses.length === 0 &&
yesterdayCourses.length === 0 && <Empty></Empty>}
{!loading && (
<>
{todayCourses.length > 0 && (
<>
<div className={styles["label"]}></div>
{todayCourses.map((item: any, index: number) => (
<div key={index} style={{ width: "100%" }}>
{item.course && (
<CoursesModel
id={item.course.id}
title={item.course.title}
thumb={item.course.thumb}
isRequired={item.course.is_required}
record={item.record}
></CoursesModel>
)}
<div className="float-left" style={{ position: "relative" }}>
<PullToRefresh
onRefresh={async () => {
setLoading(true);
await sleep(700);
getCourses();
}}
>
<div className={styles["list-box"]}>
{loading &&
Array.from({ length: 2 }).map((_, i) => (
<div className={styles["item"]} key={i}>
<Skeleton
animated
style={{
width: 100,
height: 75,
borderRadius: 8,
marginRight: 15,
}}
/>
<div className={styles["item-info"]}>
<Skeleton animated style={{ width: "100%", height: 21 }} />
<Skeleton animated style={{ width: "100%", height: 24 }} />
</div>
))}
</div>
))}
{!loading &&
courses.length === 0 &&
todayCourses.length === 0 &&
yesterdayCourses.length === 0 && <Empty></Empty>}
{!loading && (
<>
{todayCourses.length > 0 && (
<>
<div className={styles["label"]}></div>
{todayCourses.map((item: any, index: number) => (
<div key={index} style={{ width: "100%" }}>
{item.course && (
<CoursesModel
id={item.course.id}
title={item.course.title}
thumb={item.course.thumb}
isRequired={item.course.is_required}
record={item.record}
></CoursesModel>
)}
</div>
))}
</>
)}
{yesterdayCourses.length > 0 && (
<>
<div className={styles["label"]}></div>
{yesterdayCourses.map((item: any, index: number) => (
<div key={index} style={{ width: "100%" }}>
{item.course && (
<CoursesModel
id={item.course.id}
title={item.course.title}
thumb={item.course.thumb}
isRequired={item.course.is_required}
record={item.record}
></CoursesModel>
)}
</div>
))}
</>
)}
{courses.length > 0 && (
<>
<div className={styles["label"]}></div>
{courses.map((item: any, index: number) => (
<div key={index} style={{ width: "100%" }}>
{item.course && (
<CoursesModel
id={item.course.id}
title={item.course.title}
thumb={item.course.thumb}
isRequired={item.course.is_required}
record={item.record}
></CoursesModel>
)}
</div>
))}
</>
)}
</>
)}
{yesterdayCourses.length > 0 && (
<>
<div className={styles["label"]}></div>
{yesterdayCourses.map((item: any, index: number) => (
<div key={index} style={{ width: "100%" }}>
{item.course && (
<CoursesModel
id={item.course.id}
title={item.course.title}
thumb={item.course.thumb}
isRequired={item.course.is_required}
record={item.record}
></CoursesModel>
)}
</div>
))}
</>
)}
{courses.length > 0 && (
<>
<div className={styles["label"]}></div>
{courses.map((item: any, index: number) => (
<div key={index} style={{ width: "100%" }}>
{item.course && (
<CoursesModel
id={item.course.id}
title={item.course.title}
thumb={item.course.thumb}
isRequired={item.course.is_required}
record={item.record}
></CoursesModel>
)}
</div>
))}
</>
)}
</>
)}
</div>
</PullToRefresh>
</div>
</div>
);

View File

@ -1,15 +0,0 @@
import { ReportHandler } from 'web-vitals';
const reportWebVitals = (onPerfEntry?: ReportHandler) => {
if (onPerfEntry && onPerfEntry instanceof Function) {
import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => {
getCLS(onPerfEntry);
getFID(onPerfEntry);
getFCP(onPerfEntry);
getLCP(onPerfEntry);
getTTFB(onPerfEntry);
});
}
};
export default reportWebVitals;

View File

@ -1,6 +1,7 @@
import { createSlice } from "@reduxjs/toolkit";
type SystemConfigStoreInterface = {
"ldap-enabled": string;
systemApiUrl: string;
systemPcUrl: string;
systemH5Url: string;
@ -16,6 +17,7 @@ type SystemConfigStoreInterface = {
};
let defaultValue: SystemConfigStoreInterface = {
"ldap-enabled": "",
systemApiUrl: "",
systemPcUrl: "",
systemH5Url: "",

View File

@ -54,7 +54,6 @@ export function changeAppUrl(str: string) {
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());

View File

@ -1,13 +1,22 @@
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({
server: {
host: "0.0.0.0",
},
plugins: [react()],
plugins: [
react(),
legacy({
targets: ["chrome 52"],
additionalLegacyPolyfills: ["regenerator-runtime/runtime"],
renderLegacyChunks: true,
modernPolyfills: true,
}),
],
build: {
rollupOptions: {
plugins: [gzipPlugin()],