feat: 重构 useRefs

This commit is contained in:
vben 2023-04-06 22:17:18 +08:00
parent 14ba72dd1c
commit 9f8e010534
4 changed files with 5 additions and 3 deletions

View File

@ -1,2 +1,3 @@
export * from './onMountedOrActivated'; export * from './onMountedOrActivated';
export * from './useAttrs'; export * from './useAttrs';
export * from './useRefs';

View File

@ -64,7 +64,7 @@
import { Icon } from '/@/components/Icon'; import { Icon } from '/@/components/Icon';
import vClickOutside from '/@/directives/clickOutside'; import vClickOutside from '/@/directives/clickOutside';
import { useDesign } from '/@/hooks/web/useDesign'; import { useDesign } from '/@/hooks/web/useDesign';
import { useRefs } from '/@/hooks/core/useRefs'; import { useRefs } from '@vben/hooks';
import { useMenuSearch } from './useMenuSearch'; import { useMenuSearch } from './useMenuSearch';
import { useI18n } from '/@/hooks/web/useI18n'; import { useI18n } from '/@/hooks/web/useI18n';
import { useAppInject } from '/@/hooks/web/useAppInject'; import { useAppInject } from '/@/hooks/web/useAppInject';

View File

@ -1,4 +1,5 @@
import type { Menu } from '/@/router/types'; import { type Menu } from '/@/router/types';
import { type AnyFunction } from '@vben/types';
import { ref, onBeforeMount, unref, Ref, nextTick } from 'vue'; import { ref, onBeforeMount, unref, Ref, nextTick } from 'vue';
import { getMenus } from '/@/router/menus'; import { getMenus } from '/@/router/menus';
import { cloneDeep } from 'lodash-es'; import { cloneDeep } from 'lodash-es';
@ -26,7 +27,7 @@ function createSearchReg(key: string) {
return new RegExp(str); return new RegExp(str);
} }
export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref<ElRef>, emit: EmitType) { export function useMenuSearch(refs: Ref<HTMLElement[]>, scrollWrap: Ref, emit: AnyFunction) {
const searchResult = ref<SearchResult[]>([]); const searchResult = ref<SearchResult[]>([]);
const keyword = ref(''); const keyword = ref('');
const activeIndex = ref(-1); const activeIndex = ref(-1);