refactor: refactor hooks

This commit is contained in:
Vben
2021-04-10 20:32:44 +08:00
parent 215d8bab38
commit 2037293aa3
23 changed files with 52 additions and 394 deletions

View File

@@ -1,5 +1,5 @@
import { tryOnMounted, tryOnUnmounted } from '@vueuse/core';
import { useDebounce } from '/@/hooks/core/useDebounce';
import { useDebounceFn } from '@vueuse/core';
interface WindowSizeOptions {
once?: boolean;
@@ -11,7 +11,7 @@ export function useWindowSizeFn<T>(fn: Fn<T>, wait = 150, options?: WindowSizeOp
let handler = () => {
fn();
};
const [handleSize, cancel] = useDebounce(handler, wait, options);
const handleSize = useDebounceFn(handler, wait);
handler = handleSize;
const start = () => {
@@ -23,7 +23,6 @@ export function useWindowSizeFn<T>(fn: Fn<T>, wait = 150, options?: WindowSizeOp
const stop = () => {
window.removeEventListener('resize', handler);
cancel();
};
tryOnMounted(() => {