From 91f00f1df35a964d69f48b9f71b484e2d4ef357e Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 11 六月 2025 16:52:57 +0800 Subject: [PATCH] fix: v1.4 --- apps/taro/src/utils/request/index.ts | 21 ++++++++++++++++++++- 1 files changed, 20 insertions(+), 1 deletions(-) diff --git a/apps/taro/src/utils/request/index.ts b/apps/taro/src/utils/request/index.ts index c2ff674..cae3512 100644 --- a/apps/taro/src/utils/request/index.ts +++ b/apps/taro/src/utils/request/index.ts @@ -1,5 +1,5 @@ import { type IRequestOptions, Request, type RequestConfig } from 'senior-request'; -import { type AxiosRequestConfig, type AxiosError } from 'axios'; +import axios, { type AxiosRequestConfig, type AxiosError } from 'axios'; import qs from 'qs'; import Taro from '@tarojs/taro'; import { getToken, Message } from '@/utils'; @@ -101,6 +101,13 @@ // 閿欒鎺ユ敹鍙婂鐞� errorHandler: (error, opts) => { console.log('error: ', error); + const userStore = useUserStoreWithOut(); + logFront({ + url: opts.url, + message: JSON.stringify(error), + requestTime: new Date().toLocaleString(), + userId: userStore.virtualUserId, + }); if (opts?.skipErrorHandler) throw error; if (opts?.customErrorHandler) { @@ -289,3 +296,15 @@ } export const request = Request.create(config); + +function logFront(body: API.LogFrontInput) { + return axios.request({ + baseURL: AxiosOptions.baseURL, + url: '/api/Log/LogFront', + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + data: body, + }); +} -- Gitblit v1.9.1