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
61394e57
Commit
61394e57
authored
Aug 24, 2018
by
Pan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feature: [sidebar] add external-link
parent
85c5d600
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
64 additions
and
12 deletions
+64
-12
link.svg
src/icons/svg/link.svg
+1
-0
index.js
src/router/index.js
+11
-0
Item.vue
src/views/layout/components/Sidebar/Item.vue
+29
-0
SidebarItem.vue
src/views/layout/components/Sidebar/SidebarItem.vue
+23
-12
No files found.
src/icons/svg/link.svg
0 → 100644
View file @
61394e57
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg
t=
"1534846208920"
class=
"icon"
style=
""
viewBox=
"0 0 1024 1024"
version=
"1.1"
xmlns=
"http://www.w3.org/2000/svg"
p-id=
"2941"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"200"
height=
"200"
><defs><style
type=
"text/css"
></style></defs><path
d=
"M912 1008.512H15.488V112h448.256v96H111.488v704.512H816V560.256h96z"
p-id=
"2942"
></path><path
d=
"M918.208 37.888l67.904 67.904L545.984 545.92 478.08 478.08z"
p-id=
"2943"
></path><path
d=
"M1007.168 310.656h-96V112h-208V16h304z"
p-id=
"2944"
></path></svg>
\ No newline at end of file
src/router/index.js
View file @
61394e57
...
...
@@ -130,6 +130,17 @@ export const constantRouterMap = [
]
},
{
path
:
'external-link'
,
component
:
Layout
,
children
:
[
{
path
:
'https://panjiachen.github.io/vue-element-admin-site/#/'
,
meta
:
{
title
:
'externalLink'
,
icon
:
'link'
}
}
]
},
{
path
:
'*'
,
redirect
:
'/404'
,
hidden
:
true
}
]
...
...
src/views/layout/components/Sidebar/Item.vue
0 → 100644
View file @
61394e57
<
script
>
export
default
{
name
:
'MenuItem'
,
functional
:
true
,
props
:
{
icon
:
{
type
:
String
,
default
:
''
},
title
:
{
type
:
String
,
default
:
''
}
},
render
(
h
,
context
)
{
const
{
icon
,
title
}
=
context
.
props
const
vnodes
=
[]
if
(
icon
)
{
vnodes
.
push
(
<
svg
-
icon
icon
-
class
=
{
icon
}
/>
)
}
if
(
title
)
{
vnodes
.
push
(
<
span
slot
=
'title'
>
{(
title
)}
<
/span>
)
}
return
vnodes
}
}
</
script
>
src/views/layout/components/Sidebar/SidebarItem.vue
View file @
61394e57
<
template
>
<div
v-if=
"!item.hidden&&item.children"
class=
"menu-wrapper"
>
<router-link
v-if=
"hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow"
:to=
"resolvePath(onlyOneChild.path)"
>
<el-menu-item
:index=
"resolvePath(onlyOneChild.path)"
:class=
"
{'submenu-title-noDropdown':!isNest}">
<svg-icon
v-if=
"onlyOneChild.meta&&onlyOneChild.meta.icon"
:icon-class=
"onlyOneChild.meta.icon"
/>
<span
v-if=
"onlyOneChild.meta&&onlyOneChild.meta.title"
slot=
"title"
>
{{
onlyOneChild
.
meta
.
title
}}
</span>
</el-menu-item>
</router-link>
<template
v-if=
"hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow"
>
<a
v-if=
"isExternalLink(onlyOneChild.path)"
:href=
"onlyOneChild.path"
target=
"blank"
>
apple
<el-menu-item
:index=
"resolvePath(onlyOneChild.path)"
:class=
"
{'submenu-title-noDropdown':!isNest}">
<item
v-if=
"onlyOneChild.meta"
:icon=
"onlyOneChild.meta.icon"
:title=
"onlyOneChild.meta.title"
/>
</el-menu-item>
</a>
<router-link
v-else
: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"
:title=
"onlyOneChild.meta.title"
/>
</el-menu-item>
</router-link>
</
template
>
<el-submenu
v-else
:index=
"item.name||item.path"
>
<
template
slot=
"title"
>
<svg-icon
v-if=
"item.meta&&item.meta.icon"
:icon-class=
"item.meta.icon"
/>
<span
v-if=
"item.meta&&item.meta.title"
slot=
"title"
>
{{
item
.
meta
.
title
}}
</span>
<item
v-if=
"item.meta"
:icon=
"item.meta.icon"
:title=
"item.meta.title"
/>
</
template
>
<
template
v-for=
"child in item.children"
v-if=
"!child.hidden"
>
...
...
@@ -25,8 +31,7 @@
<router-link
v-else
:to=
"resolvePath(child.path)"
:key=
"child.name"
>
<el-menu-item
:index=
"resolvePath(child.path)"
>
<svg-icon
v-if=
"child.meta&&child.meta.icon"
:icon-class=
"child.meta.icon"
/>
<span
v-if=
"child.meta&&child.meta.title"
slot=
"title"
>
{{
child
.
meta
.
title
}}
</span>
<item
v-if=
"child.meta"
:icon=
"child.meta.icon"
:title=
"child.meta.title"
/>
</el-menu-item>
</router-link>
</
template
>
...
...
@@ -37,9 +42,12 @@
<
script
>
import
path
from
'path'
import
{
validateURL
}
from
'@/utils/validate'
import
Item
from
'./Item'
export
default
{
name
:
'SidebarItem'
,
components
:
{
Item
},
props
:
{
// route配置json
item
:
{
...
...
@@ -76,8 +84,11 @@ export default {
}
return
false
},
resolvePath
(...
paths
)
{
return
path
.
resolve
(
this
.
basePath
,
...
paths
)
resolvePath
(
routePath
)
{
return
path
.
resolve
(
this
.
basePath
,
routePath
)
},
isExternalLink
(
routePath
)
{
return
validateURL
(
routePath
)
}
}
}
...
...
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