diff --git a/src/hooks/event/useWindowSizeFn.ts b/src/hooks/event/useWindowSizeFn.ts new file mode 100644 index 0000000..8bee3fb --- /dev/null +++ b/src/hooks/event/useWindowSizeFn.ts @@ -0,0 +1,34 @@ +import debounce from 'lodash/debounce'; +import { onUnmounted, onMounted } from 'vue'; + +interface WindowSizeOptions { + immediate?: boolean; +} + +interface Fn { + (...arg: T[]): R; +} + +export function useWindowSizeFn(fn: Fn, options?: WindowSizeOptions, wait = 150) { + const handleSize: () => void = debounce(fn, wait); + + const start = () => { + if (options && options.immediate) { + fn(); + } + window.addEventListener('resize', handleSize); + }; + + const stop = () => { + window.removeEventListener('resize', handleSize); + }; + + onMounted(() => { + start(); + }); + + onUnmounted(() => { + stop(); + }); + return [start, stop]; +} diff --git a/src/layouts/components/Content.vue b/src/layouts/components/Content.vue index 069ad1e..e4a11cd 100644 --- a/src/layouts/components/Content.vue +++ b/src/layouts/components/Content.vue @@ -6,12 +6,14 @@ + diff --git a/src/layouts/components/FrameContent.vue b/src/layouts/components/FrameContent.vue new file mode 100644 index 0000000..2b8e362 --- /dev/null +++ b/src/layouts/components/FrameContent.vue @@ -0,0 +1,99 @@ + + + diff --git a/src/layouts/components/MenuContent.vue b/src/layouts/components/MenuContent.vue index 7f77765..f15cf99 100644 --- a/src/layouts/components/MenuContent.vue +++ b/src/layouts/components/MenuContent.vue @@ -2,7 +2,7 @@