mirror of
https://github.com/PlayEdu/backend
synced 2025-06-10 22:54:10 +08:00
错误页面
This commit is contained in:
parent
23d0e6265c
commit
5f959f3719
@ -3,7 +3,7 @@ import client from "./internal/httpClient";
|
||||
export function adminLogList(
|
||||
page: number,
|
||||
size: number,
|
||||
admin_id: number | null,
|
||||
admin_id: string,
|
||||
title: string,
|
||||
opt: string,
|
||||
start_time: string,
|
||||
|
@ -7,8 +7,8 @@ const GoLogin = () => {
|
||||
window.location.href = "/login";
|
||||
};
|
||||
|
||||
const GoError = () => {
|
||||
window.location.href = "/error";
|
||||
const GoError = (code: number) => {
|
||||
window.location.href = "/error?code=" + code;
|
||||
};
|
||||
|
||||
export class HttpClient {
|
||||
@ -56,13 +56,16 @@ export class HttpClient {
|
||||
GoLogin();
|
||||
} else if (status === 404) {
|
||||
// 跳转到404页面
|
||||
GoError();
|
||||
GoError(404);
|
||||
} else if (status === 403) {
|
||||
// 跳转到无权限页面
|
||||
GoError();
|
||||
GoError(403);
|
||||
} else if (status === 429) {
|
||||
// 跳转到429页面
|
||||
GoError(429);
|
||||
} else if (status === 500) {
|
||||
// 跳转到500异常页面
|
||||
GoError();
|
||||
GoError(500);
|
||||
}
|
||||
return Promise.reject(error.response);
|
||||
}
|
||||
|
@ -1,15 +1,35 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { Button, Result } from "antd";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { useParams, useNavigate, useLocation } from "react-router-dom";
|
||||
import styles from "./index.module.less";
|
||||
|
||||
const ErrorPage = () => {
|
||||
const navigate = useNavigate();
|
||||
const result = new URLSearchParams(useLocation().search);
|
||||
const [code, setCode] = useState(Number(result.get("code")));
|
||||
const [error, setError] = useState("");
|
||||
|
||||
useEffect(() => {
|
||||
setCode(Number(result.get("code")));
|
||||
}, [result.get("code")]);
|
||||
|
||||
useEffect(() => {
|
||||
if (code === 403) {
|
||||
setError("无权限操作");
|
||||
} else if (code === 404) {
|
||||
setError("URL或资源不存在");
|
||||
} else if (code === 429) {
|
||||
setError("请求次数过多,请稍后再试");
|
||||
} else {
|
||||
setError("系统错误");
|
||||
}
|
||||
}, [code]);
|
||||
|
||||
return (
|
||||
<Result
|
||||
status="404"
|
||||
title="404"
|
||||
subTitle="您访问的页面不存在"
|
||||
title={code}
|
||||
subTitle={error}
|
||||
className={styles["main"]}
|
||||
extra={
|
||||
<Button
|
||||
|
@ -1,13 +1,5 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import {
|
||||
Table,
|
||||
Typography,
|
||||
Input,
|
||||
Select,
|
||||
Space,
|
||||
Button,
|
||||
DatePicker,
|
||||
} from "antd";
|
||||
import { Table, Typography, Input, Button, DatePicker } from "antd";
|
||||
import { adminLog } from "../../../api";
|
||||
// import styles from "./index.module.less";
|
||||
import type { ColumnsType } from "antd/es/table";
|
||||
@ -38,7 +30,7 @@ const SystemLogPage = () => {
|
||||
const [total, setTotal] = useState(0);
|
||||
const [refresh, setRefresh] = useState(false);
|
||||
const [title, setTitle] = useState("");
|
||||
const [adminId, setAdminId] = useState(0);
|
||||
const [adminId, setAdminId] = useState("");
|
||||
const [created_at, setCreatedAt] = useState<any>([]);
|
||||
const [createdAts, setCreatedAts] = useState<any>([]);
|
||||
const [param, setParam] = useState("");
|
||||
@ -55,7 +47,7 @@ const SystemLogPage = () => {
|
||||
.adminLogList(
|
||||
page,
|
||||
size,
|
||||
adminId > 0 ? adminId : null,
|
||||
adminId,
|
||||
title,
|
||||
"",
|
||||
created_at[0],
|
||||
@ -73,7 +65,7 @@ const SystemLogPage = () => {
|
||||
|
||||
const resetData = () => {
|
||||
setTitle("");
|
||||
setAdminId(0);
|
||||
setAdminId("");
|
||||
setPage(1);
|
||||
setSize(10);
|
||||
setList([]);
|
||||
@ -107,7 +99,7 @@ const SystemLogPage = () => {
|
||||
render: (_, record: any) => <span>{record.id}</span>,
|
||||
},
|
||||
{
|
||||
title: "管理员",
|
||||
title: "管理员名称",
|
||||
width: 150,
|
||||
render: (_, record: any) => <span>{record.admin_name}</span>,
|
||||
},
|
||||
@ -156,6 +148,31 @@ const SystemLogPage = () => {
|
||||
<div className="d-flex"></div>
|
||||
<div className="d-flex">
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>标题:</Typography.Text>
|
||||
<Input
|
||||
value={title}
|
||||
onChange={(e) => {
|
||||
setTitle(e.target.value);
|
||||
}}
|
||||
allowClear
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入标题"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>管理员ID:</Typography.Text>
|
||||
<Input
|
||||
value={adminId}
|
||||
onChange={(e) => {
|
||||
setAdminId(e.target.value);
|
||||
}}
|
||||
allowClear
|
||||
style={{ width: 160 }}
|
||||
placeholder="请输入管理员ID"
|
||||
/>
|
||||
</div>
|
||||
<div className="d-flex mr-24">
|
||||
<Typography.Text>时间:</Typography.Text>
|
||||
<RangePicker
|
||||
disabledDate={disabledDate}
|
||||
format={"YYYY-MM-DD"}
|
||||
|
Loading…
x
Reference in New Issue
Block a user