|
|
@ -6,6 +6,9 @@ import { createVNode } from "vue"; |
|
|
import ErrorDialog from "@/components/ErrorDialog.vue"; |
|
|
import ErrorDialog from "@/components/ErrorDialog.vue"; |
|
|
|
|
|
|
|
|
function globalConfig() { |
|
|
function globalConfig() { |
|
|
|
|
|
window.globalConfig.axiosRequestDef = () => ({ |
|
|
|
|
|
timeout: 1000 * 60 * 10, |
|
|
|
|
|
}) |
|
|
window.globalConfig.customAxios = axiosInstance => { |
|
|
window.globalConfig.customAxios = axiosInstance => { |
|
|
// 全局请求拦截
|
|
|
// 全局请求拦截
|
|
|
axiosInstance.interceptors.request.clear(); |
|
|
axiosInstance.interceptors.request.clear(); |
|
|
@ -25,18 +28,18 @@ function globalConfig() { |
|
|
axiosInstance.interceptors.response.clear(); |
|
|
axiosInstance.interceptors.response.clear(); |
|
|
axiosInstance.interceptors.response.use( |
|
|
axiosInstance.interceptors.response.use( |
|
|
(response) => { |
|
|
(response) => { |
|
|
const data = response.data; |
|
|
const data = response.data; |
|
|
|
|
|
|
|
|
if (data && data.success === false) { |
|
|
if (data && data.success === false) { |
|
|
// 显示错误对话框
|
|
|
// 显示错误对话框
|
|
|
system.showErrorDialog(data.failMessage || '系统异常'); |
|
|
system.showErrorDialog(data.failMessage || '系统异常'); |
|
|
|
|
|
|
|
|
// 返回一个被拒绝的 Promise,这样后续 .then() 不会执行,进入 .catch()
|
|
|
// 返回一个被拒绝的 Promise,这样后续 .then() 不会执行,进入 .catch()
|
|
|
return Promise.reject(response); |
|
|
return Promise.reject(response); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 正常情况,继续传递数据
|
|
|
// 正常情况,继续传递数据
|
|
|
return response; |
|
|
return response; |
|
|
}, |
|
|
}, |
|
|
(error: any) => { |
|
|
(error: any) => { |
|
|
const { response } = error; |
|
|
const { response } = error; |
|
|
|