update @token失效调整

This commit is contained in:
huangzhen 2024-10-31 09:51:24 +08:00
parent 7ce35e0f79
commit b7763da877
2 changed files with 11 additions and 10 deletions

View File

@ -10,20 +10,20 @@ function openDialog({ text, confirmTxt }:{ text: string, confirmTxt: string }) {
unmount(); unmount();
resolve(); resolve();
} }
}) });
// 创建一个挂载容器 // 创建一个挂载容器
const parentNode = document.createElement('div') const parentNode = document.createElement('div');
document.body.appendChild(parentNode) document.body.appendChild(parentNode);
// 卸载组件 // 卸载组件
const unmount = () => { const unmount = () => {
app.unmount() app.unmount();
document.body.removeChild(parentNode) document.body.removeChild(parentNode);
} };
// 挂载组件 // 挂载组件
app.mount(parentNode) app.mount(parentNode);
}) })
} }

View File

@ -8,6 +8,7 @@ import axios from "axios";
import env from "@/utils/request/env"; import env from "@/utils/request/env";
import { ResultEnum, ContentTypeEnum } from "./httpEnum"; import { ResultEnum, ContentTypeEnum } from "./httpEnum";
import openDialog from "@/components/base-dialog/dialog"; import openDialog from "@/components/base-dialog/dialog";
import { getQueryParams } from "@/utils/methods";
interface axiosConfig { interface axiosConfig {
successMessage?: boolean; successMessage?: boolean;
@ -49,12 +50,12 @@ service.interceptors.response.use(
(err) => { (err) => {
console.log('---err---', err); console.log('---err---', err);
if (err?.response?.status === 401 || err?.response?.code === 4001) { if (err?.response?.status === 401 || err?.response?.code === 4001) {
return openDialog({ openDialog({
text: '登录过期', text: '登录过期',
confirmTxt: '重新进入' confirmTxt: '重新进入',
}) })
.then(() => { .then(() => {
location.replace(`${location.origin}/yxh5/home?loginBack=${location.href}`); location.replace(`${location.origin}/yxh5/home?loginBack=${getQueryParams('loginBack') || location.href}`);
}) })
} }
return {}; return {};