diff --git a/src/api/internal/httpClient.ts b/src/api/internal/httpClient.ts index 7f19cb9..54b6ccb 100644 --- a/src/api/internal/httpClient.ts +++ b/src/api/internal/httpClient.ts @@ -14,8 +14,8 @@ const GoLogin = () => { window.location.href = "/login"; }; -const GoError = () => { - window.location.href = "/error"; +const GoError = (status: number) => { + window.location.href = "/error?status=" + status; }; export class HttpClient { @@ -63,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); } diff --git a/src/pages/error/index.tsx b/src/pages/error/index.tsx index 28460b6..3de9b8c 100644 --- a/src/pages/error/index.tsx +++ b/src/pages/error/index.tsx @@ -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 ( 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); }