From 46aae38e660fe104e8ae62ae30f4e1aeca4bf6cb Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期日, 19 十月 2025 20:36:58 +0800
Subject: [PATCH] release: v1.2.0
---
src/utils/common/common.ts | 31 +++++++++++++++++++++++++++++++
1 files changed, 31 insertions(+), 0 deletions(-)
diff --git a/src/utils/common/common.ts b/src/utils/common/common.ts
index 374c3a8..2a52bc0 100644
--- a/src/utils/common/common.ts
+++ b/src/utils/common/common.ts
@@ -115,3 +115,34 @@
}
return roleName;
}
+
+/**
+ * 鍓旈櫎瀵硅薄涓�间负 ''銆乽ndefined銆乶ull 鐨勯敭锛屾敮鎸佸祵濂楀璞�
+ * @param {Object} obj - 闇�瑕佸鐞嗙殑瀵硅薄
+ * @returns {Object} 澶勭悊鍚庣殑鏂板璞�
+ */
+export function removeEmptyKeys<T extends object>(obj: T) {
+ // 濡傛灉涓嶆槸瀵硅薄鎴栦负null锛岀洿鎺ヨ繑鍥炲師鍊�
+ if (obj === null || typeof obj !== 'object') {
+ return obj;
+ }
+
+ // 澶勭悊鏁扮粍锛堥�掑綊澶勭悊姣忎釜鍏冪礌锛�
+ if (Array.isArray(obj)) {
+ return obj.map((item) => removeEmptyKeys(item));
+ }
+
+ // 澶勭悊瀵硅薄
+ const result = {} as T;
+ for (const key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ //@ts-ignore
+ const value = removeEmptyKeys(obj[key]); // 閫掑綊澶勭悊宓屽瀵硅薄
+ // 鍙繚鐣欓潪绌哄�硷紙鎺掗櫎''銆乽ndefined銆乶ull锛�
+ if (value !== '' && value !== undefined && value !== null) {
+ result[key] = value;
+ }
+ }
+ }
+ return result;
+}
--
Gitblit v1.9.1