-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ui: Reconstructing Sidebar Routing Method
- Loading branch information
1 parent
10aa702
commit 149049f
Showing
5 changed files
with
99 additions
and
213 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { ref } from 'vue'; | ||
|
||
// Throttle | ||
export function useThrottle(fn: () => void, delay: number = 500): () => void { | ||
This comment has been minimized.
Sorry, something went wrong. |
||
const throttled = ref(false); | ||
return function throttledFn() { | ||
if (!throttled.value) { | ||
fn(); | ||
throttled.value = true; | ||
setTimeout(() => { | ||
throttled.value = false; | ||
}, delay); | ||
} | ||
}; | ||
} | ||
|
||
// Debounce | ||
export function useDebounce(fn: () => void, delay: number = 500): () => void { | ||
let timer: NodeJS.Timeout; | ||
return function debouncedFn() { | ||
clearTimeout(timer); | ||
timer = setTimeout(fn, delay); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './debounce-throttle'; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export const useThrottle =(...) => {
....
}