fix(菜单): 防重点击

This commit is contained in:
baiqi 2024-11-04 15:59:42 +08:00 committed by Craftsman
parent 935c1d652e
commit 7c495db38a
1 changed files with 5 additions and 7 deletions

View File

@ -6,7 +6,7 @@
mode="horizontal" mode="horizontal"
@menu-item-click="menuClickHandler" @menu-item-click="menuClickHandler"
> >
<a-menu-item v-for="menu of appStore.getTopMenus" :key="(menu.name as string)" @click="jumpPath(menu.name)"> <a-menu-item v-for="menu of appStore.getTopMenus" :key="(menu.name as string)">
{{ t(menu.meta?.locale || '') }} {{ t(menu.meta?.locale || '') }}
</a-menu-item> </a-menu-item>
</a-menu> </a-menu>
@ -15,7 +15,7 @@
<script setup lang="ts"> <script setup lang="ts">
import { Ref, ref, watch } from 'vue'; import { Ref, ref, watch } from 'vue';
import { RouteRecordName, RouteRecordRaw, useRouter } from 'vue-router'; import { RouteRecordName, RouteRecordRaw, useRouter } from 'vue-router';
import { cloneDeep } from 'lodash-es'; import { cloneDeep, debounce } from 'lodash-es';
import { useI18n } from '@/hooks/useI18n'; import { useI18n } from '@/hooks/useI18n';
import usePermission from '@/hooks/usePermission'; import usePermission from '@/hooks/usePermission';
@ -108,12 +108,10 @@
setCurrentTopMenu(''); setCurrentTopMenu('');
}, true); }, true);
function jumpPath(route: RouteRecordName | undefined) { const menuClickHandler = debounce((route: RouteRecordName | undefined) => {
router.push({ name: route });
}
function menuClickHandler() {
activeMenus.value = [appStore.getCurrentTopMenu?.name || '']; activeMenus.value = [appStore.getCurrentTopMenu?.name || ''];
} router.push({ name: route });
}, 150);
watch( watch(
() => appStore.currentOrgId, () => appStore.currentOrgId,