Commit 84203e28 by ningjihai

菜单

parent 15ab1ab3
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
<template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow"> <template v-if="hasOneShowingChild(item.children, item) && (!onlyOneChild.children || onlyOneChild.noShowingChildren) && !item.alwaysShow">
<app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)"> <app-link v-if="onlyOneChild.meta" :to="resolvePath(onlyOneChild.path, onlyOneChild.query)">
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }" @click="pageLuyou(onlyOneChild)"> <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{ 'submenu-title-noDropdown': !isNest }" @click="pageLuyou(onlyOneChild)">
<!-- <svg-icon :icon-class="onlyOneChild.meta.icon || (item.meta && item.meta.icon)"/> -->
<template #title><span class="menu-title" :title="hasTitle(onlyOneChild.meta.title)" >{{ onlyOneChild.meta.title }}</span></template> <template #title><span class="menu-title" :title="hasTitle(onlyOneChild.meta.title)" >{{ onlyOneChild.meta.title }}</span></template>
</el-menu-item> </el-menu-item>
</app-link> </app-link>
......
...@@ -205,6 +205,7 @@ function handleLogin() { ...@@ -205,6 +205,7 @@ function handleLogin() {
} }
function transformRoutes(originalRoutes) { function transformRoutes(originalRoutes) {
return originalRoutes.map(route => { return originalRoutes.map(route => {
const hasChildren = route.submenu && route.submenu.length > 0
// 基础转换 - 所有路由都使用Layout作为父组件 // 基础转换 - 所有路由都使用Layout作为父组件
const transformedRoute = { const transformedRoute = {
path: route.url, path: route.url,
...@@ -217,13 +218,15 @@ function transformRoutes(originalRoutes) { ...@@ -217,13 +218,15 @@ function transformRoutes(originalRoutes) {
title: route.menuname, title: route.menuname,
icon: route.icon, icon: route.icon,
noCache: false, noCache: false,
link: null link: null,
singleLevel: !hasChildren
}, },
children: [] // 初始化children数组 children: [] // 初始化children数组
}; };
// 处理有子路由的情况 // 处理有子路由的情况
if (route.submenu && route.submenu.length > 0) { if (hasChildren) {
transformedRoute.alwaysShow = true
transformedRoute.children = route.submenu.map(child => ({ transformedRoute.children = route.submenu.map(child => ({
path: child.url.startsWith('/') ? child.url.substring(1) : child.url, path: child.url.startsWith('/') ? child.url.substring(1) : child.url,
name: child.menuname.replace(/\s+/g, ''), name: child.menuname.replace(/\s+/g, ''),
...@@ -255,9 +258,9 @@ function transformRoutes(originalRoutes) { ...@@ -255,9 +258,9 @@ function transformRoutes(originalRoutes) {
} }
// 添加alwaysShow属性给有子路由的项 // 添加alwaysShow属性给有子路由的项
if (transformedRoute.children && transformedRoute.children.length > 0) { // if (transformedRoute.children && transformedRoute.children.length > 0) {
transformedRoute.alwaysShow = true; // transformedRoute.alwaysShow = true;
} // }
// console.log('transformedRoute',transformedRoute) // console.log('transformedRoute',transformedRoute)
return transformedRoute; return transformedRoute;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论