From 9bec4dcae002f36aa23231da11cb03a156b40110 Mon Sep 17 00:00:00 2001
From: schangxiang@126.com <schangxiang@126.com>
Date: 周三, 30 4月 2025 16:24:16 +0800
Subject: [PATCH] 222

---
 PipeLineLems/web/src/utils/index.ts |   62 +++++++++++++++++++++++++++++++
 1 files changed, 62 insertions(+), 0 deletions(-)

diff --git a/PipeLineLems/web/src/utils/index.ts b/PipeLineLems/web/src/utils/index.ts
index 67d42e2..1d34068 100644
--- a/PipeLineLems/web/src/utils/index.ts
+++ b/PipeLineLems/web/src/utils/index.ts
@@ -1,5 +1,7 @@
 // 宸ュ叿绫诲嚱鏁�
 
+import { SpeedTime } from '@/widgets/ProductDelivery/enum'
+
 // 闅忔満id
 function createRandomId(): string {
   return (
@@ -148,6 +150,66 @@
   var uniqueValues = new Set(values)
   return values.length !== uniqueValues.size
 }
+/**
+ * 棣栧瓧姣嶅皬鍐�
+ * @param str
+ * @returns
+ */
+export function lowerCaseFirstChar(str: string) {
+  if (!str) return str // 濡傛灉瀛楃涓蹭负绌猴紝鍒欑洿鎺ヨ繑鍥�
+  return str.charAt(0).toLowerCase() + str.slice(1)
+}
+
+// export const genSetInterval = (fn: () => void, time = 33) => {
+//   let timer: any = null
+//   return {
+//     start() {
+//       timer && clearInterval(timer)
+//       timer = setInterval(() => fn(), time)
+//     },
+//     clear() {
+//       if (timer) {
+//         clearInterval(timer)
+//         timer = null
+//       }
+//     },
+//   }
+// }
+type Timer = {
+  start: () => void
+  clear: () => void
+}
+
+export const genSetInterval = (fn: () => void, time: number = 33): Timer => {
+  let timerId: number | null = null
+  let lastTime = performance.now()
+
+  const loop = (currentTime: number) => {
+    const deltaTime = currentTime - lastTime
+
+    if (deltaTime >= time) {
+      fn()
+      lastTime = currentTime - (deltaTime % time) // 淇濈暀浣欎笅鐨勬椂闂达紝鍑忓皯婕傜Щ
+    }
+
+    timerId = requestAnimationFrame(loop)
+  }
+
+  return {
+    start() {
+      if (timerId === null) {
+        lastTime = performance.now() // 閲嶇疆鍒濆鏃堕棿
+        timerId = requestAnimationFrame(loop)
+      }
+    },
+    clear() {
+      if (timerId !== null) {
+        cancelAnimationFrame(timerId)
+        timerId = null
+      }
+    },
+  }
+}
 
 export {
   hasDuplicates,

--
Gitblit v1.9.3