mirror of
https://github.com/PlayEdu/frontend.git
synced 2025-07-28 23:49:37 +08:00
Compare commits
6 Commits
6e920d8ea1
...
96da44a884
Author | SHA1 | Date | |
---|---|---|---|
|
96da44a884 | ||
|
39250531fb | ||
|
490ea214b3 | ||
|
b0d0063fc1 | ||
|
8614d4ebaf | ||
|
46bb144f0a |
@ -1,2 +1 @@
|
|||||||
VITE_APP_URL=
|
VITE_APP_URL=
|
||||||
VITE_G_ID=
|
|
4
.gitignore
vendored
4
.gitignore
vendored
@ -32,4 +32,6 @@ yarn.lock
|
|||||||
|
|
||||||
deploy-test.sh
|
deploy-test.sh
|
||||||
deploy-prod.sh
|
deploy-prod.sh
|
||||||
deploy-demo.sh
|
deploy-demo.sh
|
||||||
|
|
||||||
|
pnpm-lock.yaml
|
11
package.json
11
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "frontend",
|
"name": "playedu-pc-interface",
|
||||||
"private": true,
|
"private": false,
|
||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -9,25 +9,26 @@
|
|||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@ant-design/icons": "^5.3.0",
|
||||||
"@reduxjs/toolkit": "^1.9.3",
|
"@reduxjs/toolkit": "^1.9.3",
|
||||||
"add": "^2.0.6",
|
"add": "^2.0.6",
|
||||||
"antd": "^5.3.2",
|
"antd": "^5.3.2",
|
||||||
"axios": "^1.3.4",
|
"axios": "^1.3.4",
|
||||||
|
"dayjs": "^1.11.10",
|
||||||
"localforage": "^1.10.0",
|
"localforage": "^1.10.0",
|
||||||
"match-sorter": "^6.3.1",
|
"match-sorter": "^6.3.1",
|
||||||
"moment": "^2.29.4",
|
"moment": "^2.29.4",
|
||||||
"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"
|
||||||
},
|
},
|
||||||
"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",
|
||||||
|
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 { 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();
|
return <Suspense fallback={<LoadingPage />}>{views}</Suspense>;
|
||||||
useEffect(() => {
|
|
||||||
if (!G_ID) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ReactGA.pageview(location.pathname + location.search);
|
|
||||||
}, [location]);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Suspense fallback={<LoadingPage />}>
|
|
||||||
{views}
|
|
||||||
</Suspense>
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default App;
|
export default App;
|
||||||
|
@ -1,14 +1,21 @@
|
|||||||
import axios, { Axios, AxiosResponse } from "axios";
|
import axios, { Axios, AxiosResponse } from "axios";
|
||||||
import { message } from "antd";
|
import { message } from "antd";
|
||||||
import { getToken, clearToken } from "../../utils/index";
|
import {
|
||||||
|
getToken,
|
||||||
|
clearToken,
|
||||||
|
clearDepKey,
|
||||||
|
clearDepName,
|
||||||
|
} from "../../utils/index";
|
||||||
|
|
||||||
const GoLogin = () => {
|
const GoLogin = () => {
|
||||||
clearToken();
|
clearToken();
|
||||||
|
clearDepName();
|
||||||
|
clearDepKey();
|
||||||
window.location.href = "/login";
|
window.location.href = "/login";
|
||||||
};
|
};
|
||||||
|
|
||||||
const GoError = () => {
|
const GoError = (status: number) => {
|
||||||
window.location.href = "/error";
|
window.location.href = "/error?status=" + status;
|
||||||
};
|
};
|
||||||
|
|
||||||
export class HttpClient {
|
export class HttpClient {
|
||||||
@ -56,13 +63,13 @@ export class HttpClient {
|
|||||||
GoLogin();
|
GoLogin();
|
||||||
} else if (status === 404) {
|
} else if (status === 404) {
|
||||||
// 跳转到404页面
|
// 跳转到404页面
|
||||||
GoError();
|
GoError(404);
|
||||||
} else if (status === 403) {
|
} else if (status === 403) {
|
||||||
// 跳转到无权限页面
|
// 跳转到无权限页面
|
||||||
GoError();
|
GoError(403);
|
||||||
} else if (status === 500) {
|
} else if (status === 500) {
|
||||||
// 跳转到500异常页面
|
// 跳转到500异常页面
|
||||||
GoError();
|
GoError(500);
|
||||||
}
|
}
|
||||||
return Promise.reject(error.response);
|
return Promise.reject(error.response);
|
||||||
}
|
}
|
||||||
|
@ -33,6 +33,18 @@ body {
|
|||||||
min-height: 100vh;
|
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 {
|
.main-body {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: auto;
|
height: auto;
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
|
import { useState } from "react";
|
||||||
import { Button, Result } from "antd";
|
import { Button, Result } from "antd";
|
||||||
import { useNavigate } from "react-router-dom";
|
import { useNavigate, useLocation } from "react-router-dom";
|
||||||
import styles from "./index.module.scss";
|
import styles from "./index.module.scss";
|
||||||
|
|
||||||
const ErrorPage = () => {
|
const ErrorPage = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const result = new URLSearchParams(useLocation().search);
|
||||||
|
const [status, setStatus] = useState(String(result.get("status") || "404"));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Result
|
<Result
|
||||||
status="404"
|
status="404"
|
||||||
title="404"
|
title={status}
|
||||||
subTitle="您访问的页面不存在"
|
subTitle="您访问的页面不存在"
|
||||||
className={styles["main"]}
|
className={styles["main"]}
|
||||||
extra={
|
extra={
|
||||||
|
@ -5,13 +5,15 @@ import LoadingPage from "../../loading";
|
|||||||
|
|
||||||
const WithHeaderWithFooter = () => {
|
const WithHeaderWithFooter = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="layout-box">
|
||||||
<Header></Header>
|
<Header></Header>
|
||||||
<Suspense fallback={<LoadingPage height="100vh" />}>
|
<Suspense fallback={<LoadingPage height="100vh" />}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
<Footer></Footer>
|
<div className="footer-box">
|
||||||
</>
|
<Footer></Footer>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -5,12 +5,14 @@ import LoadingPage from "../../loading";
|
|||||||
|
|
||||||
const WithoutHeaderWithFooter = () => {
|
const WithoutHeaderWithFooter = () => {
|
||||||
return (
|
return (
|
||||||
<>
|
<div className="layout-box">
|
||||||
<Suspense fallback={<LoadingPage height="100vh" />}>
|
<Suspense fallback={<LoadingPage height="100vh" />}>
|
||||||
<Outlet />
|
<Outlet />
|
||||||
</Suspense>
|
</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.user = e.payload.user;
|
||||||
stage.value.departments = e.payload.departments;
|
stage.value.departments = e.payload.departments;
|
||||||
stage.value.isLogin = true;
|
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;
|
stage.value.currentDepId = e.payload.departments[0].id;
|
||||||
setDepName(e.payload.departments[0].name);
|
setDepName(e.payload.departments[0].name);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user