From 97a154b83ff9ec6b375b035066cb7e5e2881e1b4 Mon Sep 17 00:00:00 2001 From: zhengyiming <540361168@qq.com> Date: 星期三, 11 六月 2025 16:53:06 +0800 Subject: [PATCH] Merge branch 'dev-ui' of http://120.26.58.240:8888/r/LifePaymentFront into dev-ui --- 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