From f45130bd1fd7a63ac759e0a8696ab1341338e0e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E5=8B=A4=E6=B0=91?= Date: Fri, 16 Aug 2024 20:25:40 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B8=A2=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/index.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/api/index.js b/src/api/index.js index 76ba0ac..7e19db1 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -7,10 +7,6 @@ import { ElMessage } from "element-plus" // 错误处理 function errorHandle(data) { - if (data.message === "请登录") - CommonUtil.debounce(() => { - router.push("/login") - }, 1000) CommonUtil.debounce(() => { ElMessage.error(data.message) }, 1000) @@ -19,7 +15,12 @@ function errorHandle(data) { // 处理handle function handle(data) { if (data.code !== 200) { - throw Error(data.msg) + if (data.code === 401) { + CommonUtil.debounce(() => { + router.push("/login") + }, 1000) + } else + throw Error(data.msg) } return data.data }