From 21fb7eb6f99ed52a48b4655ea2ea9ec97fa76189 Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Sat, 14 Jun 2025 14:51:16 +0800
Subject: [PATCH] feat:航线加载
---
src/utils/util.js | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/src/utils/util.js b/src/utils/util.js
index 8fe922e..acf5472 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -447,4 +447,24 @@
if (!url) return ''
const lastDotIndex = url.lastIndexOf('.')
return `${url.substring(0, lastDotIndex)}_show${url.substring(lastDotIndex)}`
+}
+
+// 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