Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
兵
兵役_吉林工业
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
麦嘉得
兵役_吉林工业
提交
5bfadbc1
提交
5bfadbc1
编写于
2月 28, 2019
作者:
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
perf[Sidebar]: optimize logic
上级
be61e702
变更
2
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
32 行删除
+22
-32
Item.vue
src/views/layout/components/Sidebar/Item.vue
+9
-8
SidebarItem.vue
src/views/layout/components/Sidebar/SidebarItem.vue
+13
-24
未找到文件。
src/views/layout/components/Sidebar/Item.vue
浏览文件 @
5bfadbc1
...
@@ -3,17 +3,18 @@ export default {
...
@@ -3,17 +3,18 @@ export default {
name
:
'
MenuItem
'
,
name
:
'
MenuItem
'
,
functional
:
true
,
functional
:
true
,
props
:
{
props
:
{
icon
:
{
meta
:
{
type
:
String
,
type
:
Object
,
default
:
''
default
:
()
=>
{
},
return
{
title
:
{
title
:
''
,
type
:
String
,
icon
:
''
default
:
''
}
}
}
}
},
},
render
(
h
,
context
)
{
render
(
h
,
context
)
{
const
{
icon
,
title
}
=
context
.
props
const
{
icon
,
title
}
=
context
.
props
.
meta
const
vnodes
=
[]
const
vnodes
=
[]
if
(
icon
)
{
if
(
icon
)
{
...
...
src/views/layout/components/Sidebar/SidebarItem.vue
浏览文件 @
5bfadbc1
<
template
>
<
template
>
<div
v-if=
"!item.hidden
&&item.children
"
class=
"menu-wrapper"
>
<div
v-if=
"!item.hidden"
class=
"menu-wrapper"
>
<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
:to=
"resolvePath(onlyOneChild.path)"
>
<app-link
:to=
"resolvePath(onlyOneChild.path)"
>
<el-menu-item
:index=
"resolvePath(onlyOneChild.path)"
:class=
"
{'submenu-title-noDropdown':!isNest}">
<el-menu-item
:index=
"resolvePath(onlyOneChild.path)"
:class=
"
{'submenu-title-noDropdown':!isNest}">
<item
v-if=
"onlyOneChild.meta"
:icon=
"onlyOneChild.meta.icon||item.meta.icon"
:title=
"onlyOneChild.meta.title
"
/>
<item
:meta=
"Object.assign(
{},item.meta,onlyOneChild.meta)
" />
</el-menu-item>
</el-menu-item>
</app-link>
</app-link>
</
template
>
</
template
>
<el-submenu
v-else
:index=
"resolvePath(item.path)"
>
<el-submenu
v-else
ref=
"subMenu"
:index=
"resolvePath(item.path)"
>
<
template
slot=
"title"
>
<
template
slot=
"title"
>
<item
v-if=
"item.meta"
:icon=
"item.meta.icon"
:title=
"item.meta.title
"
/>
<item
:meta=
"item.meta
"
/>
</
template
>
</
template
>
<
template
v-for=
"child in item.children"
v-if=
"!child.hidden"
>
<sidebar-item
<sidebar-item
v-if=
"child.children&&child.children.length>0
"
v-for=
"child in item.children
"
:is-nest=
"true"
:is-nest=
"true"
:item=
"child"
:item=
"child"
:key=
"child.path"
:key=
"child.path"
:base-path=
"resolvePath(child.path)"
:base-path=
"resolvePath(child.path)"
class=
"nest-menu"
/>
class=
"nest-menu"
/>
<app-link
v-else
:to=
"resolvePath(child.path)"
:key=
"child.name"
>
<el-menu-item
:index=
"resolvePath(child.path)"
>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
</el-menu-item>
</app-link>
</
template
>
</el-submenu>
</el-submenu>
</div>
</div>
...
@@ -64,7 +56,7 @@ export default {
...
@@ -64,7 +56,7 @@ export default {
return
{}
return
{}
},
},
methods
:
{
methods
:
{
hasOneShowingChild
(
children
,
parent
)
{
hasOneShowingChild
(
children
=
[]
,
parent
)
{
const
showingChildren
=
children
.
filter
(
item
=>
{
const
showingChildren
=
children
.
filter
(
item
=>
{
if
(
item
.
hidden
)
{
if
(
item
.
hidden
)
{
return
false
return
false
...
@@ -89,13 +81,10 @@ export default {
...
@@ -89,13 +81,10 @@ export default {
return
false
return
false
},
},
resolvePath
(
routePath
)
{
resolvePath
(
routePath
)
{
if
(
this
.
isExternalLink
(
routePath
))
{
if
(
isExternal
(
routePath
))
{
return
routePath
return
routePath
}
}
return
path
.
resolve
(
this
.
basePath
,
routePath
)
return
path
.
resolve
(
this
.
basePath
,
routePath
)
},
isExternalLink
(
routePath
)
{
return
isExternal
(
routePath
)
}
}
}
}
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录