From ca27783bb2b809c3a0e7a8340647eab383791d40 Mon Sep 17 00:00:00 2001 From: hrx <18603305412@163.com> Date: Fri, 10 Apr 2026 17:36:17 +0800 Subject: [PATCH] =?UTF-8?q?4.10=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/video/VideoLeft.vue | 3 +++ src/utlis/debounce.ts | 42 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/utlis/debounce.ts diff --git a/src/components/video/VideoLeft.vue b/src/components/video/VideoLeft.vue index 35fb514..4b6a90c 100644 --- a/src/components/video/VideoLeft.vue +++ b/src/components/video/VideoLeft.vue @@ -217,6 +217,7 @@ onUnmounted(() => { flex: 1; min-height: 0; overflow-y: auto; + padding-bottom: 96px; } .create-button-container { z-index: 999; @@ -225,6 +226,7 @@ onUnmounted(() => { left: 0; width: 100%; padding: 16px; + pointer-events: none; // background: linear-gradient(180deg, rgba(2, 11, 19, 0) 0%, #0f0f19 100%); // position: relative; } @@ -243,6 +245,7 @@ onUnmounted(() => { font-weight: 600 !important; cursor: pointer; transition: all 0.2s; + pointer-events: auto; } .create-button .price-info { font-size: 16px; diff --git a/src/utlis/debounce.ts b/src/utlis/debounce.ts new file mode 100644 index 0000000..1d64d00 --- /dev/null +++ b/src/utlis/debounce.ts @@ -0,0 +1,42 @@ +export type DebouncedFunction any> = (( + ...args: Parameters +) => void) & { + cancel: () => void; +}; + +export const debounce = any>( + fn: T, + wait = 300, + immediate = true +): DebouncedFunction => { + let timer: ReturnType | null = null; + + const debounced = ((...args: Parameters) => { + const shouldCallNow = immediate && timer === null; + + if (timer) { + clearTimeout(timer); + } + + timer = setTimeout(() => { + timer = null; + + if (!immediate) { + void fn(...args); + } + }, wait); + + if (shouldCallNow) { + void fn(...args); + } + }) as DebouncedFunction; + + debounced.cancel = () => { + if (!timer) return; + + clearTimeout(timer); + timer = null; + }; + + return debounced; +};