From 85d5bb7226f25b7af51c3fb1d617f9d43b2fe5be Mon Sep 17 00:00:00 2001 From: lizw-2015 <1183409807@qq.com> Date: Wed, 9 Jul 2025 10:13:31 +0800 Subject: [PATCH] =?UTF-8?q?feat(config):=20=E6=B7=BB=E5=8A=A0=E5=85=A8?= =?UTF-8?q?=E5=B1=80=E8=AF=B7=E6=B1=82=E8=B6=85=E6=97=B6=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E5=B9=B6=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在 globalConfig 中添加 axiosRequestDef函数,设置请求超时时间为10 分钟 - 优化代码格式,调整缩进和空格 --- src/config.ts | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/config.ts b/src/config.ts index 1a74ce1..97d2207 100644 --- a/src/config.ts +++ b/src/config.ts @@ -6,6 +6,9 @@ import { createVNode } from "vue"; import ErrorDialog from "@/components/ErrorDialog.vue"; function globalConfig() { + window.globalConfig.axiosRequestDef = () => ({ + timeout: 1000 * 60 * 10, + }) window.globalConfig.customAxios = axiosInstance => { // 全局请求拦截 axiosInstance.interceptors.request.clear(); @@ -25,18 +28,18 @@ function globalConfig() { axiosInstance.interceptors.response.clear(); axiosInstance.interceptors.response.use( (response) => { - const data = response.data; + const data = response.data; - if (data && data.success === false) { - // 显示错误对话框 - system.showErrorDialog(data.failMessage || '系统异常'); + if (data && data.success === false) { + // 显示错误对话框 + system.showErrorDialog(data.failMessage || '系统异常'); - // 返回一个被拒绝的 Promise,这样后续 .then() 不会执行,进入 .catch() - return Promise.reject(response); - } + // 返回一个被拒绝的 Promise,这样后续 .then() 不会执行,进入 .catch() + return Promise.reject(response); + } - // 正常情况,继续传递数据 - return response; + // 正常情况,继续传递数据 + return response; }, (error: any) => { const { response } = error;