forked from AkkomaGang/admin-fe
refactor[ExternalLink]: tweak externalLink judge
This commit is contained in:
parent
ccf1791fca
commit
1e50d4a93b
1 changed files with 10 additions and 9 deletions
|
@ -2,17 +2,11 @@
|
|||
<div v-if="!item.hidden&&item.children" class="menu-wrapper">
|
||||
|
||||
<template v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow">
|
||||
<a v-if="isExternalLink(onlyOneChild.path)" :href="onlyOneChild.path" target="blank">
|
||||
apple
|
||||
<a :href="onlyOneChild.path" target="_blank" @click="clickLink(onlyOneChild.path,$event)">
|
||||
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
|
||||
<item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon" :title="generateTitle(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="generateTitle(onlyOneChild.meta.title)" />
|
||||
</el-menu-item>
|
||||
</router-link>
|
||||
</template>
|
||||
|
||||
<el-submenu v-else :index="item.name||item.path">
|
||||
|
@ -23,11 +17,11 @@
|
|||
<template v-for="child in item.children" v-if="!child.hidden">
|
||||
<sidebar-item v-if="child.children&&child.children.length>0" :is-nest="true" :item="child" :key="child.path" :base-path="resolvePath(child.path)" class="nest-menu"/>
|
||||
|
||||
<router-link v-else :to="resolvePath(child.path)" :key="child.name">
|
||||
<a v-else :href="child.path" :key="child.name" target="_blank" @click="clickLink(child.path,$event)">
|
||||
<el-menu-item :index="resolvePath(child.path)">
|
||||
<item v-if="child.meta" :icon="child.meta.icon" :title="generateTitle(child.meta.title)" />
|
||||
</el-menu-item>
|
||||
</router-link>
|
||||
</a>
|
||||
</template>
|
||||
</el-submenu>
|
||||
|
||||
|
@ -85,6 +79,13 @@ export default {
|
|||
isExternalLink(routePath) {
|
||||
return validateURL(routePath)
|
||||
},
|
||||
clickLink(routePath, e) {
|
||||
if (!this.isExternalLink(routePath)) {
|
||||
e.preventDefault()
|
||||
const path = this.resolvePath(routePath)
|
||||
this.$router.push(path)
|
||||
}
|
||||
},
|
||||
generateTitle
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue