From 84e27a26dcbee4d0706dfad6059454ea85fadacc Mon Sep 17 00:00:00 2001
From: zhengyiming <540361168@qq.com>
Date: 星期五, 15 八月 2025 14:20:54 +0800
Subject: [PATCH] fix: 修改角色授权代码

---
 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