From 3fbb7294fbccd4a88e004b80306be3dadcb9c31f Mon Sep 17 00:00:00 2001 From: yuantao Date: Mon, 1 Dec 2025 16:10:42 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20API=E8=AF=B7=E6=B1=82?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E8=87=AA=E5=8A=A8=E4=B8=8A=E6=8A=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/request.js | 4 ++++ common/utils/tool.js | 7 +++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/api/request.js b/api/request.js index 3174fdc..2207b10 100644 --- a/api/request.js +++ b/api/request.js @@ -31,6 +31,10 @@ http.interceptors.response.use(response => { if (response.statusCode == 401 || response.data.code == 401) { } + if (response.data.code !== 1 || response.data.code !== 200) { + tool.reportError('network', response.data) + } + if (response.statusCode == 200) { return Promise.resolve(response) } else { diff --git a/common/utils/tool.js b/common/utils/tool.js index 75206a2..07ffa27 100644 --- a/common/utils/tool.js +++ b/common/utils/tool.js @@ -551,9 +551,9 @@ class Tool { * @param {Object} [context] 错误上下文信息 * @param {boolean} [forceSend=false] 强制发送(忽略环境检查) */ - reportError(error, context = {}, forceSend = false) { + reportError(type = 'manual', error, context = {}, forceSend = false) { const errorInfo = { - type: 'manual', + type, error: error instanceof Error ? error.message : error, stack: error instanceof Error ? error.stack : null, context, @@ -562,6 +562,9 @@ class Tool { userAgent: this._getUserAgent(), page: getCurrentPageName(), } + this.errorStats.total++ + this.errorStats.miniProgram++ + this.errorStats.lastErrorTime = errorInfo.timestamp if (forceSend) { // 强制发送