From 309cc3fe6303d8464951063e89fc9d623915501e Mon Sep 17 00:00:00 2001 From: zhangwei <1504152376@qq.com> Date: 星期一, 10 三月 2025 16:23:35 +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