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 }