mirror of
https://github.com/imdap/ruoyi-plus-vben5.git
synced 2026-05-11 13:22:09 +08:00
Merge branch 'main' of https://github.com/vbenjs/vue-vben-admin into antdv-next
This commit is contained in:
@@ -5,6 +5,7 @@ import { computed, onBeforeUnmount, onMounted, reactive, useSlots } from 'vue';
|
||||
|
||||
import { useNamespace } from '@vben-core/composables';
|
||||
import { VbenIcon, VbenTooltip } from '@vben-core/shadcn-ui';
|
||||
import { isHttpUrl } from '@vben-core/shared/utils';
|
||||
|
||||
import qs from 'qs';
|
||||
|
||||
@@ -29,12 +30,21 @@ const subMenu = useSubMenuContext();
|
||||
const { parentMenu, parentPaths } = useMenu();
|
||||
|
||||
const active = computed(() => props.path === rootMenu?.activePath);
|
||||
const menuIcon = computed(() => (active.value ? props.activeIcon || props.icon : props.icon));
|
||||
const menuIcon = computed(() =>
|
||||
active.value ? props.activeIcon || props.icon : props.icon,
|
||||
);
|
||||
|
||||
const isTopLevelMenuItem = computed(() => parentMenu.value?.type.name === 'Menu');
|
||||
const isHttp = computed(() => isHttpUrl(item.parentPaths.at(-1)));
|
||||
|
||||
const isTopLevelMenuItem = computed(
|
||||
() => parentMenu.value?.type.name === 'Menu',
|
||||
);
|
||||
|
||||
const collapseShowTitle = computed(
|
||||
() => rootMenu.props?.collapseShowTitle && isTopLevelMenuItem.value && rootMenu.props.collapse,
|
||||
() =>
|
||||
rootMenu.props?.collapseShowTitle &&
|
||||
isTopLevelMenuItem.value &&
|
||||
rootMenu.props.collapse,
|
||||
);
|
||||
|
||||
const showTooltip = computed(
|
||||
@@ -77,11 +87,16 @@ onBeforeUnmount(() => {
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<a
|
||||
:href="(item.parentPaths.at(-1) ?? '') + (item?.query ? `?${qs.stringify(item?.query)}` : '')"
|
||||
@click.prevent.stop="handleClick"
|
||||
<router-link
|
||||
v-slot="{ href }"
|
||||
custom
|
||||
:to="
|
||||
(item.parentPaths.at(-1) ?? '') +
|
||||
(item?.query ? `?${qs.stringify(item?.query)}` : '')
|
||||
"
|
||||
>
|
||||
<li
|
||||
<a
|
||||
:href="isHttp ? item.parentPaths.at(-1) : href"
|
||||
:class="[
|
||||
rootMenu.theme,
|
||||
b(),
|
||||
@@ -90,9 +105,13 @@ onBeforeUnmount(() => {
|
||||
is('collapse-show-title', collapseShowTitle),
|
||||
]"
|
||||
role="menuitem"
|
||||
@click.prevent.stop="handleClick"
|
||||
>
|
||||
<!-- -->
|
||||
<VbenTooltip v-if="showTooltip" :content-class="[rootMenu.theme]" side="right">
|
||||
<VbenTooltip
|
||||
v-if="showTooltip"
|
||||
:content-class="[rootMenu.theme]"
|
||||
side="right"
|
||||
>
|
||||
<template #trigger>
|
||||
<div :class="[nsMenu.be('tooltip', 'trigger')]">
|
||||
<VbenIcon :class="nsMenu.e('icon')" :icon="menuIcon" fallback />
|
||||
@@ -105,11 +124,15 @@ onBeforeUnmount(() => {
|
||||
<slot name="title"></slot>
|
||||
</VbenTooltip>
|
||||
<div v-show="!showTooltip" :class="[e('content')]">
|
||||
<MenuBadge v-if="rootMenu.props.mode !== 'horizontal'" class="right-2" v-bind="props" />
|
||||
<MenuBadge
|
||||
v-if="rootMenu.props.mode !== 'horizontal'"
|
||||
class="right-2"
|
||||
v-bind="props"
|
||||
/>
|
||||
<VbenIcon :class="nsMenu.e('icon')" :icon="menuIcon" />
|
||||
<slot></slot>
|
||||
<slot name="title"></slot>
|
||||
</div>
|
||||
</li>
|
||||
</a>
|
||||
</a>
|
||||
</router-link>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user