Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
Support
提交反馈
为 GitLab 提交贡献
登录
切换导航
兵
兵役_吉林工业
项目
项目
详情
动态
版本
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
麦嘉得
兵役_吉林工业
提交
1ae92fe9
提交
1ae92fe9
编写于
9月 26, 2018
作者:
Pan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix[Sidebar]: link bug
上级
30cb2df7
变更
2
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
48 行增加
和
12 行删除
+48
-12
Link.vue
src/views/layout/components/Sidebar/Link.vue
+39
-0
SidebarItem.vue
src/views/layout/components/Sidebar/SidebarItem.vue
+9
-12
未找到文件。
src/views/layout/components/Sidebar/Link.vue
0 → 100644
浏览文件 @
1ae92fe9
<
template
>
<!-- eslint-disable vue/require-component-is-->
<component
v-bind=
"linkProps(to)"
>
<slot/>
</component>
</
template
>
<
script
>
import
{
validateURL
}
from
'
@/utils/validate
'
export
default
{
props
:
{
to
:
{
type
:
String
,
required
:
true
}
},
methods
:
{
isExternalLink
(
routePath
)
{
return
validateURL
(
routePath
)
},
linkProps
(
url
)
{
if
(
this
.
isExternalLink
(
url
))
{
return
{
is
:
'
a
'
,
href
:
url
,
target
:
'
_blank
'
,
rel
:
'
noopener
'
}
}
return
{
is
:
'
router-link
'
,
to
:
url
}
}
}
}
</
script
>
src/views/layout/components/Sidebar/SidebarItem.vue
浏览文件 @
1ae92fe9
...
@@ -2,11 +2,11 @@
...
@@ -2,11 +2,11 @@
<div
v-if=
"!item.hidden&&item.children"
class=
"menu-wrapper"
>
<div
v-if=
"!item.hidden&&item.children"
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"
>
<a
:href=
"onlyOneChild.path"
target=
"_blank"
@
click=
"clickLink(onlyOneChild.path,$event
)"
>
<a
pp-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
v-if=
"onlyOneChild.meta"
:icon=
"onlyOneChild.meta.icon||item.meta.icon"
:title=
"onlyOneChild.meta.title"
/>
</el-menu-item>
</el-menu-item>
</a>
</a
pp-link
>
</
template
>
</
template
>
<el-submenu
v-else
:index=
"item.name||item.path"
>
<el-submenu
v-else
:index=
"item.name||item.path"
>
...
@@ -22,11 +22,11 @@
...
@@ -22,11 +22,11 @@
:key=
"child.path"
:key=
"child.path"
:base-path=
"resolvePath(child.path)"
:base-path=
"resolvePath(child.path)"
class=
"nest-menu"
/>
class=
"nest-menu"
/>
<a
v-else
:href=
"child.path"
:key=
"child.name"
target=
"_blank"
@
click=
"clickLink(child.path,$event)
"
>
<a
pp-link
v-else
:to=
"resolvePath(child.path)"
:key=
"child.name
"
>
<el-menu-item
:index=
"resolvePath(child.path)"
>
<el-menu-item
:index=
"resolvePath(child.path)"
>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
</el-menu-item>
</el-menu-item>
</a>
</a
pp-link
>
</
template
>
</
template
>
</el-submenu>
</el-submenu>
...
@@ -37,10 +37,11 @@
...
@@ -37,10 +37,11 @@
import
path
from
'
path
'
import
path
from
'
path
'
import
{
validateURL
}
from
'
@/utils/validate
'
import
{
validateURL
}
from
'
@/utils/validate
'
import
Item
from
'
./Item
'
import
Item
from
'
./Item
'
import
AppLink
from
'
./Link
'
export
default
{
export
default
{
name
:
'
SidebarItem
'
,
name
:
'
SidebarItem
'
,
components
:
{
Item
},
components
:
{
Item
,
AppLink
},
props
:
{
props
:
{
// route object
// route object
item
:
{
item
:
{
...
@@ -87,17 +88,13 @@ export default {
...
@@ -87,17 +88,13 @@ export default {
return
false
return
false
},
},
resolvePath
(
routePath
)
{
resolvePath
(
routePath
)
{
if
(
this
.
isExternalLink
(
routePath
))
{
return
routePath
}
return
path
.
resolve
(
this
.
basePath
,
routePath
)
return
path
.
resolve
(
this
.
basePath
,
routePath
)
},
},
isExternalLink
(
routePath
)
{
isExternalLink
(
routePath
)
{
return
validateURL
(
routePath
)
return
validateURL
(
routePath
)
},
clickLink
(
routePath
,
e
)
{
if
(
!
this
.
isExternalLink
(
routePath
))
{
e
.
preventDefault
()
const
path
=
this
.
resolvePath
(
routePath
)
this
.
$router
.
push
(
path
)
}
}
}
}
}
}
}
...
...
编辑
预览
Markdown
格式
0%
请重试
or
添加新附件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
先完成此消息的编辑!
取消
想要评论请
注册
或
登录