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 ElMessage: (typeof import("element-plus/es"))["ElMessage"];
|
||||
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 acceptHMRUpdate: (typeof import("pinia"))["acceptHMRUpdate"];
|
||||
const asyncComputed: (typeof import("@vueuse/core"))["asyncComputed"];
|
||||
|
||||
@@ -48,15 +48,14 @@ service.interceptors.response.use(
|
||||
if (error.response.data) {
|
||||
const { code, msg } = error.response.data;
|
||||
if (code === ResultEnum.TOKEN_INVALID) {
|
||||
ElMessageBox.confirm("当前页面已失效,请重新登录", "提示", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
type: "warning",
|
||||
}).then(() => {
|
||||
const userStore = useUserStoreHook();
|
||||
userStore.resetToken().then(() => {
|
||||
location.reload();
|
||||
});
|
||||
ElNotification({
|
||||
title: "提示",
|
||||
message: "您的会话已过期,请重新登录",
|
||||
type: "info",
|
||||
});
|
||||
const userStore = useUserStoreHook();
|
||||
userStore.resetToken().then(() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
ElMessage.error(msg || "系统出错");
|
||||
|
||||
Reference in New Issue
Block a user