From 2ca94de8ede18ac07ccfd8dec7b6f6a707adde9b Mon Sep 17 00:00:00 2001
From: 张含笑 <zhx18749296735@163.com>
Date: Mon, 01 Sep 2025 11:20:24 +0800
Subject: [PATCH] Merge branch 'refs/heads/feature/v5.0/5.0.5' into patch_management
---
src/utils/util.js | 62 +++++++++++++++++++++++++++++++
1 files changed, 62 insertions(+), 0 deletions(-)
diff --git a/src/utils/util.js b/src/utils/util.js
index 94137a6..57c3536 100644
--- a/src/utils/util.js
+++ b/src/utils/util.js
@@ -130,6 +130,16 @@
return `${url.substring(0, lastDotIndex)}_small${url.substring(lastDotIndex)}`
}
/**
+ * 获取正射路径
+ * @param url
+ * @returns {string}
+ */
+export const getzsSmallImg = url => {
+ if (!url) return ''
+ const lastDotIndex = url.lastIndexOf('.')
+ return `${url.substring(0, lastDotIndex)}_small.jpeg`
+}
+/**
* 浏览器判断是否全屏
*/
export const fullscreenEnable = () => {
@@ -438,3 +448,55 @@
// 设置默认范围 [上个月, 当前月]
return [new Date(lastMonthYear, lastMonth, 1), new Date(currentYear, currentMonth, 1)]
}
+/**
+ * 获取中等缩略图路径
+ * @param url
+ * @returns {string}
+ */
+export const getShowImg = url => {
+ if (!url) return ''
+ const lastDotIndex = url.lastIndexOf('.')
+ return `${url.substring(0, lastDotIndex)}_show${url.substring(lastDotIndex)}`
+}
+
+/**
+ * 获取正射路径
+ * @param url
+ * @returns {string}
+ */
+export const getzsShowImg = url => {
+ if (!url) return ''
+ const lastDotIndex = url.lastIndexOf('.')
+ return `${url.substring(0, lastDotIndex)}_show.jpeg`
+}
+// 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
+}
+
+// a链接直接下载
+export const aLinkDownloadUtil = (url, name) => {
+ let a = document.createElement('a')
+ a.style.display = 'none'
+ a.href = url
+ a.download = name
+ document.body.appendChild(a)
+ a.click()
+ document.body.removeChild(a)
+ a = null
+}
--
Gitblit v1.9.3