From 7bc5d67efcc3f7a5d1e45f1bfc7b394de05b1e22 Mon Sep 17 00:00:00 2001 From: Yer <17633066053@163.com> Date: Tue, 25 Jul 2023 10:10:20 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20:sparkles:=20=E5=95=86=E5=AE=B6?= =?UTF-8?q?=E7=AB=AF=E6=96=B0=E5=A2=9Eredirect=E7=99=BB=E5=BD=95=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seller/src/libs/axios.js | 15 ++++++++++++--- seller/src/views/login.vue | 12 ++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/seller/src/libs/axios.js b/seller/src/libs/axios.js index 031a79db..7b2bf38c 100644 --- a/seller/src/libs/axios.js +++ b/seller/src/libs/axios.js @@ -1,6 +1,6 @@ import axios from "axios"; import { getStore, setStore } from "./storage"; -import { router } from "../router/index"; +import { router } from "../router/index"; import { Message } from "view-design"; import Cookies from "js-cookie"; import { handleRefreshToken } from "@/api/index"; @@ -23,6 +23,15 @@ const service = axios.create({ timeout: 10000, baseURL: baseUrl }); + +const recordCurrentPath = () => { + return router.history.current.fullPath +} +// 跳转登录页 +const redirectLogin = () => { + router.push({path:'/login',query:{redirect: recordCurrentPath()}}); +} + service.interceptors.request.use( config => { if (config.method == "get") { @@ -72,7 +81,7 @@ service.interceptors.response.use( } else { Message.error("未知错误,请重新登录"); } - router.push("/login"); + redirectLogin(); } break; case 500: @@ -110,7 +119,7 @@ service.interceptors.response.use( } } else { Cookies.set("userInfoSeller", ""); - router.push("/login"); + redirectLogin(); } isRefreshToken = 0; } diff --git a/seller/src/views/login.vue b/seller/src/views/login.vue index 1b8b31f7..147c2424 100644 --- a/seller/src/views/login.vue +++ b/seller/src/views/login.vue @@ -1,4 +1,4 @@ -