Browse Source

Update menu-tree.vue

master
许孟阳 1 year ago
parent
commit
5b2aabc706
  1. 11
      packages/manage/common/menu-tree.vue

11
packages/manage/common/menu-tree.vue

@ -3,19 +3,19 @@ @@ -3,19 +3,19 @@
:background-color="state.style.menuBg" :active-text-color="state.style.menuActiveColor" :size="state.size.size">
<template v-for="menu in data || state.menus">
<template v-if="menu.children && menu.children.length > 0">
<el-sub-menu :index="menu.path" :key="menu.path">
<el-sub-menu :index="getPath(menu)" :key="menu.path">
<template #title>
<component class="icon" :is="menu.icon || state.style.menuDefaultIcon"></component>
<span>{{ menu.title || t(menu.i18n) }}</span>
</template>
<el-menu-item v-for="child in menu.children" :index="child.path" :router="router">
<el-menu-item v-for="child in menu.children" :index="getPath(child)" :router="router">
<component class="icon" :is="child.icon || state.style.menuDefaultIcon"></component>
{{ child.title || t(child.i18n) }}
</el-menu-item>
</el-sub-menu>
</template>
<template v-else>
<el-menu-item :index="menu.path" :key="menu.path" :router="router">
<el-menu-item :index="getPath(menu)" :key="menu.path" :router="router">
<component class="icon" :is="menu.icon || state.style.menuDefaultIcon"></component>
<span>{{ menu.title || t(menu.i18n) }}</span>
</el-menu-item>
@ -43,8 +43,9 @@ const props = defineProps({ @@ -43,8 +43,9 @@ const props = defineProps({
});
const router = useRouter();
const clickMenu = (menu) => {
router.push(menu.path);
const getPath = (menu) => {
const prefix = menu.path.startsWith("/") ? "" : "/";
return prefix + menu.path;
};
const active = ref("");
onMounted(() => {

Loading…
Cancel
Save