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

Loading…
Cancel
Save