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 {};