|
@@ -2,11 +2,11 @@
|
2
|
2
|
<div v-if="!item.hidden&&item.children" class="menu-wrapper">
|
3
|
3
|
|
4
|
4
|
<template v-if="hasOneShowingChild(item.children,item) && (!onlyOneChild.children||onlyOneChild.noShowingChildren)&&!item.alwaysShow">
|
5
|
|
- <a :href="onlyOneChild.path" target="_blank" @click="clickLink(onlyOneChild.path,$event)">
|
|
5
|
+ <app-link :to="resolvePath(onlyOneChild.path)">
|
6
|
6
|
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
|
7
|
7
|
<item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon||item.meta.icon" :title="onlyOneChild.meta.title" />
|
8
|
8
|
</el-menu-item>
|
9
|
|
- </a>
|
|
9
|
+ </app-link>
|
10
|
10
|
</template>
|
11
|
11
|
|
12
|
12
|
<el-submenu v-else :index="item.name||item.path">
|
|
@@ -22,11 +22,11 @@
|
22
|
22
|
:key="child.path"
|
23
|
23
|
:base-path="resolvePath(child.path)"
|
24
|
24
|
class="nest-menu" />
|
25
|
|
- <a v-else :href="child.path" :key="child.name" target="_blank" @click="clickLink(child.path,$event)">
|
|
25
|
+ <app-link v-else :to="resolvePath(child.path)" :key="child.name">
|
26
|
26
|
<el-menu-item :index="resolvePath(child.path)">
|
27
|
27
|
<item v-if="child.meta" :icon="child.meta.icon" :title="child.meta.title" />
|
28
|
28
|
</el-menu-item>
|
29
|
|
- </a>
|
|
29
|
+ </app-link>
|
30
|
30
|
</template>
|
31
|
31
|
</el-submenu>
|
32
|
32
|
|
|
@@ -37,10 +37,11 @@
|
37
|
37
|
import path from 'path'
|
38
|
38
|
import { validateURL } from '@/utils/validate'
|
39
|
39
|
import Item from './Item'
|
|
40
|
+import AppLink from './Link'
|
40
|
41
|
|
41
|
42
|
export default {
|
42
|
43
|
name: 'SidebarItem',
|
43
|
|
- components: { Item },
|
|
44
|
+ components: { Item, AppLink },
|
44
|
45
|
props: {
|
45
|
46
|
// route object
|
46
|
47
|
item: {
|
|
@@ -87,17 +88,13 @@ export default {
|
87
|
88
|
return false
|
88
|
89
|
},
|
89
|
90
|
resolvePath(routePath) {
|
|
91
|
+ if (this.isExternalLink(routePath)) {
|
|
92
|
+ return routePath
|
|
93
|
+ }
|
90
|
94
|
return path.resolve(this.basePath, routePath)
|
91
|
95
|
},
|
92
|
96
|
isExternalLink(routePath) {
|
93
|
97
|
return validateURL(routePath)
|
94
|
|
- },
|
95
|
|
- clickLink(routePath, e) {
|
96
|
|
- if (!this.isExternalLink(routePath)) {
|
97
|
|
- e.preventDefault()
|
98
|
|
- const path = this.resolvePath(routePath)
|
99
|
|
- this.$router.push(path)
|
100
|
|
- }
|
101
|
98
|
}
|
102
|
99
|
}
|
103
|
100
|
}
|