serv\web-侧边栏 标签统一
This commit is contained in:
@@ -28,7 +28,7 @@
|
||||
v-if="expanded && !collapsed"
|
||||
>
|
||||
<MenuItem
|
||||
v-for="child in menu.children"
|
||||
v-for="child in filteredChildren"
|
||||
:key="child.menuID"
|
||||
:menu="child"
|
||||
:collapsed="false"
|
||||
@@ -85,15 +85,23 @@ const emit = defineEmits<{
|
||||
'menu-click': [menu: SysMenu];
|
||||
}>();
|
||||
|
||||
// 状态
|
||||
const expanded = ref(false);
|
||||
// 状态 - 顶层菜单默认展开
|
||||
const expanded = ref(props.level === 0);
|
||||
|
||||
// Composition API
|
||||
const route = useRoute();
|
||||
|
||||
// 计算属性
|
||||
const hasChildren = computed(() => {
|
||||
return props.menu.children && props.menu.children.length > 0;
|
||||
// 只显示SIDEBAR类型的子菜单,过滤掉PAGE类型
|
||||
return props.menu.children &&
|
||||
props.menu.children.filter((child: SysMenu) => child.type === MenuType.SIDEBAR).length > 0;
|
||||
});
|
||||
|
||||
// 过滤后的子菜单(只显示SIDEBAR类型)
|
||||
const filteredChildren = computed(() => {
|
||||
if (!props.menu.children) return [];
|
||||
return props.menu.children.filter((child: SysMenu) => child.type === MenuType.SIDEBAR);
|
||||
});
|
||||
|
||||
const isActive = computed(() => {
|
||||
@@ -109,7 +117,8 @@ function toggleExpanded() {
|
||||
}
|
||||
|
||||
function handleClick() {
|
||||
if (props.menu.type === MenuType.NAVIGATION && props.menu.url) {
|
||||
// 支持NAVIGATION和SIDEBAR类型的菜单点击
|
||||
if (props.menu.url && (props.menu.type === MenuType.NAVIGATION || props.menu.type === MenuType.SIDEBAR)) {
|
||||
emit('menu-click', props.menu);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user