refactor: ♻️ 优化会话过期提示
This commit is contained in:
1
src/types/auto-imports.d.ts
vendored
1
src/types/auto-imports.d.ts
vendored
@@ -9,6 +9,7 @@ declare global {
|
|||||||
const ElForm: (typeof import("element-plus/es"))["ElForm"];
|
const ElForm: (typeof import("element-plus/es"))["ElForm"];
|
||||||
const ElMessage: (typeof import("element-plus/es"))["ElMessage"];
|
const ElMessage: (typeof import("element-plus/es"))["ElMessage"];
|
||||||
const ElMessageBox: (typeof import("element-plus/es"))["ElMessageBox"];
|
const ElMessageBox: (typeof import("element-plus/es"))["ElMessageBox"];
|
||||||
|
const ElNotification: (typeof import("element-plus/es"))["ElNotification"];
|
||||||
const ElTree: (typeof import("element-plus/es"))["ElTree"];
|
const ElTree: (typeof import("element-plus/es"))["ElTree"];
|
||||||
const acceptHMRUpdate: (typeof import("pinia"))["acceptHMRUpdate"];
|
const acceptHMRUpdate: (typeof import("pinia"))["acceptHMRUpdate"];
|
||||||
const asyncComputed: (typeof import("@vueuse/core"))["asyncComputed"];
|
const asyncComputed: (typeof import("@vueuse/core"))["asyncComputed"];
|
||||||
|
|||||||
@@ -48,15 +48,14 @@ service.interceptors.response.use(
|
|||||||
if (error.response.data) {
|
if (error.response.data) {
|
||||||
const { code, msg } = error.response.data;
|
const { code, msg } = error.response.data;
|
||||||
if (code === ResultEnum.TOKEN_INVALID) {
|
if (code === ResultEnum.TOKEN_INVALID) {
|
||||||
ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
|
ElNotification({
|
||||||
confirmButtonText: "确定",
|
title: "提示",
|
||||||
cancelButtonText: "取消",
|
message: "您的会话已过期,请重新登录",
|
||||||
type: "warning",
|
type: "info",
|
||||||
}).then(() => {
|
});
|
||||||
const userStore = useUserStoreHook();
|
const userStore = useUserStoreHook();
|
||||||
userStore.resetToken().then(() => {
|
userStore.resetToken().then(() => {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
ElMessage.error(msg || "系统出错");
|
ElMessage.error(msg || "系统出错");
|
||||||
|
|||||||
Reference in New Issue
Block a user