From 2d43a1df3f5ba42710e6d21c27d1e13bdb8dfd56 Mon Sep 17 00:00:00 2001
From: zhangwei <1504152376@qq.com>
Date: 星期一, 24 三月 2025 09:23:08 +0800
Subject: [PATCH] -
---
src/common/utils/util.js | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
diff --git a/src/common/utils/util.js b/src/common/utils/util.js
index da3cfb9..bd7bb9c 100644
--- a/src/common/utils/util.js
+++ b/src/common/utils/util.js
@@ -894,5 +894,31 @@
getFileExtensionWithDotRegex(filename) {
const match = filename.match(/\.[^.]+$/);
return match ? match[0] : '';
+ },
+ isEmpty(value) {
+ return (
+ value === null ||
+ value === undefined ||
+ value === '' ||
+ (Array.isArray(value) && value.length === 0) ||
+ (typeof value === 'object' &&!Array.isArray(value) && Object.keys(value).length === 0)
+ );
+ },
+
+ removeEmptyValuesRecursive(obj) {
+ const newObj = {};
+ for (const key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ const value = obj[key];
+ if (!this.isEmpty(value)) {
+ if (typeof value === 'object' &&!Array.isArray(value)) {
+ newObj[key] = removeEmptyValuesRecursive(value);
+ } else {
+ newObj[key] = value;
+ }
+ }
+ }
+ }
+ return newObj;
}
}
\ No newline at end of file
--
Gitblit v1.9.1