From 404b493d23bbfe0e59d27c1619abac7c367924f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BB=96=E5=BD=A6=E6=A3=8B?= Date: Thu, 7 Mar 2024 18:03:06 +0800 Subject: [PATCH] =?UTF-8?q?feat(ui):=20=E8=BF=87=E6=9C=9F=E8=B7=B3?= =?UTF-8?q?=E8=BD=AC=E7=99=BB=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gpt-vue/projects/vue-admin/src/http/config.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gpt-vue/projects/vue-admin/src/http/config.ts b/gpt-vue/projects/vue-admin/src/http/config.ts index 95ff3eff..1e07e4eb 100644 --- a/gpt-vue/projects/vue-admin/src/http/config.ts +++ b/gpt-vue/projects/vue-admin/src/http/config.ts @@ -1,3 +1,4 @@ +import router from "@/router"; import { Notification } from "@arco-design/web-vue"; import createInstance from "@gpt-vue/packages/request" import type { BaseResponse } from "@gpt-vue/packages/type"; @@ -16,6 +17,10 @@ instance.interceptors.response.use( (response) => { const { data }: { data: BaseResponse } = response if (data && typeof data === "object" && data.code !== 0) { + if (data.code === 400) { + localStorage.removeItem(__AUTH_KEY); + router.push({ name: "Login" }) + } Notification.error(data.message ?? '未知错误') } return { data, response } as any;