From dae8d5ad8df88593261f6df3697fbfe2cab3047b Mon Sep 17 00:00:00 2001
From: shuishen <1109946754@qq.com>
Date: Wed, 11 Jun 2025 17:13:00 +0800
Subject: [PATCH] feat:后台管理通用航线加载相关方法、hook、航线材质等处理
---
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