From b9f44598fe95b9c1f8a053b8a04706a137f630e6 Mon Sep 17 00:00:00 2001
From: wupengfei <834520024@qq.com>
Date: 星期五, 17 十月 2025 14:35:25 +0800
Subject: [PATCH] feat: 1.2.0.1
---
src/utils/request/index.ts | 32 ++++++++++++++++++++++++++++++++
1 files changed, 32 insertions(+), 0 deletions(-)
diff --git a/src/utils/request/index.ts b/src/utils/request/index.ts
index e11bb12..d5c39ef 100644
--- a/src/utils/request/index.ts
+++ b/src/utils/request/index.ts
@@ -7,6 +7,7 @@
import { ElLoading as Loading, ElNotification } from 'element-plus';
import { router } from '@/router';
import { Message, tokenIsExpired } from '@/utils';
+import { httpLoggerRecord } from '../LoggerRecord';
// 鍔犺浇鐜鍙橀噺 VITE_PROXY_DOMAIN锛堝紑鍙戠幆澧冿級 VITE_PROXY_DOMAIN_REAL锛堟墦鍖呭悗鐨勭嚎涓婄幆澧冿級
const { VITE_PROXY_DOMAIN, VITE_PROXY_DOMAIN_REAL, DEV } = loadEnv();
@@ -67,6 +68,7 @@
*/
msg?: string;
showType?: ErrorShowType;
+ traceId?: string;
}
interface ErrorResponse {
@@ -107,6 +109,19 @@
// 閿欒鎺ユ敹鍙婂鐞�
errorHandler: (error, opts) => {
console.log('error: ', error);
+
+ const url = opts.url ?? '';
+ httpLoggerRecord.error({
+ message: `[${url}] 璇锋眰閿欒`,
+ httpParams: {
+ url: url,
+ //@ts-ignore
+ traceId: error?.info?.traceId,
+ stackTrace: error.stack,
+ },
+ args: [{ data: opts.data, params: opts.params, headers: opts.headers }],
+ });
+
if (opts?.skipErrorHandler) throw error;
if (opts?.customErrorHandler) {
@@ -182,6 +197,14 @@
NProgress.start();
}
+ httpLoggerRecord.info({
+ message: `[${$config.url}] 璇锋眰寮�濮媊,
+ httpParams: {
+ url: $config.url,
+ },
+ args: [{ data: $config.data, params: $config.params, headers: $config.headers }],
+ });
+
const userStore = useUserStoreHook();
const userInfo = userStore.userInfo;
@@ -224,6 +247,15 @@
(response) => {
const $config = response.config as IRequestOptions;
+ httpLoggerRecord.info({
+ message: `[${$config.url}] 璇锋眰缁撴潫`,
+ httpParams: {
+ url: $config.url,
+ traceId: response.data?.traceId,
+ },
+ args: [{ data: $config.data, params: $config.params, headers: $config.headers }],
+ });
+
const { needNProcess, getResponse = false } = $config;
// 鍏抽棴杩涘害鏉″姩鐢�
--
Gitblit v1.9.1