Commit 9f8e01053411cb469e00db5059edb2813d7cf5b3

Authored by vben
1 parent 14ba72dd

feat: 重构 useRefs

packages/hooks/src/index.ts
1 1 export * from './onMountedOrActivated';
2 2 export * from './useAttrs';
  3 +export * from './useRefs';
... ...
src/hooks/core/useRefs.ts renamed to packages/hooks/src/useRefs.ts
src/components/Application/src/search/AppSearchModal.vue
... ... @@ -64,7 +64,7 @@
64 64 import { Icon } from '/@/components/Icon';
65 65 import vClickOutside from '/@/directives/clickOutside';
66 66 import { useDesign } from '/@/hooks/web/useDesign';
67   - import { useRefs } from '/@/hooks/core/useRefs';
  67 + import { useRefs } from '@vben/hooks';
68 68 import { useMenuSearch } from './useMenuSearch';
69 69 import { useI18n } from '/@/hooks/web/useI18n';
70 70 import { useAppInject } from '/@/hooks/web/useAppInject';
... ...
src/components/Application/src/search/useMenuSearch.ts
1   -import type { Menu } from '/@/router/types';
  1 +import { type Menu } from '/@/router/types';
  2 +import { type AnyFunction } from '@vben/types';
2 3 import { ref, onBeforeMount, unref, Ref, nextTick } from 'vue';
3 4 import { getMenus } from '/@/router/menus';
4 5 import { cloneDeep } from 'lodash-es';
... ... @@ -26,7 +27,7 @@ function createSearchReg(key: string) {
26 27 return new RegExp(str);
27 28 }
28 29  
29   -export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>, emit: EmitType) {
  30 +export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref, emit: AnyFunction) {
30 31 const searchResult = ref<SearchResult[]>([]);
31 32 const keyword = ref('');
32 33 const activeIndex = ref(-1);
... ...