From b7763da87793a5c58420bb653081f38200cefdf6 Mon Sep 17 00:00:00 2001 From: huangzhen Date: Thu, 31 Oct 2024 09:51:24 +0800 Subject: [PATCH] =?UTF-8?q?update=20@token=E5=A4=B1=E6=95=88=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/base-dialog/dialog.ts | 14 +++++++------- src/utils/request/index.ts | 7 ++++--- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/components/base-dialog/dialog.ts b/src/components/base-dialog/dialog.ts index 8fefe23..65eead1 100644 --- a/src/components/base-dialog/dialog.ts +++ b/src/components/base-dialog/dialog.ts @@ -10,20 +10,20 @@ function openDialog({ text, confirmTxt }:{ text: string, confirmTxt: string }) { unmount(); resolve(); } - }) + }); // 创建一个挂载容器 - const parentNode = document.createElement('div') - document.body.appendChild(parentNode) + const parentNode = document.createElement('div'); + document.body.appendChild(parentNode); // 卸载组件 const unmount = () => { - app.unmount() - document.body.removeChild(parentNode) - } + app.unmount(); + document.body.removeChild(parentNode); + }; // 挂载组件 - app.mount(parentNode) + app.mount(parentNode); }) } diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts index 7ab3d25..f10155e 100644 --- a/src/utils/request/index.ts +++ b/src/utils/request/index.ts @@ -8,6 +8,7 @@ import axios from "axios"; import env from "@/utils/request/env"; import { ResultEnum, ContentTypeEnum } from "./httpEnum"; import openDialog from "@/components/base-dialog/dialog"; +import { getQueryParams } from "@/utils/methods"; interface axiosConfig { successMessage?: boolean; @@ -49,12 +50,12 @@ service.interceptors.response.use( (err) => { console.log('---err---', err); if (err?.response?.status === 401 || err?.response?.code === 4001) { - return openDialog({ + openDialog({ text: '登录过期', - confirmTxt: '重新进入' + confirmTxt: '重新进入', }) .then(() => { - location.replace(`${location.origin}/yxh5/home?loginBack=${location.href}`); + location.replace(`${location.origin}/yxh5/home?loginBack=${getQueryParams('loginBack') || location.href}`); }) } return {};