1.解决多个接口报错,出现多个提示的问题
parent
3b94706425
commit
975d92d970
|
|
@ -28,7 +28,7 @@
|
|||
</el-form-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<el-form-item label="文章分类">
|
||||
<el-form-item label="类型">
|
||||
<el-select v-model="form.type" multiple collapse-tags placeholder="请选择优惠券类型">
|
||||
<el-option v-for="item in base_list.coupon_type_list" :key="item.value" :label="item.name" :value="item.value" />
|
||||
</el-select>
|
||||
|
|
@ -74,7 +74,7 @@ const new_url = ref('');
|
|||
const base_list = reactive({
|
||||
data_type_list: [
|
||||
{ name: '默认', value: '0' },
|
||||
{ name: '手动', value: '1' },
|
||||
{ name: '自动', value: '1' },
|
||||
],
|
||||
themeList: Array.from({ length: 7 }, (_, index) => ({
|
||||
id: String(index + 1),
|
||||
|
|
|
|||
|
|
@ -1,6 +1,20 @@
|
|||
import axios, { InternalAxiosRequestConfig, AxiosResponse } from 'axios';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { ElMessage, ElMessageBox, type MessageHandler } from 'element-plus';
|
||||
import { get_cookie } from './index';
|
||||
|
||||
// 提示拦截
|
||||
|
||||
let messageInstance: MessageHandler;
|
||||
const message_error = (info: string) => {
|
||||
if (messageInstance) {
|
||||
messageInstance.close();
|
||||
}
|
||||
messageInstance = ElMessage.error(info);
|
||||
};
|
||||
|
||||
// 创建一个状态变量来跟踪是否已经弹出了退出登录的弹窗
|
||||
const isLogoutModalShown = ref(true);
|
||||
|
||||
// 创建 axios 实例
|
||||
const index = window.location.href.lastIndexOf('?s=');
|
||||
const pro_url = window.location.href.substring(0, index);
|
||||
|
|
@ -37,23 +51,26 @@ service.interceptors.response.use(
|
|||
if (code == 0) {
|
||||
return response.data;
|
||||
} else if (code == -400) {
|
||||
ElMessageBox.alert(msg, '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
showClose: false,
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
localStorage.clear(); // @vueuse/core 自动导入
|
||||
window.location.href = data;
|
||||
});
|
||||
if (isLogoutModalShown.value) {
|
||||
isLogoutModalShown.value = false;
|
||||
ElMessageBox.alert(msg, '温馨提示', {
|
||||
confirmButtonText: '确定',
|
||||
showClose: false,
|
||||
type: 'warning',
|
||||
}).then(() => {
|
||||
localStorage.clear(); // @vueuse/core 自动导入
|
||||
window.location.href = data;
|
||||
});
|
||||
}
|
||||
} else {
|
||||
ElMessage.error(msg || message || '系统出错');
|
||||
message_error(msg || message || '系统出错');
|
||||
return Promise.reject(new Error(msg || 'Error'));
|
||||
}
|
||||
},
|
||||
(error: any) => {
|
||||
if (error.response.data) {
|
||||
const { msg, message } = error.response.data;
|
||||
ElMessage.error(msg || message || '系统出错');
|
||||
message_error(msg || message || '系统出错');
|
||||
}
|
||||
return Promise.reject(error.message);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue