Skip to content

Commit 3859828

Browse files
committed
chore: use vueuse hooks
1 parent a694e36 commit 3859828

File tree

4 files changed

+27
-64
lines changed

4 files changed

+27
-64
lines changed

build/plugins/unplugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export default [
1111
imports: ['vue', 'vue-router', '@vueuse/core', 'pinia'],
1212
dts: 'types/auto-imports.d.ts',
1313
vueTemplate: true,
14-
dirs: ['src/store/modules', 'src/composables'],
14+
dirs: ['src/store/modules', 'src/composables', 'src/hooks'],
1515
}),
1616
Icons({
1717
customCollections: {

src/hooks/useBreakpoint.ts

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { screenEnum, screenMap, sizeEnum } from '@/enums/breakpointEnum'
2-
import { useEventListener } from './useEventListener'
32
import type { ComputedRef } from 'vue'
43

54
let globalScreenRef: ComputedRef<sizeEnum | undefined>
@@ -57,16 +56,14 @@ export function createBreakpointListen(fn?: (opt: CreateCallbackParams) => void)
5756
realWidthRef.value = width
5857
}
5958

60-
useEventListener({
61-
el: window,
62-
name: 'resize',
63-
64-
listener: () => {
59+
useEventListener(
60+
window,
61+
'resize',
62+
() => {
6563
getWindowWidth()
6664
resizeFn()
6765
},
68-
// wait: 100,
69-
})
66+
)
7067

7168
getWindowWidth()
7269
globalScreenRef = computed(() => unref(screenRef))

src/hooks/useEventListener.ts

Lines changed: 0 additions & 55 deletions
This file was deleted.

types/auto-imports.d.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ declare global {
1717
const controlledComputed: typeof import('@vueuse/core')['controlledComputed']
1818
const controlledRef: typeof import('@vueuse/core')['controlledRef']
1919
const createApp: typeof import('vue')['createApp']
20+
const createBreakpointListen: typeof import('../src/hooks/useBreakpoint')['createBreakpointListen']
21+
const createContext: typeof import('../src/hooks/useContext')['createContext']
2022
const createEventHook: typeof import('@vueuse/core')['createEventHook']
2123
const createGlobalState: typeof import('@vueuse/core')['createGlobalState']
2224
const createInjectionState: typeof import('@vueuse/core')['createInjectionState']
@@ -118,6 +120,7 @@ declare global {
118120
const until: typeof import('@vueuse/core')['until']
119121
const useActiveElement: typeof import('@vueuse/core')['useActiveElement']
120122
const useAnimate: typeof import('@vueuse/core')['useAnimate']
123+
const useAppInject: typeof import('../src/hooks/useAppInject')['useAppInject']
121124
const useArrayDifference: typeof import('@vueuse/core')['useArrayDifference']
122125
const useArrayEvery: typeof import('@vueuse/core')['useArrayEvery']
123126
const useArrayFilter: typeof import('@vueuse/core')['useArrayFilter']
@@ -136,6 +139,7 @@ declare global {
136139
const useBase64: typeof import('@vueuse/core')['useBase64']
137140
const useBattery: typeof import('@vueuse/core')['useBattery']
138141
const useBluetooth: typeof import('@vueuse/core')['useBluetooth']
142+
const useBreakpoint: typeof import('../src/hooks/useBreakpoint')['useBreakpoint']
139143
const useBreakpoints: typeof import('@vueuse/core')['useBreakpoints']
140144
const useBroadcastChannel: typeof import('@vueuse/core')['useBroadcastChannel']
141145
const useBrowserLocation: typeof import('@vueuse/core')['useBrowserLocation']
@@ -144,6 +148,7 @@ declare global {
144148
const useCloned: typeof import('@vueuse/core')['useCloned']
145149
const useColorMode: typeof import('@vueuse/core')['useColorMode']
146150
const useConfirmDialog: typeof import('@vueuse/core')['useConfirmDialog']
151+
const useContext: typeof import('../src/hooks/useContext')['useContext']
147152
const useCounter: typeof import('@vueuse/core')['useCounter']
148153
const useCssModule: typeof import('vue')['useCssModule']
149154
const useCssVar: typeof import('@vueuse/core')['useCssVar']
@@ -182,6 +187,8 @@ declare global {
182187
const useFullscreen: typeof import('@vueuse/core')['useFullscreen']
183188
const useGamepad: typeof import('@vueuse/core')['useGamepad']
184189
const useGeolocation: typeof import('@vueuse/core')['useGeolocation']
190+
const useGlobSetting: typeof import('../src/hooks/useGlobSetting')['useGlobSetting']
191+
const useGo: typeof import('../src/hooks/usePage')['useGo']
185192
const useIdle: typeof import('@vueuse/core')['useIdle']
186193
const useImage: typeof import('@vueuse/core')['useImage']
187194
const useInfiniteScroll: typeof import('@vueuse/core')['useInfiniteScroll']
@@ -316,6 +323,8 @@ declare module 'vue' {
316323
readonly controlledComputed: UnwrapRef<typeof import('@vueuse/core')['controlledComputed']>
317324
readonly controlledRef: UnwrapRef<typeof import('@vueuse/core')['controlledRef']>
318325
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
326+
readonly createBreakpointListen: UnwrapRef<typeof import('../src/hooks/useBreakpoint')['createBreakpointListen']>
327+
readonly createContext: UnwrapRef<typeof import('../src/hooks/useContext')['createContext']>
319328
readonly createEventHook: UnwrapRef<typeof import('@vueuse/core')['createEventHook']>
320329
readonly createGlobalState: UnwrapRef<typeof import('@vueuse/core')['createGlobalState']>
321330
readonly createInjectionState: UnwrapRef<typeof import('@vueuse/core')['createInjectionState']>
@@ -417,6 +426,7 @@ declare module 'vue' {
417426
readonly until: UnwrapRef<typeof import('@vueuse/core')['until']>
418427
readonly useActiveElement: UnwrapRef<typeof import('@vueuse/core')['useActiveElement']>
419428
readonly useAnimate: UnwrapRef<typeof import('@vueuse/core')['useAnimate']>
429+
readonly useAppInject: UnwrapRef<typeof import('../src/hooks/useAppInject')['useAppInject']>
420430
readonly useArrayDifference: UnwrapRef<typeof import('@vueuse/core')['useArrayDifference']>
421431
readonly useArrayEvery: UnwrapRef<typeof import('@vueuse/core')['useArrayEvery']>
422432
readonly useArrayFilter: UnwrapRef<typeof import('@vueuse/core')['useArrayFilter']>
@@ -435,6 +445,7 @@ declare module 'vue' {
435445
readonly useBase64: UnwrapRef<typeof import('@vueuse/core')['useBase64']>
436446
readonly useBattery: UnwrapRef<typeof import('@vueuse/core')['useBattery']>
437447
readonly useBluetooth: UnwrapRef<typeof import('@vueuse/core')['useBluetooth']>
448+
readonly useBreakpoint: UnwrapRef<typeof import('../src/hooks/useBreakpoint')['useBreakpoint']>
438449
readonly useBreakpoints: UnwrapRef<typeof import('@vueuse/core')['useBreakpoints']>
439450
readonly useBroadcastChannel: UnwrapRef<typeof import('@vueuse/core')['useBroadcastChannel']>
440451
readonly useBrowserLocation: UnwrapRef<typeof import('@vueuse/core')['useBrowserLocation']>
@@ -443,6 +454,7 @@ declare module 'vue' {
443454
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
444455
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
445456
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
457+
readonly useContext: UnwrapRef<typeof import('../src/hooks/useContext')['useContext']>
446458
readonly useCounter: UnwrapRef<typeof import('@vueuse/core')['useCounter']>
447459
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
448460
readonly useCssVar: UnwrapRef<typeof import('@vueuse/core')['useCssVar']>
@@ -481,6 +493,8 @@ declare module 'vue' {
481493
readonly useFullscreen: UnwrapRef<typeof import('@vueuse/core')['useFullscreen']>
482494
readonly useGamepad: UnwrapRef<typeof import('@vueuse/core')['useGamepad']>
483495
readonly useGeolocation: UnwrapRef<typeof import('@vueuse/core')['useGeolocation']>
496+
readonly useGlobSetting: UnwrapRef<typeof import('../src/hooks/useGlobSetting')['useGlobSetting']>
497+
readonly useGo: UnwrapRef<typeof import('../src/hooks/usePage')['useGo']>
484498
readonly useIdle: UnwrapRef<typeof import('@vueuse/core')['useIdle']>
485499
readonly useImage: UnwrapRef<typeof import('@vueuse/core')['useImage']>
486500
readonly useInfiniteScroll: UnwrapRef<typeof import('@vueuse/core')['useInfiniteScroll']>
@@ -609,6 +623,8 @@ declare module '@vue/runtime-core' {
609623
readonly controlledComputed: UnwrapRef<typeof import('@vueuse/core')['controlledComputed']>
610624
readonly controlledRef: UnwrapRef<typeof import('@vueuse/core')['controlledRef']>
611625
readonly createApp: UnwrapRef<typeof import('vue')['createApp']>
626+
readonly createBreakpointListen: UnwrapRef<typeof import('../src/hooks/useBreakpoint')['createBreakpointListen']>
627+
readonly createContext: UnwrapRef<typeof import('../src/hooks/useContext')['createContext']>
612628
readonly createEventHook: UnwrapRef<typeof import('@vueuse/core')['createEventHook']>
613629
readonly createGlobalState: UnwrapRef<typeof import('@vueuse/core')['createGlobalState']>
614630
readonly createInjectionState: UnwrapRef<typeof import('@vueuse/core')['createInjectionState']>
@@ -710,6 +726,7 @@ declare module '@vue/runtime-core' {
710726
readonly until: UnwrapRef<typeof import('@vueuse/core')['until']>
711727
readonly useActiveElement: UnwrapRef<typeof import('@vueuse/core')['useActiveElement']>
712728
readonly useAnimate: UnwrapRef<typeof import('@vueuse/core')['useAnimate']>
729+
readonly useAppInject: UnwrapRef<typeof import('../src/hooks/useAppInject')['useAppInject']>
713730
readonly useArrayDifference: UnwrapRef<typeof import('@vueuse/core')['useArrayDifference']>
714731
readonly useArrayEvery: UnwrapRef<typeof import('@vueuse/core')['useArrayEvery']>
715732
readonly useArrayFilter: UnwrapRef<typeof import('@vueuse/core')['useArrayFilter']>
@@ -728,6 +745,7 @@ declare module '@vue/runtime-core' {
728745
readonly useBase64: UnwrapRef<typeof import('@vueuse/core')['useBase64']>
729746
readonly useBattery: UnwrapRef<typeof import('@vueuse/core')['useBattery']>
730747
readonly useBluetooth: UnwrapRef<typeof import('@vueuse/core')['useBluetooth']>
748+
readonly useBreakpoint: UnwrapRef<typeof import('../src/hooks/useBreakpoint')['useBreakpoint']>
731749
readonly useBreakpoints: UnwrapRef<typeof import('@vueuse/core')['useBreakpoints']>
732750
readonly useBroadcastChannel: UnwrapRef<typeof import('@vueuse/core')['useBroadcastChannel']>
733751
readonly useBrowserLocation: UnwrapRef<typeof import('@vueuse/core')['useBrowserLocation']>
@@ -736,6 +754,7 @@ declare module '@vue/runtime-core' {
736754
readonly useCloned: UnwrapRef<typeof import('@vueuse/core')['useCloned']>
737755
readonly useColorMode: UnwrapRef<typeof import('@vueuse/core')['useColorMode']>
738756
readonly useConfirmDialog: UnwrapRef<typeof import('@vueuse/core')['useConfirmDialog']>
757+
readonly useContext: UnwrapRef<typeof import('../src/hooks/useContext')['useContext']>
739758
readonly useCounter: UnwrapRef<typeof import('@vueuse/core')['useCounter']>
740759
readonly useCssModule: UnwrapRef<typeof import('vue')['useCssModule']>
741760
readonly useCssVar: UnwrapRef<typeof import('@vueuse/core')['useCssVar']>
@@ -774,6 +793,8 @@ declare module '@vue/runtime-core' {
774793
readonly useFullscreen: UnwrapRef<typeof import('@vueuse/core')['useFullscreen']>
775794
readonly useGamepad: UnwrapRef<typeof import('@vueuse/core')['useGamepad']>
776795
readonly useGeolocation: UnwrapRef<typeof import('@vueuse/core')['useGeolocation']>
796+
readonly useGlobSetting: UnwrapRef<typeof import('../src/hooks/useGlobSetting')['useGlobSetting']>
797+
readonly useGo: UnwrapRef<typeof import('../src/hooks/usePage')['useGo']>
777798
readonly useIdle: UnwrapRef<typeof import('@vueuse/core')['useIdle']>
778799
readonly useImage: UnwrapRef<typeof import('@vueuse/core')['useImage']>
779800
readonly useInfiniteScroll: UnwrapRef<typeof import('@vueuse/core')['useInfiniteScroll']>

0 commit comments

Comments
 (0)