fix(菜单): 防重点击

This commit is contained in:
baiqi 2024-11-04 15:59:42 +08:00 committed by Craftsman
parent 935c1d652e
commit 7c495db38a

View File

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