From 37561068a3c91c964a2af4f2c673e4909c009494 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B0=8F=E9=9C=9E?= <1571974166@qq.com> Date: Thu, 6 Feb 2025 12:06:05 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/request.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/utils/request.ts b/src/utils/request.ts index 9461909..d469a41 100644 --- a/src/utils/request.ts +++ b/src/utils/request.ts @@ -1,5 +1,6 @@ import axios from "axios"; import { ElMessage } from 'element-plus' +import { useRouter } from "vue-router"; interface requestType { url: string @@ -7,13 +8,13 @@ interface requestType { } const handleCode = async (code: number, msg: string) => { console.log(code); - + const router = useRouter(); switch (code) { case 401: ElMessage.error(msg || '登录失效') setTimeout(() => { console.log('登录失效') - location.href = "/login" + router.push("/login") }, 1500) // 跳转登录 break