From b0d0063fc155e459308bb00258a301eaa0897abd Mon Sep 17 00:00:00 2001 From: unknown <18119604035@163.com> Date: Thu, 1 Feb 2024 09:50:00 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E9=83=A8=E7=BD=B2=E7=B3=BB=E7=BB=9F?= =?UTF-8?q?=E6=97=B6=E9=83=A8=E9=97=A8storage=E5=AD=98=E5=82=A8=E4=BC=98?= =?UTF-8?q?=E5=8C=96=E4=BB=A5=E5=8F=8Aerror=E9=A1=B5=E9=9D=A2=E6=98=BE?= =?UTF-8?q?=E7=A4=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/internal/httpClient.ts | 10 +++++----- src/pages/error/index.tsx | 7 +++++-- src/store/user/loginUserSlice.ts | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) 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); }