|
1 | 1 | <template>
|
2 | 2 | <div v-if="!item.hidden&&item.children" class="menu-wrapper">
|
3 | 3 |
|
4 |
| - <router-link v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow" :to="resolvePath(onlyOneChild.path)"> |
5 |
| - <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> |
6 |
| - <svg-icon v-if="onlyOneChild.meta&&onlyOneChild.meta.icon" :icon-class="onlyOneChild.meta.icon"/> |
7 |
| - <span v-if="onlyOneChild.meta&&onlyOneChild.meta.title" slot="title">{{ onlyOneChild.meta.title }}</span> |
8 |
| - </el-menu-item> |
9 |
| - </router-link> |
| 4 | + <template v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow"> |
| 5 | + <a v-if="isExternalLink(onlyOneChild.path)" :href="onlyOneChild.path" target="blank"> |
| 6 | + apple |
| 7 | + <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> |
| 8 | + <item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon" :title="onlyOneChild.meta.title" /> |
| 9 | + </el-menu-item> |
| 10 | + </a> |
| 11 | + <router-link v-else :to="resolvePath(onlyOneChild.path)"> |
| 12 | + <el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}"> |
| 13 | + <item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon" :title="onlyOneChild.meta.title" /> |
| 14 | + </el-menu-item> |
| 15 | + </router-link> |
| 16 | + </template> |
10 | 17 |
|
11 | 18 | <el-submenu v-else :index="item.name||item.path">
|
12 | 19 | <template slot="title">
|
13 |
| - <svg-icon v-if="item.meta&&item.meta.icon" :icon-class="item.meta.icon"/> |
14 |
| - <span v-if="item.meta&&item.meta.title" slot="title">{{ item.meta.title }}</span> |
| 20 | + <item v-if="item.meta" :icon="item.meta.icon" :title="item.meta.title" /> |
15 | 21 | </template>
|
16 | 22 |
|
17 | 23 | <template v-for="child in item.children" v-if="!child.hidden">
|
|
25 | 31 |
|
26 | 32 | <router-link v-else :to="resolvePath(child.path)" :key="child.name">
|
27 | 33 | <el-menu-item :index="resolvePath(child.path)">
|
28 |
| - <svg-icon v-if="child.meta&&child.meta.icon" :icon-class="child.meta.icon"/> |
29 |
| - <span v-if="child.meta&&child.meta.title" slot="title">{{ child.meta.title }}</span> |
| 34 | + <item v-if="child.meta" :icon="child.meta.icon" :title="child.meta.title" /> |
30 | 35 | </el-menu-item>
|
31 | 36 | </router-link>
|
32 | 37 | </template>
|
|
37 | 42 |
|
38 | 43 | <script>
|
39 | 44 | import path from 'path'
|
| 45 | +import { validateURL } from '@/utils/validate' |
| 46 | +import Item from './Item' |
40 | 47 |
|
41 | 48 | export default {
|
42 | 49 | name: 'SidebarItem',
|
| 50 | + components: { Item }, |
43 | 51 | props: {
|
44 | 52 | // route配置json
|
45 | 53 | item: {
|
@@ -76,8 +84,11 @@ export default {
|
76 | 84 | }
|
77 | 85 | return false
|
78 | 86 | },
|
79 |
| - resolvePath(...paths) { |
80 |
| - return path.resolve(this.basePath, ...paths) |
| 87 | + resolvePath(routePath) { |
| 88 | + return path.resolve(this.basePath, routePath) |
| 89 | + }, |
| 90 | + isExternalLink(routePath) { |
| 91 | + return validateURL(routePath) |
81 | 92 | }
|
82 | 93 | }
|
83 | 94 | }
|
|
0 commit comments