refactor[ExternalLink]: tweak externalLink judge
This commit is contained in:
parent
61394e573e
commit
d54bdc8fff
|
@ -2,17 +2,11 @@
|
||||||
<div v-if="!item.hidden&&item.children" class="menu-wrapper">
|
<div v-if="!item.hidden&&item.children" class="menu-wrapper">
|
||||||
|
|
||||||
<template v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow">
|
<template v-if="hasOneShowingChild(item.children) && !onlyOneChild.children&&!item.alwaysShow">
|
||||||
<a v-if="isExternalLink(onlyOneChild.path)" :href="onlyOneChild.path" target="blank">
|
<a :href="onlyOneChild.path" target="_blank" @click="clickLink(onlyOneChild.path,$event)">
|
||||||
apple
|
|
||||||
<el-menu-item :index="resolvePath(onlyOneChild.path)" :class="{'submenu-title-noDropdown':!isNest}">
|
<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" />
|
<item v-if="onlyOneChild.meta" :icon="onlyOneChild.meta.icon" :title="onlyOneChild.meta.title" />
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</a>
|
</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>
|
</template>
|
||||||
|
|
||||||
<el-submenu v-else :index="item.name||item.path">
|
<el-submenu v-else :index="item.name||item.path">
|
||||||
|
@ -29,11 +23,11 @@
|
||||||
:base-path="resolvePath(child.path)"
|
:base-path="resolvePath(child.path)"
|
||||||
class="nest-menu"/>
|
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)">
|
<el-menu-item :index="resolvePath(child.path)">
|
||||||
<item v-if="child.meta" :icon="child.meta.icon" :title="child.meta.title" />
|
<item v-if="child.meta" :icon="child.meta.icon" :title="child.meta.title" />
|
||||||
</el-menu-item>
|
</el-menu-item>
|
||||||
</router-link>
|
</a>
|
||||||
</template>
|
</template>
|
||||||
</el-submenu>
|
</el-submenu>
|
||||||
|
|
||||||
|
@ -89,6 +83,13 @@ export default {
|
||||||
},
|
},
|
||||||
isExternalLink(routePath) {
|
isExternalLink(routePath) {
|
||||||
return validateURL(routePath)
|
return validateURL(routePath)
|
||||||
|
},
|
||||||
|
clickLink(routePath, e) {
|
||||||
|
if (!this.isExternalLink(routePath)) {
|
||||||
|
e.preventDefault()
|
||||||
|
const path = this.resolvePath(routePath)
|
||||||
|
this.$router.push(path)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue