From 0082fa417fb2af9add3406bf05ab3e3e45890c34 Mon Sep 17 00:00:00 2001
From: rain <1679827795@qq.com>
Date: Thu, 12 Jun 2025 14:30:02 +0800
Subject: [PATCH] Merge branch 'master' of http://139.196.74.78:10010/r/drone/drone-web-manage
---
src/utils/util.js | 26 +++++++++++++++++++++++---
1 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/utils/util.js b/src/utils/util.js
index 94137a6..fc0bc9e 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -125,9 +125,9 @@
* @returns {string}
*/
export const getSmallImg = url => {
- if (!url) return ''
- const lastDotIndex = url.lastIndexOf('.')
- return `${url.substring(0, lastDotIndex)}_small${url.substring(lastDotIndex)}`
+ if (!url) return ''
+ const lastDotIndex = url.lastIndexOf('.')
+ return `${url.substring(0, lastDotIndex)}_small${url.substring(lastDotIndex)}`
}
/**
* 浏览器判断是否全屏
@@ -438,3 +438,23 @@
// 设置默认范围 [上个月, 当前月]
return [new Date(lastMonthYear, lastMonth, 1), new Date(currentYear, currentMonth, 1)]
}
+
+// key驼峰转换为下划线
+export function camelToSnake (obj) {
+ if (typeof obj !== 'object' || obj === null) {
+ return obj
+ }
+
+ if (Array.isArray(obj)) {
+ return obj.map(item => camelToSnake(item))
+ }
+
+ const newObj = {}
+ for (const key in obj) {
+ if (Object.prototype.hasOwnProperty.call(obj, key)) {
+ const newKey = key.replace(/([a-z])([A-Z])/g, '$1_$2').toLowerCase()
+ newObj[newKey] = camelToSnake(obj[key])
+ }
+ }
+ return newObj
+}
\ No newline at end of file
--
Gitblit v1.9.3