Compare commits

...

5 Commits
1.5 ... 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
14 changed files with 193 additions and 211 deletions

View File

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

2
.gitignore vendored
View File

@ -32,3 +32,5 @@ yarn.lock
deploy-test.sh deploy-test.sh
deploy-demo.sh deploy-demo.sh
pnpm-lock.yaml

View File

@ -13,11 +13,6 @@
<body> <body>
<div id="root"></div> <div id="root"></div>
<script type="module" src="/src/main.tsx"></script> <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"> <script type="text/javascript">
if ( if (
typeof WeixinJSBridge == "object" && typeof WeixinJSBridge == "object" &&

View File

@ -1,6 +1,6 @@
{ {
"name": "frontend", "name": "playedu-h5-interface",
"private": true, "private": false,
"version": "0.0.0", "version": "0.0.0",
"type": "module", "type": "module",
"scripts": { "scripts": {
@ -10,6 +10,7 @@
}, },
"dependencies": { "dependencies": {
"@reduxjs/toolkit": "^1.9.3", "@reduxjs/toolkit": "^1.9.3",
"ahooks": "^3.7.10",
"antd-mobile": "^5.31.1", "antd-mobile": "^5.31.1",
"axios": "^1.3.4", "axios": "^1.3.4",
"localforage": "^1.10.0", "localforage": "^1.10.0",
@ -18,16 +19,14 @@
"prop-types": "^15.8.1", "prop-types": "^15.8.1",
"react": "^18.2.0", "react": "^18.2.0",
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-ga": "^3.3.1",
"react-redux": "^8.0.5", "react-redux": "^8.0.5",
"react-router-dom": "^6.9.0", "react-router-dom": "^6.9.0",
"redux": "^4.2.1", "redux": "^4.2.1",
"sort-by": "^1.2.0", "sort-by": "^1.2.0"
"web-vitals": "^3.3.0"
}, },
"devDependencies": { "devDependencies": {
"@types/react": "^18.0.28", "@types/react": "^18.2.0",
"@types/react-dom": "^18.0.11", "@types/react-dom": "^18.2.0",
"@vitejs/plugin-legacy": "^4.1.1", "@vitejs/plugin-legacy": "^4.1.1",
"@vitejs/plugin-react-swc": "^3.0.0", "@vitejs/plugin-react-swc": "^3.0.0",
"rollup-plugin-gzip": "^3.1.0", "rollup-plugin-gzip": "^3.1.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 { Suspense } from "react";
import ReactGA from "react-ga"; import { useRoutes } from "react-router-dom";
import { useLocation, useRoutes } from "react-router-dom";
import routes from "./routes"; import routes from "./routes";
import "./App.scss"; import "./App.scss";
import LoadingPage from "./pages/loading"; import LoadingPage from "./pages/loading";
const G_ID = import.meta.env.VITE_G_ID || "";
if (G_ID) {
ReactGA.initialize(G_ID);
}
const App = () => { const App = () => {
const Views = () => useRoutes(routes); const Views = () => useRoutes(routes);
const location = useLocation();
useEffect(() => {
if (!G_ID) {
return;
}
ReactGA.pageview(location.pathname + location.search);
}, [location]);
return ( return (
<Suspense fallback={<LoadingPage />}> <Suspense fallback={<LoadingPage />}>
<Views /> <Views />

View File

@ -32,6 +32,13 @@ code {
float: left; float: left;
height: auto; height: auto;
} }
.float-left {
width: 100%;
height: auto;
float: left;
}
.main-header { .main-header {
position: relative; position: relative;
width: 100%; width: 100%;

View File

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

View File

@ -1,5 +1,6 @@
import { useEffect, useRef, useState } from "react"; 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 { DropdownRef } from "antd-mobile/es/components/dropdown";
import { user } from "../../api/index"; import { user } from "../../api/index";
import styles from "./index.module.scss"; import styles from "./index.module.scss";
@ -71,14 +72,15 @@ const IndexPage = () => {
}, []); }, []);
useEffect(() => { useEffect(() => {
setLoading(true);
if (currentDepId === 0) { if (currentDepId === 0) {
setLoading(false);
return; return;
} }
getData(); getData();
}, [currentDepId, categoryId]); }, [currentDepId, categoryId]);
const getData = () => { const getData = () => {
setLoading(true);
user.courses(currentDepId, categoryId).then((res: any) => { user.courses(currentDepId, categoryId).then((res: any) => {
const records = res.data.learn_course_records; const records = res.data.learn_course_records;
setLearnCourseRecords(records); setLearnCourseRecords(records);
@ -265,6 +267,17 @@ const IndexPage = () => {
</Dropdown.Item> </Dropdown.Item>
</Dropdown> </Dropdown>
</div> </div>
<div
className="float-left"
style={{ position: "relative", paddingTop: 96 }}
>
<PullToRefresh
onRefresh={async () => {
setLoading(true);
await sleep(700);
getData();
}}
>
<div className={styles["list-box"]}> <div className={styles["list-box"]}>
{loading && {loading &&
Array.from({ length: 2 }).map((_, i) => ( Array.from({ length: 2 }).map((_, i) => (
@ -320,6 +333,8 @@ const IndexPage = () => {
<Footer></Footer> <Footer></Footer>
</> </>
)} )}
</div>{" "}
</PullToRefresh>
</div> </div>
</div> </div>
); );

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 { Outlet } from "react-router-dom";
import LoadingPage from "../../loading"; import LoadingPage from "../../loading";
import { TabBarFooter } from "../../../components"; import { TabBarFooter } from "../../../components";
import styles from "./index.module.scss";
const WithoutHeaderWithoutFooter = () => { const WithoutHeaderWithoutFooter = () => {
return ( return (
<> <div className={styles["playedu-app"]}>
<Suspense fallback={<LoadingPage />}> <Suspense fallback={<LoadingPage />}>
<Outlet /> <Outlet />
</Suspense> </Suspense>
<TabBarFooter></TabBarFooter> <TabBarFooter></TabBarFooter>
</> </div>
); );
}; };

View File

@ -1,5 +1,6 @@
import { useState, useEffect } from "react"; 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 styles from "./index.module.scss";
import { course } from "../../api/index"; import { course } from "../../api/index";
import { Empty } from "../../components"; import { Empty } from "../../components";
@ -17,14 +18,11 @@ const StudyPage = () => {
}, []); }, []);
useEffect(() => { useEffect(() => {
setLoading(true);
getCourses(); getCourses();
}, []); }, []);
const getCourses = () => { const getCourses = () => {
if (loading) {
return;
}
setLoading(true);
course course
.latestLearn() .latestLearn()
.then((res: any) => { .then((res: any) => {
@ -61,6 +59,14 @@ const StudyPage = () => {
return ( return (
<div className="main-body"> <div className="main-body">
<div className={styles["title"]}></div> <div className={styles["title"]}></div>
<div className="float-left" style={{ position: "relative" }}>
<PullToRefresh
onRefresh={async () => {
setLoading(true);
await sleep(700);
getCourses();
}}
>
<div className={styles["list-box"]}> <div className={styles["list-box"]}>
{loading && {loading &&
Array.from({ length: 2 }).map((_, i) => ( Array.from({ length: 2 }).map((_, i) => (
@ -143,6 +149,8 @@ const StudyPage = () => {
</> </>
)} )}
</div> </div>
</PullToRefresh>
</div>
</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;