From a502a022c84eb4fe27ba537f2aee679fda7f645d Mon Sep 17 00:00:00 2001 From: ws Date: Wed, 22 Apr 2026 19:49:55 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20=E6=9B=B4=E6=96=B0=E9=85=8D=E7=BD=AE?= =?UTF-8?q?=E7=8E=AF=E5=A2=83=E6=89=93=E5=8C=85=E6=B5=8B=E8=AF=95=E4=B8=8A?= =?UTF-8?q?=E4=BD=93=E9=AA=8C=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- utils/api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/utils/api.js b/utils/api.js index 72abaa9..53b5663 100644 --- a/utils/api.js +++ b/utils/api.js @@ -9,6 +9,7 @@ const { BASE_URL, API } = require('./config') function request(options) { return new Promise((resolve, reject) => { wx.request({ + timeout: 30000, ...options, success: (res) => { const result = res.data @@ -20,7 +21,11 @@ function request(options) { }, fail: (err) => { console.error('请求失败', options.url, err) - reject(err) + if (err.errMsg && err.errMsg.indexOf('timeout') !== -1) { + reject(new Error('网络请求超时,请检查网络后重试')) + } else { + reject(new Error('网络异常,请检查网络连接')) + } } }) })