serv\web-侧边栏 标签统一

This commit is contained in:
2025-10-27 16:21:00 +08:00
parent e50de4a277
commit 5fa4e1cd42
47 changed files with 1933 additions and 1307 deletions

View File

@@ -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);
}
}