Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
W
web-monitor
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
web-monitor
Commits
1ae92fe9
Commit
1ae92fe9
authored
Sep 26, 2018
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix[Sidebar]: link bug
parent
30cb2df7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
12 deletions
+48
-12
Link.vue
src/views/layout/components/Sidebar/Link.vue
+39
-0
SidebarItem.vue
src/views/layout/components/Sidebar/SidebarItem.vue
+9
-12
No files found.
src/views/layout/components/Sidebar/Link.vue
0 → 100644
View file @
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
View file @
1ae92fe9
...
...
@@ -2,11 +2,11 @@
<div
v-if=
"!item.hidden&&item.children"
class=
"menu-wrapper"
>
<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}">
<item
v-if=
"onlyOneChild.meta"
:icon=
"onlyOneChild.meta.icon||item.meta.icon"
:title=
"onlyOneChild.meta.title"
/>
</el-menu-item>
</a>
</a
pp-link
>
</
template
>
<el-submenu
v-else
:index=
"item.name||item.path"
>
...
...
@@ -22,11 +22,11 @@
:key=
"child.path"
:base-path=
"resolvePath(child.path)"
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)"
>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
</el-menu-item>
</a>
</a
pp-link
>
</
template
>
</el-submenu>
...
...
@@ -37,10 +37,11 @@
import
path
from
'path'
import
{
validateURL
}
from
'@/utils/validate'
import
Item
from
'./Item'
import
AppLink
from
'./Link'
export
default
{
name
:
'SidebarItem'
,
components
:
{
Item
},
components
:
{
Item
,
AppLink
},
props
:
{
// route object
item
:
{
...
...
@@ -87,17 +88,13 @@ export default {
return
false
},
resolvePath
(
routePath
)
{
if
(
this
.
isExternalLink
(
routePath
))
{
return
routePath
}
return
path
.
resolve
(
this
.
basePath
,
routePath
)
},
isExternalLink
(
routePath
)
{
return
validateURL
(
routePath
)
},
clickLink
(
routePath
,
e
)
{
if
(
!
this
.
isExternalLink
(
routePath
))
{
e
.
preventDefault
()
const
path
=
this
.
resolvePath
(
routePath
)
this
.
$router
.
push
(
path
)
}
}
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment